OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: XPS on 11 Jul 2006, 17:10:13
-
Hi,
I have given a unit the name Player1.
When I use this code:
Hint Format["Hi %1", Name Player]
The result is "Hi XPS"
The result I want is "Hi Player1"
How can I do this?
-
player is a command in the command reference and refers in MP to the player on that client.
It has nothing to do with the name given in the name field of the unit dialog.
Planck
-
I have 3 units, named Player1, Player2 and Player3
When one of those units enters my trigger, I want his name (Player1, Player2 or Player3) as a result.
With my solution (Hint Format["Hi %1", Name Player])
The result is: Hi XPS.
So that is not working for me. What can I do to get Player1, Player2 or Player3 as a result?
-
name player
will, as you have probably guessed, return the name of the player, i.e. whoever is playing the mission.
if you wish to the return the name of the unit called player1, use
name player1
units which enter a trigger are held in the trigger's activating array. if the trigger has a name (in the 'name' box), the array can be accessed by using
_unitarray = list trigger_name
if you wish to assign the array to a global variable from the trigger's init line, use
unitarray = thislist
the global variable unitarray is now a real-time array of the units which activate the trigger.
like any array, those units can be accessed using the select command. so for example
unitarray select 0
points to the first unit that walked into the trigger. to find out its name, use
hint format ["Hi %1", name (unitarray select 0)]
-
I am not sure that this can be done simply. If you were to try this:
Hint Format["Hi %1", Player]you would just get "Hi East:Bravo Black 1", or something like that. There may be a slick way to do this, but I do not know it. Here is a clumsy way:
You will have to create an array of names and a matching array of units.
In your init.sqs
nameArray = ["Player1","Player2","Player3",....]
unitArray = [Player1,Player2,Player3,....]
Now when your trigger is activated you will have to search the unitArray to see what element of nameArray to use.
In your trigger On Activation:
{if ((thisList select 0) == (unitArray select _i)) then {playerName = nameArray select _i} ; _i = _i + 1} forEach nameArray; hint format ["%1 activated the trigger",playerName]
Note that if the trigger is activated by more than one player, this only gives the name of one of the players.
-
I get this error:
scalar bool array string 0xfxffffef activated the trigger.
So it still won't get the name I gave the unit.