Jump to content
Sign in to follow this  
Taurus

Checking locality?

Recommended Posts

I come to think of why this is needed.

Tried to search this matter on this forum(arma editing) but didn't find anything of interest.

As far as I know the init-file is run on all machines, right?

So files and variables defined there will be global, fine.

Now, have 4 players.

and one car called myCar.

In a trigger we have(Triggers are on each machine.)

Cond:getDammage myCar == 1

OnAct: nil = [] execVM "spawnSomething.sqf";

spawnSomething.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">myCar = "HMMWV" createVehicle (getPos player);

Will create how many Hmmwvs?

One, because "createVehicle" is smart.

Where?

Now this would be interesting, but I think it will be at the player who took the first spot in the lobby.

So it would be better to spawn it by a marker or the location where the car was first at, or why not where it was currently at when it got blown away.

A gameLogic would not be as good as they are local to the server.

The same car, is moved in another script

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(driver myCar) doMove (some position);

As there is one myCar, and all knows where "some position" is at, the car will move to that position.

Now when myCar is near(or 10 meter from it, LoL because of "precision")

We could wait until the car stops, but that wouldn't be any fun now would it?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">waitUntil{(myCar distance (some position)) < 12};

ammoCreate = "Reammobox" createVehicle (some position);

nil = ammoCreate execVM "fillWithStuff.sqf";

As createVehicle spawns one object and as we all know addMagazineCargo is local, now all players will have stuff in that very ammo crate.

now say that myCar has some units in it.

myCar is local to the server even if it does exist at every player because an AI not belonging to any player, drives it.

So, in order to disembark units from it, that "unload" script needs to be run on all clients.

All clients can count the crew number in the car.

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

unassignVehicle _x;

}forEach crew myCar;

Will disembark all units(hopefully)

If the above script isn't used we need the driver(AI) to leave the car so the player can get in.

Worth to mention here is that if player1 enters as a driver and player2 tries to order his units to disembark, it will fail because the driver takes "command" over the units in that vehicle...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unassignVehicle (driver myCar);

Now, we know that the AI is local to the server, but we don't care if we are the players because the AI driver isn't "ours", and the script is at the server so the little driver will jump out anyways.

The only things I see which are needed to be run on the server are calculations.

Not that clients will calculate 1 + 1 wrongly, but random numbers will obviously differ on all clients, because its random biggrin_o.gif

So, what am I missing here?

Do we check for locality because it would be better performance wise or why do we bother?

Share this post


Link to post
Share on other sites

Are you saying that when running createVehicle command on ALL machines, it will create only ONE vehicle?

...i find it very hard to believe smile_o.gif. Try and test it in MP, i am sure you will find it will create as many vehicles as there are players(+dedicated server).

To answer your question:

Basicaly, we have to check locality, because some commands must be run where the given unit/vehicle is local.

And it is also better (mostly required) to run some scripts only on the clients, and some only on the server - for that you have to check locality too.

I am little surprised by your question, i have bumped into need of locality checks in every MP mission i have ever worked on.

Share this post


Link to post
Share on other sites
I am little surprised by your question, i have bumped into need of locality checks in every MP mission i have ever worked on.

True, but I'm yet to find out what needs to be "checked" or not.

Its not that its very obvious, even if we read the wiki over and over.

First we have the locality which we need to check for.

Then secondly we have the locality issues with some BIS commands, like addMagazine/WeaponCargo has.

I know that createVehicle created 1 vehicle per script(enitity*) who ran it in OFP.

But in Arma I have the feeling its different, because we now the "createVehicleLocal"-command.

Whatever it does, but it "should" create the vehicle local only to the one who ran the script.

[edit_inner]

Example:

I have a trigger just like the one I mentioned which checks damage of my car.

in the onAct I have the very same script I posted too, and only one vehicle pops up.

1 remote client and me playing local server.

[/edit_inner]

You shouldn't be surprised, I'm a total nublet when it comes to MP local, dedicated vs commands.

[edit1]

To answer your question:

Basicaly, we have to check locality, because some commands must be run where the given unit/vehicle is local.

