Sign in to follow this  
Followers 0
mikie boy

Deleting markers originally defined by player uid

12 posts in this topic

long story short - i created markers for players that join the server which will follow them around the map - i used uid to assign the marker which is created and setmarker text - to the players name

On joining the marker is there and shows in MP.

Problem...

On disconnection i use the same uid to deletemarker - nothing not a thing. even tried mpframe work - couldnt get it to work.

so does anybody know the way to delete such markers

code as follows

activated via [] execVM "marker.sqf"; - tried onplayerconnected [_id,_name] etc - _name comes back as "ANY" - think its the name given to the server. Anyway...

marker.sqf


_caller = name player;
_uid = getPlayerUID player;
[nil,nil,rHINT, format["%1 connected",_uid]] call RE;
if (isserver) then
{     //also tried createmarkerlocal :(
_marker = createMarker [_uid, position player]; 
_uid setMarkerText _uid;  //can change this to _caller - shows players name
_uid setMarkerType "NATO_base";
_uid setMarkerColor "ColorRed";

while {!isnull player} do
{
_uid setmarkerpos getpos player;
sleep 5;				
};				
} else

{
_marker = createMarker [_uid, position player]; 
_uid setMarkerText _uid;    //can change this to _caller - shows players name
_uid setMarkerType "NATO_base";
_uid setMarkerColor "ColorRed";

while {!isnull player} do
{
_uid setmarkerpos getpos player;
sleep 5;		
};
};

following code is called when player disconnects -

defined in the init as ..

onPlayerDisconnected "[_id, _name, _uid] execVM 'removenamedmarkers.sqf';"; - this hints the exact uid (as shown in the their defined marker within game) when someone leaves.

removenamedmarkers.sqf

deletemarkers1 = {
deletemarker  format ["%1",_named];
deletemarker  format ["%1",_idname];
 deletemarker _uid;	
 deletemarkerlocal _named;	
 deletemarker _named;	
 deletemarkerlocal _idname;
 deletemarkerlocal  format ["%1",_named];
deletemarkerlocal  format ["%1",_idname];
};

_uid = _this select 2;
_caller = _this select 1;
_named = str(_uid);
_idname = _uid;
[nil,nil,rHINT, format["%1 disconnecting",_idname]] call RE;
[nil,nil,"per",rSPAWN,[], {[] call deletemarkers1}];

lobbed as much delete marker stuff in there to see if any work - nope!

So no idea how to get this working - any help would be much appreciated - spent way too long on this

Share this post


Link to post
Share on other sites

have you tried

while {!isnull player} do
{
_uid setmarkerpos getpos player;
sleep 5;				
};
deleteMarker _marker;

edit: only the server needs to update markers. they're global unless you're using the xxxmarkerLocal command.

i'd recommend doing everything client side tho.

Edited by cuel

Share this post


Link to post
Share on other sites

onPlayerDisconnected "deleteMarker format['%1', _uid];";

This doesn't work?

Share this post


Link to post
Share on other sites

alas - neither method works.

cuel - thats how i had it at the start. thought that would have done it, especially as i have identified in that script the name given to create the marker.

sxp2high - alas that did not work either - which looks as it that would do the job for the reason shown below.

appears on disconnecting everything to do with the player is wiped - the onPlayerDisconnected "[_id, _name, _uid]... part seems to find the uid - calls it in a hint as disconnecting - but not joy.

very strange - any other takers?

Share this post


Link to post
Share on other sites

yeah dedicated server - doesnt work on hosted either;

just absolutely lost in which direction to go.

ive changed _marker to global var - marker -

I added an addaction to each player - deletemarker marker; - that works! and the attached marker goes.

i also used the same addaction with this code...

_uid = getPlayerUID player; deletemarker _uid;

that worked -

so is this a locality issue?

Edited by Mikie boy

Share this post


Link to post
Share on other sites

Yea, kinda. You cannot use the variable player on a dedicated server. The dedicated server will exit at that position with an error. Error: Undefined variable: player

