Jump to content
Knifedge

Name command not returning player name?

Recommended Posts

Can someone please help me on the below:

The script is working correctly bar one thing. When the marker is added to the map I want it to have in brackets (Marked by <playerName>) however currently it just adds "CAS Target (Marked by any)"

 

Can someone explain why the name command is not returning the name of the player?

 

I have in the Init box of the unit in the editor:

nul = [this] execVM "scripts\add_markcastarget_action.sqf";

This is add_markcastarget_action.sqf

_currentPlayer = _this select 0;
_playerName = name _currentPlayer;

sleep 10;

fnc_addActionMP =
{
	private["_object", "_screenMsg", "_scriptToCall"];
	_object = _this select 0;
	_screenMsg = _this select 1;
	_scriptToCall = _this select 2;
	
	if(isNull _object) exitWith {};

	_object addaction [_screenMsg,_scriptToCall];
};

[_currentPlayer, "<t color='#f20000'>" + "Mark CAS Target" + "</t>", 
{ 
	titleText ["Click to mark CAS Target location.", "PLAIN"];
	openMap [true, false];
	_attachedTo = (_this select 0);
	["mk_cas", "onMapSingleClick", {
		titleText ["", "PLAIN"];
		_markerName = "CASMARKER_" + (str _pos);
		_marker = createMarker [_markerName, _pos];
		_marker setMarkerType "hd_destroy";
		_marker setMarkerColor "ColorRed";
		_marker setMarkerText format["CAS Target (Marked by %1)", _playerName];
		["mk_cas", "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
		true;
	}, [_attachedTo]] call BIS_fnc_addStackedEventHandler
}
] remoteExec ["fnc_addActionMP"];

 

  • Like 1

Share this post


Link to post
Share on other sites

_playerName is not defined inside the onMapSingleClick command. Replace it with "name player".

 

Cheers

  • Like 2

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

×