And it is also better (mostly required) to run some scripts only on the clients, and some only on the server - for that you have to check locality too.

Yes, but why?

Better as in the client or server might get out of sync or bogged down?

[/edit1]

*entity: Player or server.

Share this post


Link to post
Share on other sites

Didnt read most of what was said, but createvehicle would be run on all clients if the createvehicle script is chucked in a trigger like that. Since that trigger is run on all clients and is therefore global, i suppose. Making sure the script is run only on one machine, preferably a server is the way to go about it as im sure i dont need to tell anyone. Since the createvehicle command itself is global.

If you did createvehiclelocal on all machines everyone would get one incarnation of the vehicle, but no one would be able to interact or even see anyone elses. As an example this is how evolution keeps new weapons in the ammo crates local. It spawns a new crate locally with the new fancy weapons on the exact position of the pre-existing crate when a new rank is achieved.

In my experience locality is a right little bitch with most things, but it can also be a really useful tool.

Share this post


Link to post
Share on other sites

It would be nice if there were a definitive guide as to what is handled locally and what is not. It seems tedious test cycles by individual users and sharing the info here in an unofficial capacity has ben the default method. It makes it hard to get scripts working MP if you dont know how locality works with the game elements involved in any given mission. Searching is good and well but its like we all have to build our own seperate book of notes on what is what.

Share this post


Link to post
Share on other sites
But in Arma I have the feeling its different, because we now the "createVehicleLocal"-command.

Whatever it does, but it "should" create the vehicle local only to the one who ran the script.

Well, i think you misunderstood the exact difference between those two commands, or i misunderstood you. Here is what i think of the two aforementioned commands (just my guess):

createVehicle - No matter where you use this command, the effect is broadcasted to every client, which means every client will see this vehicle, every client will be able to use it, etc.

BUT if you run this command on 4 machines, then of course 4 vehicles will be created and all of them will visible and available on all machines. That's why everybody prefers to run this command on the server, its also the simplest way to make sure the command is run only on ONE machine, because there is allways only ONE server, so you check only for (isServer true) and you know your command will be executed only on one machine so only one vehicle will be created.

And here is the important thing: no matter where you run this command (server or any ofthe clients) the created vehicle will be local to the server! (at least that is what i think - that is the difference between this and createVehicleLocal - please correct me if i am wrong)

createVehicleLocal - again, no matter where you will use this command, the effect is broadcasted to all clients, so everybody will see this vehicle and everybody will be able to use it.

But, this vehicle will be created local to where the command was run(again, this is what i think - so correct me please if i am mistaken)

The reason behind what i think about these two commands is that i can't see the logic behind creating vehicle which will exist and be visible ONLY on one computer - what would happen if the player would get into that vehicle? what would others see then? It seems as a nonsense, so i think the difference is, that createVehicle creates a vehicle initially local to the server, whicle createVehicleLocal will create a vehicle initially local to the machine where the command was run.

...i must admit, that i haven't even tried to use the createVehicleLocal command,

and everytime i use the createVehicle, i use it on the server.

So i never needed to worry about what those commands EXACTLY do, which means i can be horribly wrong.

And since we started this discussion, i would appreciate very much if someone could made it clear for us.

Share this post


Link to post
Share on other sites
To answer your question:

Basicaly, we have to check locality, because some commands must be run where the given unit/vehicle is local.

And it is also better (mostly required) to run some scripts only on the clients, and some only on the server - for that you have to check locality too.

Yes, but why?

Better as in the client or server might get out of sync or bogged down?

Maybe to lower down (or at least not to add more) the network traffic under some circumstances?

For example - the <span style='color:blue'>[_unit] join _leader</span> command - you need to run this on the machine where <span style='color:blue'>_unit</span> is local.

What would happen if it was global so you could run it anywhere?

Lets say that <span style='color:blue'>_unit</span> is local to the <span style='color:blue'>client1</span>, while <span style='color:red'>_leader</span> is player on <span style='color:red'>client2</span>.

What would happen if you use this command on the <span style='color:brown'>client3</span>?

Well, then it would add more network traffic, because now you would need to inform at least three computers about the change,