When you are testing stuff on a dedicated server, you have to look at your local -and- the server's RPT files. The server may have different errors than the clients.

You can use this code. Just put it in your init.sqf

waitUntil {!(isNull player) || isDedicated}; // Make init.sqf JIP compatible


if (!isDedicated) then {
[] spawn {
	_caller = name player;
	_uid = getPlayerUID player;

	_marker = createMarker [_uid, (getPosATL (vehicle player))]; 
	_marker setMarkerText _uid;    //can change this to _caller - shows players name
	_marker setMarkerType "NATO_base";
	_marker setMarkerColor "ColorRed";

	while {true} do {
		_marker setMarkerPos (getPosATL (vehicle player));
		sleep 5;		
	};
};
};


onPlayerDisconnected "deleteMarker format['%1', _uid];";

Share this post


Link to post
Share on other sites

Alas, no joy. had a go at different methods of removing the marker.

hinted to obtain the markers name (_uid) - shows the same as thought.

however on disconnecting the marker is still showing on the other persons screen (who is still connected). I think therefore this is a matter of having to delete that particular marker from all computers.

I have tried MP frame work to delete it from all computers - no joy.

this is annoying - thought this would have been the easy bit lol.

Share this post


Link to post
Share on other sites

BIS_fnc_listPlayers

Any good? You may be able to add/subtract arrays with this?

scriptName "Functions\misc\fn_listPlayers.sqf";

/*
File: listPlayers.sqf
Author: Karel Moricky

Description:
Returns list of players and playable units

Returns:
Boolean (true when position is in area, false if not).
*/
private ["_this","_SPlist","_MPlist","_resultList"];

_SPlist = switchableUnits;
_MPlist = playableunits;
_resultList = [player];

if (isnil "_this") then {
{
	if !(_x in _resultList) then {_resultList = _resultList + [_x]};
} foreach (_SPlist + _MPlist);
} else {
{
	if (isplayer _x && !(_x in _resultList)) then {_resultList = _resultList + [_x]};
} foreach (_SPlist + _MPlist);
};

_resultList;

Share this post


Link to post
Share on other sites

When I want to track players I usually run a script clientside, using only xxxMarkerLocal commands. Just loop, create markers, add them to an array and delete them before the loop ends.

Some old script I used to track players inside cars (only the driver)

_markArr = [];
while {true} do {
waitUntil {sleep 0.2; alive player};
{
	if ((side _x) == EAST && vehicle _x != _x) then {
		if (driver (vehicle _x) == _x) then {
			_id=format["trk_%1",_x];
			_mark = createMarkerLocal [_id, [(getPosATL _x select 0),(getPosATL _x select 1)]];
			_mark setMarkerShapeLocal "ICON";
			_mark setMarkerTypeLocal "mil_box";
			_mark setMarkerColorLocal "ColorBlue";
			_mark setMarkerTextLocal format [" %1", name _x];
			sleep 0.02;
			_markArr = _markArr + [_mark];
		};
	};
} forEach playableUnits;

sleep 8;
{
		deleteMarkerLocal _x
}forEach _markArr;
};

Then you won't have to send marker updates over the network.

Share this post


Link to post
Share on other sites

cheers Pelham - sorry bud but that doesn't work either.

Cheers cuel, ill have a look at doing it locally - ive tried various things - created arrays - and tried deleting it that way.

The point ive got to is - on the player disconnecting - it calls the script to remove the marker based on the disconnecting player's UID. I get a hint to display the UID of that player - and confirmed that is the correct uid.

It is at this point that the marker will not delete - even if type - deletemarker "41234156"; which would be the leaving players uid. Its almost like the marker name has been removed but remains in situ. OR the onplayer disconnect is the problem.

Ive tried create marker local but - ill start again with your take on it cuel - see what that brings.

appreciate all the help chaps - Any more takers?

Share this post


Link to post
Share on other sites

Just a wild guess.... but maybe the marker is being created more than once and you are only deleting one of them.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0