tophe 69 Posted February 26, 2007 I have a script that runs in the beginning of the mission. This script will randomize the setPos of a number of objects. I do not use any publicVariables in it but somehow it seemd to work when I tried it unit setPos (house buildingpos (random 19)) Shouldn't that really put that unit in different positions on the different computers connected? Maybe I should run a script first on the server only that takes out the random numbers and the publicVariable them. Thus writing "unit setPos (house buildingpos x)" Is there a way to run a script on the server only? I have a gamelogic named Server in the mission. Thank you. // Tophe, Östgöta Ops Share this post Link to post Share on other sites
terox 316 Posted February 26, 2007 local / global / player / server First thing Game logics are "Only" local on the server, be it a player/server or a dedicated server as an unwritten standard, most missionn makers create a gamelogic and name it "Server" when you are running the code <span style='color:blue'>?(local server):</span> what you are actually stating is Is the game logic named "server" local on this machine, if so, run the code that follows on from ":" Typical switches are <ul> ?(local server):hint "I am the server machine" ?!(local server):hint "I am not the server machine" ? (local player):hint "I am a player machine" ?! (local player):hint "I am a dedicated server machine" Where and when to use these, is dependant on what code you are running and where you want the code to run More often than not you will see the following at the very start of a script ?(Local server): exit ?(local player): exit This line is used to stop the script from being run on certain machines Certain commands are local or global Global commands mean, that when the command is run on 1 machine, every other machine is sent / receives that data Local commands mean that the command will not be sent to other machines. In your example "setpos", this is actually a global command, which means only 1 machine needs to run this code, as all the other machines will receive the data of the objects new position and reposition it If you dont run this code on just 1 machine, then every machine will tell every ,machine where to setpos the object, and the last machine that runs the code, will be the one that overwrites the rest whereas "setdir" is local It takes time, but eventually you will discover which commands are local and which arent and the workarounds to create a global from a local Eg, to make setdir into a global command, first setdir the object then setpos it, the setpos sends the direction of the object, thus setdir has been sent globally. I hope that gives you a better understanding of the relationship between player/server/global/local Share this post Link to post Share on other sites
tophe 69 Posted February 26, 2007 That was VERY informative. All I needed was in that post! Thank you so much. Share this post Link to post Share on other sites
deanosbeano 0 Posted February 26, 2007 Fantasic piece of info terox , i havent got into mp coding yet but i hope when i do its all as easily followed as that. ty very much Share this post Link to post Share on other sites
t_d 47 Posted February 26, 2007 I dont think setDir is local. Maybe it is local for static objects like setPos but I am quite sure that both commands are global if we exclude static objects like buildings. Since I am making a MP project I know that setDir works correctly on vehicles. Share this post Link to post Share on other sites
terox 316 Posted March 1, 2007 I dont think setDir is local. Maybe it is local for static objects like setPos but I am quite sure that both commands are global if we exclude static objects like buildings. Since I am making a MP project I know that setDir works correctly on vehicles. Setdir is local....... what you may have done is 1) run code from the vehicle's init field, which would run that code local to that vehicle 2) got in and out of the vehicle, which in certain circumstances makes that vehicle local to you. How to prove Create a 2 player mission on a dedicated server add to it an empty M1A1 name the vehicle "tank" and then using a console or some such other method, simply tank setdir 45 If player1 runs the "setdir" code he will see the tank turn to the 45 degree angle Player2 wont see any change (if the tank is local to Player1, it will remain at that angle) (if the tank isnt local to Player1, it will remain at 45 degrees for approximately 1 second, then change back to its original direction 2nd stage of testing If the tank wasnt local to player1, simply get in it, then get out (providing the vehicle is empty, this will make it local to Player1) then re-run the setdir command, the tank will remain at the setdir that you gave it. Share this post Link to post Share on other sites
KeyCat 131 Posted March 1, 2007 In your example "setpos", this is actually a global command, which means only 1 machine needs to run this code, as all the other machines will receive the data of the objects new position and reposition it True for OFP but I think this changed in ArmA. setPos is now (for some reason) local. /KC Share this post Link to post Share on other sites
terox 316 Posted March 1, 2007 Thx for the input Keycat, i didnt realise that, I take it you've tested this? Share this post Link to post Share on other sites
KeyCat 131 Posted March 1, 2007 Yes, I breifly tested it on a helipad object and can confirm it's local for at least that object type. However reading the Biki states... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> This command has local effect, but some simulation types do synchronise their changes over the network whilst others do not. The only known object types that currently, don't synchronise their positions over the net, are statics (simulation = "house"). So it seems that most objects do sync over the network. Guess more testing is needed or someone else will probably jump in and clarify... /KC Share this post Link to post Share on other sites
whisper 0 Posted March 1, 2007 Just for complement, there is also another thing, besides the effect of a function that can be local or global, to take into consideration : the arguments. Certain function cannot work if their arguments (all of them or one of them) are local to where the function is run. In OFP for example, setPos only works on units local to the PC where the setPos is made. Same for moveInXXXX commands. If you try to move a unit non local to your computer, it won't do anything. There are also more subtle behaviors. For example, <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unit1 knowsAbout unit2 will return 0 if unit1 is not local to where the knowsAbout was made. You could think it is because unit1 doesn't know where unit2 is, but in fact, it is just that you don't know the knowsAbout status of a unit not local to your PC. Share this post Link to post Share on other sites
whisper 0 Posted March 1, 2007 Yes, I breifly tested it on a helipad object and can confirm it's local for at least that object type. However reading the Biki states...<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> This command has local effect, but some simulation types do synchronise their changes over the network whilst others do not. The only known object types that currently, don't synchronise their positions over the net, are statics (simulation = "house"). So it seems that most objects do sync over the network. Guess more testing is needed or someone else will probably jump in and clarify... /KC Most probably, BI reduced some of the network load by not sending positionnal updates anymore about objects that are never supposed to move Share this post Link to post Share on other sites
terox 316 Posted March 1, 2007 well i've just done some dedi testing and server/client testing on setpos Testing with v1.02 on a dedi setpos on a server local M1A1 when i tried setpossing it on my client, the other player saw the tank raised 10m above the ground and it remained there However on my client it fell back to the ground Because both clients saw the same setpos effect and the vehicle was not local to either, this i would say proves setpos (on vehicles at least) can be non locally executed and having a global effect, so it's a global command for vehicles. The falling back to ground on 1 client only, i assume is a pghysics problem, which i believe has been sorted in 1.04. In addition we also found you can now setpos vehicles under the ground, this was only possible in OFP with static objects such as ammo crates. However as soon as the vehicle starts to move, it pops back to ground level. I see as a community we will need to re-assess every command and discover it's true globAL/local properties and effects If static objects such as ammo crates positions arent updated over the network, then this could cause problems for cargo carrying capabilities etc and what about invisible targets? gotta wait til they stabilise arma first though Share this post Link to post Share on other sites