BUT as the command is local, you need to run it on <span style='color:blue'>client1</span> and the change is sent only to the server (and maybe even not) and to the <span style='color:red'>client2</span>.

Now multiple this traffic by all those local commands and you will get pretty considerable amount of additional network traffic - which could, under heavy load, lead to more desync and lag.

It's up to the mission designer, whether he makes wrong usage of any of these commands, and create a desync or any other problem, it's his fault only, the commands are innocent smile_o.gif

Share this post


Link to post
Share on other sites

Sure, there you have one example on when it should be run local.

But over to the spawn vehicle thingy.

I was to try this but I fail to think out a way of doing it, so here goes my thoughts.

Correct me if I'm thinking wrongly.

Say that you have a client script running where you want to move some units into this very vehicle.

We call the vehicle

Car1 for simplicity.

You have Car1 placed in the editor and name it using either the name field or

Car1 = this;

The client-side script

_newUnit moveInCargo Car1;

Now you have a server-side script running checking Car1s hp and respawn it if necessary.

This because we don't want to have a trigger checking its condition every 0.2 second.

Car1 gets blown up in some way.

The server runs this from within the checkHP-script.

_vehicle = "somevehicle" createVehicle somePosition;

This creates a vehicle which all(?) can see and use.

But, the second time the client will want to run.

_newUnit moveInCargo Car1;

Car1 will probably be objNull, as it was created on the server without assigning it to the variable Car1.

So, we need either to publicVariable "Car1" in the server-respawn script.

= network traffic.

This results in less dynamic scripts as we need to switch/case which car was destroyed.

Or changing the script to a function and returning a vehicle which we set to Car1, this should work ok because Car1 is a global variable to begin with right?

checkHP-script

Car1 = [] call compile preProcessFile "respawn.sqf";

respawn.sqf

_vehicle = "somevehicle" createVehicle somePosition;

_vehicle

Maybe the function needs to be defined globally in the init.sqf

globalRespawn = compile preProcessFile "respawn.sqf";

Then the checkHP-script will look like this.

Car1 = [] call globalRespawn;

Which, stated "would" spawn one vehicle per client who run it because the function is defined globally on each entity.

Either way it produces network-traffic.

I am confused to say the least!!

crazy_o.gif

Share this post


Link to post
Share on other sites
...
You have the setVehicleVarName and vehicleVarName commands for that.

could you be more specific please,

where should I use that?

Sorry, i missed the part where you are publishing the Car1 again, and i am getting little tired (i haven't slept for more than 24 hours) and i think i am starting to loosing it - i lost your point.

I don't know exactly what to tell you, to satisfy your curiosity, but there are situations when you need some commands/effects to be only local, same as there are situations when you need them global.

Maybe this doesn't apply to 100% of those commands, maybe some could be global instead of local and vice versa, but i think that generally speaking the commands are ok as they are.

For example, i would like the say command to have global effects - it would be nice if i could run <span style='color:blue'>someUnit say "some_sound"</span> only on one machine without worrying about how to make it so the unit will say the sound on every machine.

So i think i understand what you are saying, but as i wrote, most of the commands are ok as they are.

If i take your example with the createVehicle, then what if i wanted to create vehicle named "Car1" but i want this vehicle to be something different on every machine?

If the <span style='color:blue'>Car1 = "skoda" createVehicle [...]</span> would automatically published the variable "Car1" to all clients, i would be screwed.

So it is really good thing that we have to use publicVariable and manually publish the "Car1" variable if we want to.

Here is an example:

You are making a "race" mission for 4 players, and you need to create new vehicle when the vehicle of any player gets destroyed.

So you have some script which is being run on every player machine and the script looks like this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {true} do {

if (damage playerCar >= 0.9) then {

waitUntil {player In playerCar};

deleteVehicle playerCar;

playerCar = "skoda" createVehicle [...];

};

};If the createVehicle command would automatically broadcast the variable <span style='color:blue'>playerCar</span> to all machines, then you would have problems and you would have to do things differently, because the <span style='color:blue'>playerCar</span> on all machines would be always referencing only the last created car.

Share this post


Link to post
Share on other sites
createVehicleLocal - again, no matter where you will use this command, the effect is broadcasted to all clients, so everybody will see this vehicle and everybody will be able to use it.

But, this vehicle will be created local to where the command was run(again, this is what i think - so correct me please if i am mistaken)

No, didn't you read the info on the wiki?

Quote[/b] ]Vehicle is not transferred through network in MP games.

