Home   Help Search Login Register  

Author Topic: name _unit .. but the actual Name: from the editor..  (Read 1966 times)

0 Members and 1 Guest are viewing this topic.

Acecool

  • Guest
How do I get the actual name from a player?

not "name _unit" which would return Acecool, but the Name what you give in the editor?

Thanks in advance :-)

StonedSoldier

  • Guest
Re:name _unit .. but the actual Name: from the editor..
« Reply #1 on: 28 Feb 2005, 11:22:56 »
ok, not quite sure what your asking but here goes,

either try

hint format ["%1",_unit]

or

hint format ["%1",typeof _unit]

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:name _unit .. but the actual Name: from the editor..
« Reply #2 on: 28 Feb 2005, 12:20:11 »
If you give the name in description.ext you can then use the name command to extract it.

Acecool

  • Guest
Re:name _unit .. but the actual Name: from the editor..
« Reply #3 on: 28 Feb 2005, 13:15:57 »
Hi, thanks for the quick responses :-)

_unit gives a full list then :Acecool..
typeof gives the type, like Solder...  etc..

Say I name a unit p1, etc in the editor, how would I get that to show up?

Thanks

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:name _unit .. but the actual Name: from the editor..
« Reply #4 on: 28 Feb 2005, 13:58:53 »
If Stonedsoldier's suggestions don't work then I am not sure you can

Acecool

  • Guest
Re:name _unit .. but the actual Name: from the editor..
« Reply #5 on: 28 Feb 2005, 19:15:08 »
Hmm, there has got to be a way..

Basically, create a unit with the editor, then in the Name: _____________________ field type in a name..

That name is the one I need to get, heh..

StonedSoldier

  • Guest
Re:name _unit .. but the actual Name: from the editor..
« Reply #6 on: 28 Feb 2005, 19:41:26 »
give us some idea why you need this information and what your trying to do and im sure we can find a work around

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:name _unit .. but the actual Name: from the editor..
« Reply #7 on: 28 Feb 2005, 19:47:55 »
The game engine knows the units as, say, East Alpha Black:1 - that's the sort of thing you get when you do a Format ["%1",mynamedunit].

When you name a unit in the editor you are defining a variable whose value is the unit's 'identifier' i.e.

mynamedunit = East Alpha Black:1

In wanting the editor name of the unit, you are effectively asking the question 'which variable holds this value?'  You can't do that withoout knowing all the variables and checking through them.

The other way I would read your first post is 'how do you set the player's real name against the player unit's identity?'  All I can offer on this one is that in Sui's missions, he has pulled out the player' name as a string because it appears as text; there must be a reserved variable 'playername' or somesuch. /knowledge

Acecool

  • Guest
Re:name _unit .. but the actual Name: from the editor..
« Reply #8 on: 28 Feb 2005, 20:13:47 »
Well, I do this:

_Players = ["p1","p2","p3","p4","p5", "c1","c2","c3","c4","c5","c6","c7","c8","c9","c10"]
{call format [{%1 addAction ["Statistics","Scripts/Stats.sqs"]}, _x]} forEach _Players

for a few others aswell (actions etc)..

When the user dies, it doesnt select the correct user for the messages etc..

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:name _unit .. but the actual Name: from the editor..
« Reply #9 on: 01 Mar 2005, 01:03:20 »
Have you tried it without using strings, like ' "p1" ' but instead just objects, ' p1 '?

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:name _unit .. but the actual Name: from the editor..
« Reply #10 on: 01 Mar 2005, 03:28:54 »
I think you are making this WAY more complicated than it needs to be. Listen to what ACF is telling you: putting "p1" in a unit's name field is EXACTLY the same as putting this in his init field:
  p1 = this

So basically you are asking a totally illogical question. It is like you are saying:
  a = 5
  what variable is 5?
Obviously "5" could be stored in any number of variables, just like a unit can be stored in any number of variables. But there isn't really any reason why you would HAVE to know the answer to this question, because you can just do it an easier way:

_players = [p1, p2, p3, ... ]
{_x addaction ["blah","blah.sqs"]} foreach _players

edit

Quote
All I can offer on this one is that in Sui's missions, he has pulled out the player' name as a string because it appears as text; there must be a reserved variable 'playername' or somesuch. /knowledge


name unit
« Last Edit: 01 Mar 2005, 03:30:24 by General Barron »
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:name _unit .. but the actual Name: from the editor..
« Reply #11 on: 01 Mar 2005, 05:41:50 »
Quote
All I can offer on this one is that in Sui's missions, he has pulled out the player' name as a string because it appears as text; there must be a reserved variable 'playername' or somesuch. /knowledge


name unit

Correctamundo... I simply used:

name player

(or for the intro: name c1 as it didn't like player...)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:name _unit .. but the actual Name: from the editor..
« Reply #12 on: 01 Mar 2005, 08:15:08 »
Which takes us back to #2 above.

Acecool

  • Guest
Re:name _unit .. but the actual Name: from the editor..
« Reply #13 on: 01 Mar 2005, 14:14:22 »
On the player init, I just put this addaction for now..

Basically, I need this for respawn...

Code: [Select]
_unit = _this select 0

_msg = Format["%1 you died and will respawn in 1 Minute!", name _unit]
_unit groupchat _msg

~61
_unit addAction ["Statistics","Scripts/Stats.sqs"]

~1
deletevehicle _unit

exit

it deletes the dead body, but doesnt add action to the unit.. which is why I want it to add it to the actual player: p1 (instead of Acecool) or would that work?

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:name _unit .. but the actual Name: from the editor..
« Reply #14 on: 01 Mar 2005, 20:11:31 »
Why are you deleting _unit right after you add an action to it? Is this script run from a killed eventhandler?

I assume that what is happening is that the action is being added to the player's corpse, which is then deleted. I don't know much about respawning, so I don't know if I can help you on this one. The question I would need to know is:

If you name the player "p1", and the player dies and respawns, does "p1" then point to his corpse, or the new, respawned player?

I would think that how you approach this would have to depend on the answer to this question.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!