Jump to content
Sign in to follow this  
•»kâ¥vååñ §hrîkê«•

How to correctly add a script to respawned vehicles

Recommended Posts

Greetings all

I'm using this line in another script for vehicles

?_type == "UH60Mg":_vcl AddEventHandler [{damaged},{_vcl Exec "script1.sqs"}]

The script works in LAN by doing it this way but not in dedicated server, however, the script works in dedicated server when I add u1 AddEventHandler [{dammaged},{_this Exec "script1.sqs"}]; to the units init line. So I know the script works in dedicated server, but I don't know how to make the script work in dedicated server for respawned vehicles.

Edited by KayvaanShrike

Share this post


Link to post
Share on other sites

hi,

Greetings all

I'm using this line in another script for vehicles

?_type == "UH60Mg":_vcl AddEventHandler [{damaged},{_vcl Exec "script1.sqs"}]

The script works in LAN by doing it this way but not in dedicated server, however, the script works in dedicated server when I add u1 AddEventHandler [{dammaged},{_this Exec "script1.sqs"}]; to the units init line. So I know the script works in dedicated server, but I don't know to to make the script work in dedicated server for respawned vehicles.

I suggest you to read this, this and this.

cya.

Nikiller.

Share this post


Link to post
Share on other sites

To figure out what is going on you need to determine whether the script line is definately being run on the server and know the locality of the object you are assigning the eventhandler to.

You need to be very careful when using eventhandlers in MP; "Hit" and "killed" eventhandlers will only be called on the machine that the object is local to, I believe "dammaged" (sic) is global however. For example if I assign a killed eventhandler to a given player unit even if I add it on every machine, the eventhandler will only ever run the script on that player's machine (because the player is local to their machine), not on any others.

I only use eventhandlers in MP when there is absolutely no other way of getting the data I need. E.g. there is no reliable way of getting the "killer" of a unit other than using a killed eventhandler. For damaged the only thing you can't determine using a looped script (or a trigger if you want brute force and ignorance) is selectionname.

I recommend using this script system to respawn vehicles in MP. It provides a client side script for calling local effects (player.sqs) as well as efficiently managing the respawning of a large number of vehicles on the server side (vehicles.sqs). It's a good starting point for experimenting with and learning about the locality of objects in MP.

There's a lot that can be said about managing locality and MP game state data efficiently and reliably but you need to get a grip on how locality works first.

Edited by *Zeewolf*

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  

×