Jump to content
Sign in to follow this  
IntruderDZ

Scripting help

Recommended Posts

ok im having trouble using this public variable.

I have 2 scripts one for the host (server) and one for the players(clients). I attempted to add Publicvariable"Blahblah" and @(blahblah) but with no luck. The host's scripts runs but the clients doesnt. I have a trigger where i exec both of them the one for the host and the clients. here are both of them without my publicvariable attempts

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

;;;Server Script

?!(local server):exit

_origin = _this select 0

_distance = 1

_xpos = getPos _origin Select 0

_ypos = getPos _origin Select 1

_angle = getDir _origin

;;;;;;;;;;;;;;;;;1

Goto "Offset"

#offset

_xoffset = (sin _angle) * _distance

_yoffset = (cos _angle) * _distance

_obj = NearestObject [_xpos + _xoffset, _ypos + _yoffset, 0]

? ((_obj == _origin) && (_distance < 2)): _distance = _distance + 1.5; goto "offset"

? (_obj != _origin): goto "Move1"

#move1

_obj setpos [(getPos p) Select 0,(getPos p) Select 1,26.8]

Exit

<span id='postcolor'>

and this is the client script

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

;;;ClientScript

_origin = _this select 0

_distance = 1

_xpos = getPos _origin Select 0

_ypos = getPos _origin Select 1

_angle = getDir _origin

;;;;;;;;;;;;;;;;;1

Goto "offset"

#offset

_xoffset = (sin _angle) * _distance

_yoffset = (cos _angle) * _distance

_obj = NearestObject [_xpos + _xoffset, _ypos + _yoffset, 0]

? ((_obj == _origin) && (_distance < 2)): _distance = _distance + 1.5; goto "offset"

? (_obj != _origin): goto "Move1"

#move1

_obj setpos [(getPos p) Select 0,(getPos p) Select 1,26.8]

<span id='postcolor'>

where am i supposed to put the @(BLahblah) and the Publicvariable "blahblah" within both scripts in order for it to activate and work together? and... do i have to do that for each execution say if i wanted to add more than one setpos line??

Share this post


Link to post
Share on other sites

Do you use random or relative coordinates for destination?

ie : do you use any "a setPos [(getPos a) select 0, (getPos a) select 1, ((getPos a) select 2) + 3]"

or any random position.

As scripts are run on every PC, any relative coordinate (coordinate + offset) are calculated n times, n being the number of players, so the object is mpoved by n x offset .

And, random function is evaluated on each PC and return different results, resulting in non coherent placement on every PC.

You should run your script only on the server, by placing a LOGIC unit in your map, naming it server , and by putting at the beginning of your script :

?!(local server):exit

Whis'

Share this post


Link to post
Share on other sites

Thanks for the reply Whisper. So this Local server thing should make it run on the host machine and relay it to the other players confused.gif is that right ? making it so that whatever the host sees is what everyone else will ?

Share this post


Link to post
Share on other sites

well som'gun. Well it ran fine, only on my machine (host) now how do i get it to run for each players computer. Is there another command line for that ? what is Local variable ? will that make it local to the individual's computer ? Any takers

Share this post


Link to post
Share on other sites

You need to research multiplayer scripting. Try these forums and OFPEC. Also there is some Multi stuff on the bn880 page below. PublicVariable is a big hint.

Share this post


Link to post
Share on other sites

Ok forgive me cause i dont know really what to do but im sure someone does. How to sync all players script executions so that the data is identical on each machine. I have some understanding that a Server has his own script and the clients have thier own scripts, but how confused.gif?

Share this post


Link to post
Share on other sites

oooops... wow.gif

Sry for the late reply

I didn't see any random or relative setting in your code, so the problem should not be there.

BUT... smile.gif

did you try :

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_obj setpos [(getPos o) Select 0,(getPos o) Select 1,36.2] <span id='postcolor'>

(...) is important smile.gif

For your second code, getPos for a marker do not work, if I remember well, you should use getMarkerPos

Whis'

Share this post


Link to post
Share on other sites

publicvariable "blahblah"  and    @(blahblah)

for multiplayer scripts ?? will this solve my problem for inconsistent results throughout all the players machines.

Share this post


Link to post
Share on other sites

ok im having trouble using this public variable.

I have 2 scripts one for the host (server) and one for the players(clients). I attempted to add Publicvariable"Blahblah" and @(blahblah) but with no luck. The host's scripts runs but the clients doesnt. I have a trigger where i exec both of them the one for the host and the clients. here are both of them without my publicvariable attempts

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

;;;Server Script

?!(local server):exit

_origin = _this select 0

_distance = 1

_xpos = getPos _origin Select 0

_ypos = getPos _origin Select 1

_angle = getDir _origin

;;;;;;;;;;;;;;;;;1

Goto "Offset"

#offset

_xoffset = (sin _angle) * _distance

_yoffset = (cos _angle) * _distance

_obj = NearestObject [_xpos + _xoffset, _ypos + _yoffset, 0]

? ((_obj == _origin) && (_distance < 2)): _distance = _distance + 1.5; goto "offset"

? (_obj != _origin): goto "Move1"

#move1

_obj setpos [(getPos p) Select 0,(getPos p) Select 1,26.8]

Exit

<span id='postcolor'>

and this is the client script

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

;;;ClientScript

_origin = _this select 0

_distance = 1

_xpos = getPos _origin Select 0

_ypos = getPos _origin Select 1

_angle = getDir _origin

;;;;;;;;;;;;;;;;;1

Goto "offset"

#offset

_xoffset = (sin _angle) * _distance

_yoffset = (cos _angle) * _distance

_obj = NearestObject [_xpos + _xoffset, _ypos + _yoffset, 0]

? ((_obj == _origin) && (_distance < 2)): _distance = _distance + 1.5; goto "offset"

? (_obj != _origin): goto "Move1"

#move1

_obj setpos [(getPos p) Select 0,(getPos p) Select 1,26.8]

<span id='postcolor'>

where am i supposed to put the @(BLahblah) and the Publicvariable "blahblah" within both scripts in order for it to activate and work together? and... do i have to do that for each execution say if i wanted to add more than one setpos line??

Share this post


Link to post
Share on other sites

I don't see what you are trying to do in this script.

From what I understand, it takes an unit/object/whatever as argument, and move it to the first object it encounters in the direction he is facing, 26.8 meters above ground.

Why would you need publicVariable?

Share this post


Link to post
Share on other sites

that is just a snippet of the scripts. There is  at least 15 objects per script and in multiplayer it never runs correctly ever. All the object either never make it  get misaligned or other objects in the place of the intended ones are moved. It runs perfectly in single player as i said in the first post of this thread. But lag or something in the multiplayer F***'s! everything up. So someone said i need to use public variable to make it run correct for each player.

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  

×