It is only created on the machine the command is run on. You link to it on the wiki but it seems you did not properly read what you linked to.

Share this post


Link to post
Share on other sites
It is only created on the machine the command is run on. You link to it on the wiki but it seems you did not properly read what you linked to.

Have you tested it? or are you just thinking it is created only where the command has been run?

I already explained why and what i think about this command, and that i will appreciate if someone would confirm what the command really does - do not get me wrong, but if you haven't used the command, then i can't be satisfied with your "confrimation" - i can read that on wiki too.

Share this post


Link to post
Share on other sites
It is only created on the machine the command is run on. You link to it on the wiki but it seems you did not properly read what you linked to.

Have you tested it? or are you just thinking it is created only where the command has been run?

I already explained why and what i think about this command, and that i will appreciate if someone would confirm what the command really does - do not get me wrong, but if you haven't used the command, then i can't be satisfied with your "confrimation" - i can read that on wiki too.

Well I just assumed that the info on the wiki was correct tounge2.gif

If it is not transferred across the network, how could it possibly show up for other people?

I haven't done any MP scripting yet, maybe someone who has tried it can confirm it.

Otherwise what would be the point in this command? Why would created units be local to a client? It is the servers job to handle them.

Share this post


Link to post
Share on other sites
Otherwise what would be the point in this command? Why would created units be local to a client? It is the servers job to handle them.

Clients take over all items local to them and sends the data to the server and out to other clients.

This command creates it on the local client only. Unless i did something wrong when i did it.

Share this post


Link to post
Share on other sites
Well I just assumed that the info on the wiki was correct tounge2.gif
I know, i assumed that too, but when i am thinking about it, it just somehow doesn't seems right, so i thought that maybe someone wrote thah statement ("Vehicle is not transferred through network in MP games.") only because he was mistified by the name of the command?

For me it seems more logical what i wrote earlier about how this command differs from createVehicle command.

But in the light of all things, i must admit, that i am more inclined to the Wiki description than to my own.

Otherwise what would be the point in this command? Why would created units be local to a client? It is the servers job to handle them.
You are right, it seems pointless. Right now, i don't have idea, but i think i knew about some situation when this could come in handy.
Otherwise what would be the point in this command? Why would created units be local to a client? It is the servers job to handle them.

Clients take over all items local to them and sends the data to the server and out to other clients.

This command creates it on the local client only. Unless i did something wrong when i did it.

Ummm, i don't think i understand correctly - was the vehicle created, visible, and usable only on the machine where you run this command, or was it visible on other machines too and the only difference between this and createVehicle command was that <span style='color:blue'>(local myVehicle)</span> is true on the machine where you used the command?

But, i think we should stop discussing this as it seems to be getting more and more offtopic - the original question was more about locality issues in general, let's not forget that (but if someone can confirm the wiki statement, please do).

Share this post


Link to post
Share on other sites

Ive tried setvehvarname and it seems its primarily used for assigning a new name to a pre-existing vehicle not for giving newly spawned units new names. As it seems from what ive done that other scripts running locally wont pick up on this new name assigned using setvehvarname.

Share this post


Link to post
Share on other sites

I will have to double check but when i tested it last time, the vehicle was only visible on one client. I used it in my training server where i setup missions for people to verify they can use vehicles. Aka, i have a Mi17 without any fuel in it. They go up to the instructor and choose their mission (Or what certification they are trying to get). Once in that vehicle i teleport them to a new local only chopper at some location and put an AI unit that looks just like them into the pilots seat. So to other player it looks as if they are still in there. The other unit they run thru the mission, but in MP that vehicle just never show up. Ill remove the barriers so that i can fly the vehicle over and see what happens. Maybe we will have a floating person in it. Laugh.

