Jump to content
Sign in to follow this  
H3NRY

player name as part of a trigger name on the fly

Recommended Posts

i found out how to create a trigger and a marker on the fly but i was wondering if it was possible to get the name of a player and use that as the name of a trigger or marker ( marker1_$playername$ type of thing)

what i am trying to do is attach a unique marker to a vehicle when someone uses an addaction on it, the vehicles are randomly spawned so i cant just use one name per vehicle and i would also like to be able to find out who "spawned" the marker.

as my understanding is limited right now i can only guess its something to do with _caller of the addaction and somehow get the players name from that, but also how would i put that name in the marker/trigger?

_marker = createMarker ["Marker1"."_caller", position player ] ??

Share this post


Link to post
Share on other sites

_mrk = createMarker [format["mrk_%1",player],getPosATL player];

Or are you talking about the marker text?

Share this post


Link to post
Share on other sites

no, the name.

%1 will be the player calling the script? (testing now)

Share this post


Link to post
Share on other sites

You can use name to get the unit/player name.

_marker = createMarker ["Marker1", position player];
_marker setMarkerText name player;

You seem used to something like PHP, but in sqf you can connect Strings only with +.

_string = "Hello" + " " + "World";

Get started here:

http://community.bistudio.com/wiki/Category:Scripting_Topics

Also, addAction does return the caller of the action, but as _this select 1.

_caller = _this select 1;
_name = name _caller;

Edited by neokika

Share this post


Link to post
Share on other sites

nice catch neokika, that was php ( coding a lot lately and getting languages mixed!)

anyways, seemed exactly what i was lookign for and i will let you know if it works out for me

Share this post


Link to post
Share on other sites
no, the name.

%1 will be the player calling the script? (testing now)

Then you're talking about the marker text, not the name (marker reference). :)

%1 is a format parameter, it will convert whatever comes after the comma.

_mess1 = "Hello";
_str = format ["%1, %2.",_mess1,name player];
hint _str;

Would hint "Hello, <name of player>".

Edited by cuel

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  

×