Jump to content
Sign in to follow this  
Tankbuster

addAction and locality

Recommended Posts

Guys, just a quickie. :)

I have a vehicle that was created on the server that has an addAction on it, if a client comes up to the object and does the addAction, where does the script run? client or server?

Share this post


Link to post
Share on other sites

In only runs on the client.

You need to add the action on each client also for them to even have it.

Share this post


Link to post
Share on other sites
In only runs on the client.

That's what I suspected. Thanks.

---------- Post added at 10:39 PM ---------- Previous post was at 10:38 PM ----------

You need to add the action on each client also for them to even have it.

Eh? The addaction is put on the vehicle, which was created on the server. I assumed that any client would be able to use it.

Share this post


Link to post
Share on other sites

When you say created on the server do you mean created by a script running on the server, cos I had the same problem recently.

Got around it using setVehicleInit and processInitCommands

Example:

_vehInt=format["nul=this addAction [""Unload %1"",""fen_mission\supplytruck_unload.sqf"",[""%1"",""%2""]]",_vehCnt,_vehSqf];
_vehObj setVehicleInit format["%1",_vehInt];
processInitCommands;

Share this post


Link to post
Share on other sites

Yes, the vehicle was created by createVehicle running on the server.

Share this post


Link to post
Share on other sites

If you do say something like this:

if (!isServer) exitWith {};
//......
//......
MyVeh addAction [........];

Then the action would only be available on a server. Meaning only the host on a hosted server or playing in the editor will have the action.

Share this post


Link to post
Share on other sites

You can use the RE function to add them for all by running this on the server:

[nil, MyObject, "per", rADDACTION, "ActionName", "FileName"] call RE;

You can pile on extra arguments at the end like an ordinary addAction. However, might be tricky to get the right id if you need to remove the action from everybody later.

Share this post


Link to post
Share on other sites

Well, another thing i didn't know right there. Got any documentation for RE?

Share this post


Link to post
Share on other sites

Agg! Too much new stuff for this old brain.

Thanks mate, I'll look over that.

Share this post


Link to post
Share on other sites

OK this is very interesting.

I've read through that page. Is there any way of a client executing code on the server?

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  

×