Share this post


Link to post
Share on other sites

(loooong post here, hang with me please)

5133p39

Thanks for your input, you really should get some sleep now tho' biggrin_o.gif

Anyways.

Here's some tests I did.

Functions defined are instaces of

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

_pos = getPos _object;

_dir = getDir _object;

_typeOf = typeOf _object;

//Throw the junk away

_object setVelocity [-50, -50, +50];

sleep 5;

_newObject = _typeOf createVehicle _pos;

_newObject setDir _dir;

//RETURN

_newObject

5 cars.

Car1 - Car5

(script which handles this are started by "execVM" could have used spawn too, as I wanted my function to be able to sleep for a while)

Respawning Car1

Car1 = Car1 call serverSpawnVehicleFunction; //This function defined at server and run server local

Respawning Car2

Car2 call serverSpawnVehicleFunction; //This function defined at server and run server local

Respawning Car3

Car3 = Car3 call serverSpawnVehicleFunction; //This function defined at server and run server local

publicVariable "Car3";

(Beats me, but this feels like the spawning of car1, the result however differs, see below)

Respawning Car4

Car4 = Car4 call clientSpawnVehicleFunction; //This function defined at client and run client local

Respawning Car5

Car5 call clientSpawnVehicleFunction; //This function defined at client and run client local

Results(numbers just random):

SP and Local host client

Car1 = 12412135#12134:Humww.plol

Car2 = Car2

Car3 = 12c12135#12134:Humww.plol

Car4 = 12s12135#12134:Humww.plol

Car5 = Car5

Can destroy from Radio vehicles

Car1,Car3,Car4

Dedicated more than 1 client

Car1 = Car1

Car2 = Car2

Car3 = 12c12135#12134:Humww.plol REMOTE

Car4 = 12s12135#12134:Humww.plol

Car5 = Car5

Car4 and Car5 are spawned for each client, i.e. 2 cars for 2 players as you said wink_o.gif Sorry for doubting, it works just like in OFP... as many other commands...

Can destroy from Radio vehicles

Car1,Car3,Car4 + Car4

Conclusion:

I can access/do stuff with

Car1, because the global variable is set to the new car.

Car2, does not, because its not assigned to anything, I'm surprised to see it was not objNull.

Maybe it refers to the destroyed object still, can't destroy something which is already destroyed.

Car3, because the global variable was rebroadcast to client, therefor the "REMOTE" probably.

Car4, Yes, because its local to the client

Car5, No, see event with Car2.

I think I go for the Car1 thingy.

Must try to see if the client can spawn units and "moveInCargo" with the Car1 case.

Too tired right now with all this remaking of my scripts I want to poke out my eyes and eat them.

When I've ate them I will try the setVariable name too and see how it can be used, and if I need it.

And in your case there with the race, will it actually overwrite the playerCar variable if the car is respawned at the client?

I don't think so?

Let the thoughts and comments come into this thread smile_o.gif

[edit]

Ok so hopefully 5133p39 sleeps by now smile_o.gif

I placed some soldiers called a1 - a5 in the editor.

[edit inner]

Car1 wouldn't be boarded by the troops if they were local to the client.

Obviously as I come to think of it...

Didn't try if they were local to the server but they probably would have boarded Car1

[/edit inner]

Back from some experimenting with

setVehicleVarName

tested it in the preview.

Server

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

_Car1 setVehicleVarName "Car1";

And at client

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player sideChat format["Car1: %1", Car1];

a1 moveInCargo Car1;

a1 refused to board Car1

even tho the sideChat said:

Car1: Car1

So I tried

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

Car1 setVehicleVarName "Car1";

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player sideChat format["Car1: %1", Car1];

a1 moveInCargo Car1;

a1 swiftly moved into Car1 as cargo.

sideChat said:

Car1: Car1

So it seems setVehicleVarName

is "just" a Arma way of doing publicVariable "Car1"

Because testing this on a dedicated server, before I tried the whole setVehicleVarName thing, the only vehicle which the units would board was the third one, which used publicVariable "Car3"

[edit2]

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

