Jump to content

Photo
- - - - -

Deleting markers originally defined by player uid


  • Please log in to reply
11 replies to this topic

#1 Mikie boy

Mikie boy

    Master Sergeant

  • Members
  • 660 posts

Posted 05 April 2012 - 01:16 AM

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
[FOCK] Mikie J -
Giving bad advice since 2009 :)

Looking for New Players/scripters at Fockersteam
http://fockers.moonfruit.com/
Email: fockersteam@hotmail.co.uk

A3
3 Chapters of Scripting Tutotials -http://www.armaholic...=20465#comments MORE TO FOLLOW
TvTCache Hunt - [FOCK]ers Cache Hunt TvT-x [ALPHA]
Fock Recruit/Group Management - http://www.armaholic...ge.php?id=19041

Currently NOT ACTIVE- Awaiting completion of MSc Computer Science - will return soon....

#2 cuel

cuel

    Sergeant Major

  • Members
  • 1554 posts

Posted 05 April 2012 - 01:53 AM

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, 05 April 2012 - 01:57 AM.


#3 sxp2high

sxp2high

    Master Sergeant

  • Members
  • 779 posts

Posted 05 April 2012 - 05:32 AM

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


This doesn't work?
Posted Image

#4 Mikie boy

Mikie boy

    Master Sergeant

  • Members
  • 660 posts

Posted 05 April 2012 - 01:35 PM

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?
[FOCK] Mikie J -
Giving bad advice since 2009 :)

Looking for New Players/scripters at Fockersteam
http://fockers.moonfruit.com/
Email: fockersteam@hotmail.co.uk

A3
3 Chapters of Scripting Tutotials -http://www.armaholic...=20465#comments MORE TO FOLLOW
TvTCache Hunt - [FOCK]ers Cache Hunt TvT-x [ALPHA]
Fock Recruit/Group Management - http://www.armaholic...ge.php?id=19041

Currently NOT ACTIVE- Awaiting completion of MSc Computer Science - will return soon....

#5 sxp2high

sxp2high

    Master Sergeant

  • Members
  • 779 posts

Posted 05 April 2012 - 04:47 PM

This is for a dedicated server, right?
Posted Image

#6 Mikie boy

Mikie boy

    Master Sergeant

  • Members
  • 660 posts

Posted 05 April 2012 - 05:40 PM

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, 05 April 2012 - 06:15 PM.

[FOCK] Mikie J -
Giving bad advice since 2009 :)

Looking for New Players/scripters at Fockersteam
http://fockers.moonfruit.com/
Email: fockersteam@hotmail.co.uk

A3
3 Chapters of Scripting Tutotials -http://www.armaholic...=20465#comments MORE TO FOLLOW
TvTCache Hunt - [FOCK]ers Cache Hunt TvT-x [ALPHA]
Fock Recruit/Group Management - http://www.armaholic...ge.php?id=19041

Currently NOT ACTIVE- Awaiting completion of MSc Computer Science - will return soon....

#7 sxp2high

sxp2high

    Master Sergeant

  • Members
  • 779 posts

Posted 07 April 2012 - 08:51 AM

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];";

Posted Image

#8 Mikie boy

Mikie boy

    Master Sergeant

  • Members
  • 660 posts

Posted 07 April 2012 - 01:07 PM

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.
[FOCK] Mikie J -
Giving bad advice since 2009 :)

Looking for New Players/scripters at Fockersteam
http://fockers.moonfruit.com/
Email: fockersteam@hotmail.co.uk

A3
3 Chapters of Scripting Tutotials -http://www.armaholic...=20465#comments MORE TO FOLLOW
TvTCache Hunt - [FOCK]ers Cache Hunt TvT-x [ALPHA]
Fock Recruit/Group Management - http://www.armaholic...ge.php?id=19041

Currently NOT ACTIVE- Awaiting completion of MSc Computer Science - will return soon....

#9 PELHAM

PELHAM

    I shall not insult moderators

  • Banned
  • 1576 posts

Posted 10 April 2012 - 12:36 AM

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;


#10 cuel

cuel

    Sergeant Major

  • Members
  • 1554 posts

Posted 10 April 2012 - 07:08 PM

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.

#11 Mikie boy

Mikie boy

    Master Sergeant

  • Members
  • 660 posts

Posted 10 April 2012 - 08:21 PM

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?
[FOCK] Mikie J -
Giving bad advice since 2009 :)

Looking for New Players/scripters at Fockersteam
http://fockers.moonfruit.com/
Email: fockersteam@hotmail.co.uk

A3
3 Chapters of Scripting Tutotials -http://www.armaholic...=20465#comments MORE TO FOLLOW
TvTCache Hunt - [FOCK]ers Cache Hunt TvT-x [ALPHA]
Fock Recruit/Group Management - http://www.armaholic...ge.php?id=19041

Currently NOT ACTIVE- Awaiting completion of MSc Computer Science - will return soon....

#12 twirly

twirly

    Master Gunnery Sergeant

  • Members
  • 1302 posts

Posted 10 April 2012 - 10:30 PM

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

"Learn by doing!" - Quoted from a post by Imutep

OUTERRA - OUTERRA - OUTERRA - OUTERRA - BLOWMIND!


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users