Jump to content
Sign in to follow this  
nedal

Getname??

Recommended Posts

hi have a random script wich shoses onestart point (startpoints are gamelogic markers)

now i want a message wich says wich marker is shoosen.

i want the name of the marker (name filed) in the message.

have no idiea how to make it

is there something like getname

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

StartingLocation = startingLocations Select Random _totalLocations;

PublicVariable "StartingLocation"

#Placepos

_destination = GetPos StartingLocation

_ort = name StartingLocation

S1 SetPos _destination

S2 SetPos _destination

#messages

player sidechat(format["%1",_ort])

but instead if getting in the message the text in the name field of the marker, il get "Milos Bratrunek" and that just does not exists in any of my scripts lol i am confused

Share this post


Link to post
Share on other sites

From the comref:

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

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

i have a few start position markers (gamelogic flags)

here is one of them

in the name field: Morton

in the init field : [this] exec "initstartinglocation.sqs"

then i have the initstartinglocation.sqs script

this script counts the total numbers of starting markers (startingLocations)

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

? !(Local LocalServerObject):Exit

_location = _this Select 0

;The first town to be set should call this so the arrays are declared.

? !(startedLocationsInit):goto "InitStartingLocations"

#AddLocation

startingLocations = startingLocations + [_location]

Exit

#InitStartingLocations

startedLocationsInit = true

startingLocations = [_location]

then i have a second script PlaceSides.sqs

in wich is first randomly selectet one of the starting location

and then moved the soldiers S1+S2 to the location

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

? !(Local LocalServerObject):Exit

_totalLocations = Count startingLocations

StartingLocation = startingLocations Select Random _totalLocations;PublicVariable "StartingLocation"

#soldier move

_destination = GetPos StartingLocation

S1 SetPos _destination

S2 SetPos _destination

#town message

_ort = name _location

player sidechat(format["start in","_ort"])

everything works except the town message

the message should bring up morton or wich ever name from the choosen marker

i am confused

Share this post


Link to post
Share on other sites

sad_o.gif no one knows the answer?

Is there a posibility to refere or better get the name of a gamelogic in a script?

the position of the gamelogic i can get with the getpos/setpos command, but is there a way to get the name (name Field) of a gamelogic?

Share this post


Link to post
Share on other sites

If you have a Logic that is called "Morton" (in the name field), then you have to check:

? _logic == Morton : hint "Logic is Morton";

You have to manually check every Object and Logic, there is no other way.

Share this post


Link to post
Share on other sites

i have tried this:

in PlaceSides.sqs

? _location == SaintPierre : ortmsg =  SaintPierre; PublicVariable "ortmsg";

(i tried also _Startinglocation instead of _location)

trigger:

Funkcall Beta: (0-0-2)

hint format ["start in",ortmsg]

It does not work, the Variable ortmsg stays empty  sad_o.gif

here is my mission file

Share this post


Link to post
Share on other sites

There is one way. You can give identity to each gamelogic unit.

Then you do not need to name these but you must set their identities.

Init line of GL:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setIdentity "morton"; [this] exec "initstartinglocation.sqs"

the other one:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setIdentity "pierre"; [this] exec "initstartinglocation.sqs"

and declaration in description.ext:

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

{

class morton

{name = "Morton";

face = "";glasses = "";

speaker = ""; pitch = 0;};

class pierre

{name = "Saint Pierre";

face = "";glasses = "";

speaker = ""; pitch = 0;};

};tested

And you can use your original script.

---

? _location == SaintPierre : ortmsg =  SaintPierre; PublicVariable "ortmsg";

hint format ["start in",ortmsg]

It should be

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? _location == SaintPierre : ortmsg =  "Saint Pierre"; PublicVariable "ortmsg";

hint format ["start in %1",ortmsg]

Share this post


Link to post
Share on other sites

you mean i can leave all like it is and just use

hint format ["start in %1",ortmsg] ??

but then i  get scalar bol......error

what does %1 exactly mean?

or do you mean i must use

this setIdentity "pierre"; [this] exec "initstartinglocation.sqs"

and mod. description.ext  ?

i made all you said, including the description.ext modifactions

but i stil get scalar bol....aray string error

here is the new mission file

Share this post


Link to post
Share on other sites
i made all you said, including the description.ext modifactions

but i stil get scalar bol....aray string  error

here is the new mission file

There are only two mistakes:

- you have no condition in radio Bravo trigger (it must be this)

- the important one in placesides.sqs inside message section:

you have

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? _location == ...

and it must be

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? StartingLocation == ...

and then it works.

You have two choices now:

1) delete

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setIdentity "..."

from gamelogic init lines and delete CfgIdentities class from description.ext.

Then you can even change message section of placesides.sqs into:

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

? StartingLocation == SaintPierre : ortmsg =  "SaintPierre"

...

? StartingLocation == SaintPhillippe : ortmsg =  "SaintPhillippe"

PublicVariable "ortmsg"

or

2) let description.ext and gamelogic init lines be as they are now and change message section of placesides.sqs to:

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

ortmsg=name StartingLocation

publicVariable "ortmsg"

And than you can unname gamelogics in editor.

---