Car1 setVehicleVarName "Car1";

Worked on a dedicated server too.

So now they board Car1 and Car3 which are both created on the server.

even tho publicVariable "Car3" and Car1 setVehicleVarName "Car1" does the same "thing"

the setVehicleVarName will display "Car1" instead of "123ce34#blabla: REMOTE" which publicVariable does.

Unfortunatly it seems a rather complicated "switch do" thing is needed if we want to keep track of stuff which must use variable names for e.g. boarding troops.

Share this post


Link to post
Share on other sites

createvehiclelocal basically replaces the camcreate command. It is not for just vehicles but for everything like particle FX and it is only local.

--Ben

Share this post


Link to post
Share on other sites

AFAIK, createVehicleLocal is not a replacement for camCreate. It is just a supplement. createVehicleLocal still takes collision into account, whereas camCreate does not.

publicVariable and setVehicleVarName for sure do 2 different things.

setVehicleVarName does exactly the same as naming an object in the editor. As soon as you name an object in the editor, the object name will be designated as you named it, as opposed to having a designation like "12c12135#12134:Humww.plol REMOTE".

I am uncertain atm if setVehicleVarName broadcasts the VarName, my tests in pre 1.08 showed it did not, and I had to use the setVehicleInit command to set the VarName on every client, as described in your other thread.

publicVariable simply broadcasts a global variable.

If the global variable is a string, connected to an object or whatever does not matter, but it does NOT rename the object like setVehicleVarName does

Examples:

car1="hmmwv" createVehicle [0,0];

publicVariable "car1";

Should show car1 like "12c12135#12134:Humww.plol REMOTE" and alike, on every machine. Though Pre 1.08 did have some weird issues.

car1="hmmwv" createVehicle [0,0];

car1 setVehicleVarName "Car1";

publicVariable "car1";

Should show car1 like "Car1" on the machine where it was executed, but should display car1 as "12c12135#12134:Humww.plol REMOTE" on other machines

car1="hmmwv" createVehicle [0,0];

car1 setVehicleInit "this setVehicleVarName 'Car1'";

processInitCommands;

Should show car1 like "Car1" on the machine where it was executed, aswell as on the other machines. I am uncertain atm if you must assign the variable double, but I dont think so:

car1 setVehicleInit "car1=this; this setVehicleVarName 'Car1'";

Checking Locality, importance:

[*] Not executing the same multiple times (But can be resolved by executing everything on server-only)

