Jump to content
Sign in to follow this  
[aps]gnat

Object custom name

Recommended Posts

In the editor with the NAME: field, you can custom name an empty vehicle etc

How do I capture that string ?

Dropping an empty jeep on the map, naming it "REDFRED" and sticking this in the INIT field;

[this] exec "nameit.sqs"

>nameit.sqs<

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_AJeep = _this select 0

titletext[format ["Name: %1", _AJeep], "Plain down"]

only gives jibberish like "1a3a4234# NOID jeep"

Any ideas ?

Share this post


Link to post
Share on other sites

There is no command for this afaik.

You can use this function:

init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nameIt={call loadFile "name.sqf"}

nameit.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_it","_nms","_b","_t"];

_nms=["REDFRED","BLUEFRED","BLACKFRED","WHITEFRED"];

_it=_this select 0;_i=count _nms;_b=true;

while {_b and _i>0} do {_i=_i-1;_t=_nms select _i;

call format [{if (%1==_it) then {_b=false}},_t]};

if (_b) then {_t=""};

_t

You must put quoted names to _mns array. For example you name your jeep newjeep in the editor so you must put "NewJeep" into _nms.

If the object is not in _nms then returned name is empty string "" .

Usage:

for example script name.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_AJeep=_this select 0

_name=[_AJeep] call nameIt

?_name!="": titletext[format ["Name: %1", _name], "Plain down"]

exit

Share this post


Link to post
Share on other sites

Wow ! .... I'm surprised this is not available inside the OFP:R engine ! sad_o.gif

Thanks Bart.Jan, nice script but I'm afraid it wont work in my situation ..... sad_o.gif

I want to take whatever a user names an addon and add the text "FS" to the end and thus NAME another section of an addon.

i.e. The Nimitz, trying to generate a public name for the front section of the ship (so we can use the Blast Plates). Because more than one Nimitz can be dropped onto a map, I cant hard code the NAME(s).

...... back to the drawing board.

Share this post


Link to post
Share on other sites

You try with the name command?

Share this post


Link to post
Share on other sites
Quote[/b] ]You try with the name command?

That will return a value such as "Bobby Bruning".

Share this post


Link to post
Share on other sites

This is what says the official command reference

Quote[/b] ]

name object

Operand types:

object: Object

Type of returned value:

String

Description:

Name of variable assigned to object in mission editor. In used on vehicle, name of first crew member (in order commander, driver, gunner).

Example:

name vehicle player

Share this post


Link to post
Share on other sites
Quote[/b] ]This is what says the official command reference

Try it. Using it on an object will return an error, using it on a vehicle will return the full name of the dominant crew member (Like "Mike Hirasaki" or "Bobby Bruning").

Share this post


Link to post
Share on other sites

Ok, I have just tried it. It is as you say. It seems that the person that wrote it, didn't know how to express how the command works.

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  

×