Quote[/b] ]hint format ["start in %1",ortmsg]

what does %1 exactly mean?

It's substitution for content of ortmsg

exaple:

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

_b="I"

hint format["%2 see %1.",_a,_b]and the result is "I see you."

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint format["%1 see %2.",_b,_a]returns the same result.

Share this post


Link to post
Share on other sites

Thank you 2450982457 times Bart.Jan you Did solve my problem perfect m8

biggrin_o.gifbiggrin_o.gifbiggrin_o.gif

now i just have to place: hint format ["start in %1",ortmsg]

in to the intro instead of the Funk B Trigger and the random System is basicly finished smile_o.gif)))))))

biggrin_o.gifbiggrin_o.gif

Share this post


Link to post
Share on other sites

sad_o.gifsad_o.gifsad_o.gif

i was to fast with being happy

i testet it now on server, and there it does not work sad_o.gif

i tried 2 versions

? StartingLocation == SaintPhillippe : ortmsg = "SaintPhillippe"

PublicVariable "ortmsg"

in PlaceSides.sqs and place sides is just running on server

Does not work

and i tried it also in Placespawn.sqs wich is running local

Does not work to

i am confused

it does work with both versions if i start the game from the editor

but not on server

new mission File

Share this post


Link to post
Share on other sites

anyone got an idea why it does not work on server if it does work when the map is startet from the editor?

hint format ["start in %1",ortmsg]

Share this post


Link to post
Share on other sites

the script with the message does not exist in cti

and i am not making a cti map

Share this post


Link to post
Share on other sites
anyone got an idea why it does not work on server if it does work when the map is startet from the editor?

hint format ["start in %1",ortmsg]

publicVariable command can transfer only these variable types: Number, Boolean, Object, Group.

This topic can help you too: Server and client, Understanding their relationship

So

1) You must use my way with identities

2) change placesides.sqs:

at the begining change

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? !(Local LocalServerObject):exit

~1to<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">~1

ortmsg=objNull

? !(Local LocalServerObject):goto "wait"

and message section to:

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

ortmsg=StartingLocation

publicVariable "ortmsg"

#wait

@!isNull ortmsg

cutText [format["Starting location: %1",name ortmsg],"plain down"]tested

Edit: Well there is another way without identities:

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

ortmsg=-1

? !(Local LocalServerObject):goto "wait"

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

? StartingLocation == SaintPierre : ortmsg = 0

? StartingLocation == B...           : ortmsg = 1

? ...                           C...           : ortmsg = 2

...

? StartingLocation == SaintPhillippe : ortmsg = X

PublicVariable "ortmsg"

#wait

@ortmsg>-1

ortmsg=["Saint Pierre","B...","C...", ... ,"Saint Phillippe"] select ortmsg

cutText [format["Starting location: %1",ortmsg],"plain down"]tested

Share this post


Link to post
Share on other sites

it seems the thing i want is impossible lol at least for a noob like me

@isNull>-1 makes me an error, unvalid number null[#]

rock.gif

new mission file here

i am confused

Share this post


Link to post
Share on other sites
@isNull>-1  makes me an error, unvalid number null[#]

Oops. It must be

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@ortmsg>-1

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

@ortmsg>-1

ortmsg=["Saint Pierre","Morton","Provins","Lamentin","Monignac","Gravette","Meaux","Saint Phillippe"] select ortmsg

cutText [format["Starting location: %1",ortmsg],"plain down"]

~2

safezonemsg1 = true;PublicVariable "safezonemsg1"tested

Share this post


Link to post
Share on other sites

sad_o.gif(     i m stil getting an error (div / 0)

and if i remove the the ortmsg=-1 and the @ortmsg>-1

it works in editor, but i get an scalar bol error in dedicatet server

new mission file

Share this post


Link to post
Share on other sites
sad_o.gif(     i m stil getting an error (div / 0)

and if i remove the the ortmsg=-1   and the @ortmsg>-1

it works in editor, but i get an scalar bol error in dedicatet server

new mission file

You have:

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

ortmsg=["SaintPierre",...]

@ortmsg>-1

...It must be:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#wait

@ortmsg>-1

ortmsg=["Saint Pierre",...]

...

Share this post


Link to post
Share on other sites

last night i have tried both,

#wait

ortmsg=["SaintPierre",...]

@ortmsg>-1

and

#wait

@ortmsg>-1

ortmsg=["Saint Pierre",...]

but on both versions i got error (div / 0)

then i removed @ortsmsg like i said, and got error just on server

perhaps i was just to tired, worked 12,5 hours yesterday, and today i have to work again 12,5 hours (got up at 05:40 and wil be back home at 19:40 uhhhrrff horror lol)

i hate weekend shift wink_o.gif

Share this post


Link to post
Share on other sites

biggrin_o.gif  biggrin_o.gif  biggrin_o.gif  biggrin_o.gif

Problem solved !!!!

Youre just great Mister Script Good Bart.Jan!!!!

Thank you sooooo much    smile_o.gif

I will make a spezial remark for You in the script !!!!!

And if i ever play with you a CTI il give you all my money tounge_o.gif

(this Map template will be used for czl 1v1 DM maps)  unclesam.gif

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  

×