[*] Some commands only work on the machine where the unit is local (Though v1.08 did a lot of changes to that, I think that: w2 setDammage 1; still only works when executed on w2's machine)

Share this post


Link to post
Share on other sites

sickboy

Thanks for reading the whole thing up there, I almost got tired myself when I read it over smile_o.gif

AFAIK, createVehicleLocal is not a replacement for camCreate. It is just a supplement. createVehicleLocal still takes collision into account, whereas camCreate does not.

Wouldn't createVehicleLocal create some odd things, like

Player1 MOVE away from MY vehicle will you please?

-what vehicle??

setVehicleVarName does exactly the same as naming an object in the editor. As soon as you name an object in the editor, the object name will be designated as you named it, as opposed to having a designation like "12c12135#12134:Humww.plol REMOTE".

Yepp, it'll show the name you put in the editor.

I am uncertain atm if setVehicleVarName broadcasts the VarName, my tests in pre 1.08 showed it did not, and I had to use the setVehicleInit command to set the VarName on every client, as described in your other thread.

The tests I did was on v.1.05 and it got broadcast, dunno what'll happen if i rename the object, I'll get back when testing that.

I think setVehicleInit and processblabla is needed if you put something in the init, like running a script or something which the client needs to see.

Again, uncertain, need to test this.

(ooh the time...)

car1="hmmwv" createVehicle [0,0];

car1 setVehicleVarName "Car1";

publicVariable "car1";

Wouldn't publicVariable "car1" over ride the setVehicleVarName?

Checking Locality, importance:

[*] Not executing the same multiple times (But can be resolved by executing everything on server-only)

[*] Some commands only work on the machine where the unit is local (Though v1.08 did a lot of changes to that, I think that: w2 setDammage 1; still only works when executed on w2's machine)

Nice comment! smile_o.gif

[edit]

About "reference"

Will

_myCar = car1

set in a server-script.

When car1 is respawned, will _myCar still have a reference to car1 when that variable is "reset"(or in by any other means of possible doings be changed to something else), or will it be "skalarboolcopters"?

Share this post


Link to post
Share on other sites
sickboy

Thanks for reading the whole thing up there, I almost got tired myself when I read it over smile_o.gif

Wouldn't publicVariable "car1" over ride the setVehicleVarName?

NP smile_o.gif

The createVehicleLocal is mainly created for doing local 'effects'. createVehicle, the name is a bit misleading, as it can create any kind of object (objects are referred to as "vehicles" in ArmA mostly). For instance, my Tracer addon and more, make use of camCreate, which is alike createVehicleLocal, to create tracer effects on the client-only. Thus not requiring the tracer addon on other clients while playing as the effect of the addon is 100% local.

publicVariable "car1" should override "car1" variable on every machine with the contents of the car1 variable on the machine on which the publicvariable was executed.

BUT, assigning an object to a variable does not rename the object.

car1 = "HMMWV" createVehicle [0,0];

player sidechat str(car1);

still returns the: #21484: 595490 blablabla name of the object

whereas

car1 = "HMMWV" createVehicle [0,0];

car1 setVehicleVarName "car1"

player sidechat str(car1);

Should return "car1"

Quote[/b] ][edit]

About "reference"

Will

_myCar = car1

When car1 is respawned, will _myCar still have a reference to car1 when that variable is "reset"(or in by any other means of possible doings be changed to something else), or will it be "skalarboolcopters"?

When car1 dies he should still be accessible in the _myCar. Until the car gets deleted/respawned, as the current object gets destroyed, and as such _myCar will be objNull afaik.

in this case you should check if _myCar == objNull and as such IF it was objNull, you should redefine _myCar = car1;

This requires "car1" to be updated again with the setVehicleVarName thingy, before the _myCar = Car1; is executed.

You can simply keep it loop checking until Car1 is a valid object again:

waitUntil {Car1 != objNull};

_myVar = Car1;

Share this post


Link to post
Share on other sites

Thanks!

When car1 dies he should still be accessible in the _myCar. Until the car gets deleted/respawned, as the current object gets destroyed, and as such _myCar will be objNull afaik.

in this case you should check if _myCar == objNull and as such IF it was objNull, you should redefine _myCar = car1;

This requires "car1" to be updated again with the setVehicleVarName thingy, before the _myCar = Car1; is executed.

You can simply keep it loop checking until Car1 is a valid object again:

waitUntil {Car1 != objNull};

_myVar = Car1;

The question though is why use _myVar, if you work with predefined global variables anyway: Car1.

It would have been easier if it didn't lose the reference as I'm reluctant of using "hard coded" variable names in my scripts for generic usage of the scripts.

Share this post


Link to post
Share on other sites

Though ur using global predefined variables in the above case, you can make it universal:

You can for instance make a universal script like, if you add this to init.sqf (or whatever):

TST_1=

{

waitUntil {(call compile _this) != objNull};

_myVar = (call compile _this);

// More stuff you need to execute

};

which you can spawn with:

"car1" spawn TST_1;

(Make sure before executing this, "car1" is either an object or objNull)

Another thing is... when you use functions and setVehicleInit, you can work without naming things smile_o.gif

car1 = "hmmwv" createVehicle [0,0];

car1 setVehicleInit "player moveInCargo this";

processInitCommands;

(and alike) could save a lot of pains with naming units and getting things done on different clients etc.

In my time I learned that I tried things way way way too complicated... With a little thinking here and there, you can execute nearly everything on the server, which makes things already a lot more easy. And on the other hand you can make a lot of effects and things simply local on every client.. In usual situations you do not have to public/global var too much.

The setVehicleInit and processInitCommands, are not only to execute something once, or at the very beginning. You can use setVehicleInit all over the whole match, and use it to execute code over the network.

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  

×