PDA

View Full Version : Our scripts wont work in multiplayer!



brsseb
Jan 11 2003, 11:40
Hi

I gota a couple of questions; I have a bunch of scripts which work just fine in SP but seem to run server-side only in MP. I launch them from the init handler of an addon (i.e. from config.cpp), and apparently only the computer
that owns the unit executes the script.

So how can I run a script on ALL machines? Does the init.sqs run on all
machines?

How come that adding an action to a vehicle does not take effect on all
clients, but only on the server?

Do I have to replicate all camcreated objects on all clients by hand?

- Rubblemaker (posted by BRSSEB)

Kegetys
Jan 11 2003, 14:54
</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (brsseb @<hidden> Jan. 11 2003,14:40)</td></tr><tr><td id="QUOTE">I launch them from the init handler of an addon (i.e. from config.cpp)[/QUOTE]<span id='postcolor'>
The inithandler is only ran on the server, which is a confirmed bug I hope will be fixed some day...

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Does the init.sqs run on all machines?[/QUOTE]<span id='postcolor'>

Yes

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">How come that adding an action to a vehicle does not take effect on all
clients, but only on the server?[/QUOTE]<span id='postcolor'>

You need to run the script which adds the action on all the clients.

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Do I have to replicate all camcreated objects on all clients by hand?[/QUOTE]<span id='postcolor'>

Yes, or use createvehicle instead.

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">So how can I run a script on ALL machines? [/QUOTE]<span id='postcolor'>

Well, from somewhere which gets ran on every client, init.sqs for example, or a trigger. If you want something that gets run only locally on clients (from an addactioned action for example) to do something on all other clients too, you need to set a variable in the action, do a &#39;publicvariable&#39; to it and make a trigger that does whatever you want to do when this variable is set. I believe you can find tutorials for that somewhere or by searching this forum for publicvariable.

brsseb
Jan 13 2003, 19:38
more qestions from my scripter. Please help, our Comanche depents on it if we are to make it work in MP:
-----------------------------------

REQUEST:

"Another couple of questions:

1.) Does "publicVariable" work with arbitrary arrays? The old comref says it
only works for such types as integer, string... but maybe thats outdated
information? Coz I need it to work with an array of records, i.e. something like

[ [ [], [ [], [] ], [] ] ] ]


2.) I had the following idea to make the Comanche scripts work in a MP game:
there&#39;re scripts running on each client which manage special stuff like
addactions, smoke, damage simulation, weapons, etc pp, but they don&#39;t really do
anything (&#33http://www.flashpoint1985.com/ikonboard301/iB_html/non-cgi/emoticons/wink.gif but feed their events to a global array (I call it "client
command buffer"). This array contains elements of the type

[command_ID,param1,param2,...]

and is handled by the init.sqs script. The init.sqs script constantly goes
thru the array to see if a new event has occured, and - if it has - dispatches
it via performing the required action on the client. It then removes the
item from the list and jumps back to an idle state where it waits for a new
command to be fed to the buffer.

The challenge is to fill the command buffer, as it can&#39;t be a simple global
variable (in this case the first client might kick out a dispatched command
before the second client hasn&#39;t even looked at it). So it rather needs to be
some clever mechanism that feeds the commands to local variables on each
client. Or, each command is tagged with a list of clients that have already
executed the command, so when its fully tagged, the server can kill it. Instead
of
tagging the element, I could also keep a counter for each command which
counts how many clients have already dispatched it

--------

brsseb
Jan 24 2003, 17:30
Hi again. My scritper had an urgent last question on this matter. Dunno what hes on to, but I hope someone can answer this:

"Hi

just noted that maybe I&#39;m stupid and its all very easy to make the scripts
work in MP, but therefore I MUST know this, so plz post in the forums; I still
can&#39;t open their damn fuckin shit site&#33;&#33;&#33;&#33;&#33;

"Need to know if the following commands take effect on ALL machine or on the
client which executes the command only:

setdir
setVelocity
setpos
drop
RemoveWeapon
RemoveMagazine
SetFuel
showCompass/Map/Radio&GPS...
DeleteVehicle
say
inflame

"

BRSSEB

Rastavovich
Jan 24 2003, 19:18
global (means every pc executes that):
setdir
setVelocity
setpos
RemoveWeapon
RemoveMagazine
SetFuel
DeleteVehicle
inflame (dunno)

local (only on the machine where the script runs):
drop
showCompass/Map/Radio&GPS...
say

bn880
Jan 24 2003, 21:57
And no, I do not believe you can pass arrays... http://www.flashpoint1985.com/ikonboard301/iB_html/non-cgi/emoticons/smile.gif

brsseb
Jan 26 2003, 13:32
Ok, hes got a final question:


"About the event handlers: The init event handler runs client-side only. Is this true for ALL event handlers then, like the damage/fired event handlers?"

BRSSEB (posting for rubblemaker, poor dude cant get on this page... http://www.flashpoint1985.com/ikonboard301/iB_html/non-cgi/emoticons/crazy.gif )

Kegetys
Jan 26 2003, 13:43
</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (brsseb @<hidden> Jan. 26 2003,16:32)</td></tr><tr><td id="QUOTE">"About the event handlers: The init event handler runs client-side only. Is this true for ALL event handlers then, like the damage/fired event handlers?"[/QUOTE]<span id='postcolor'>
the init handles only runs on the server, not on clients when used from the addon config at least. For other types, I believe the command reference has answers.

Rastavovich
Jan 26 2003, 13:46
Look into the official command reference:

All eventhandlers are global, except "Killed" and "Hit".
The same eventhandler on different machines is able to execute different things. (Makes me guess you have to add the eventhandlers for every not local machine manually or by script).