Jump to content
Sign in to follow this  
alleycat

addaction server/client

Recommended Posts

Created a script that adds an action players near houses. I thought that it would be a nice idea to have that server side, but turns out these actions are not existant for players. If I would make them not only serverside, wouldnt that be bad?There is nearly 2000 buildings that get the action. Does that really have to be run for every single player? The script appears to run quick, but I worry what happens with 25 players and people jipping in. It just feels so ghetto, slapping the server with all the script calls.

If that is the case, can these script calls be entirely clientside, the addaction affair being all clientside and stuff

if (isServer) then {

_handle1 = execVM "add_strat_layer.sqf" ;

then in the script:

_house_list = nearestObjects [pole, [
//KAZILLION BUILDINGS
],14000];


{_x addAction ["garrison_building", "somestuff.sqf"]} forEach _house_list;		

Share this post


Link to post
Share on other sites

Maybe this will help. Set a condition for when the action is available. Though, I think the action will still be on all of those objects, just hidden until the condition is met & then hidden again when the condition(s) are false.

FOBCreate = Player addAction ["DEPLOY FOB", "scripts\DeployFOB.sqf",[],1,false,true,"","[color=#ff0000]((Player == FOBMan) && !(Player in List BaseList))[/color]"];

Ofcourse you can't use player on the server. But a foreach playableunits should do it.

Edited by Iceman77

Share this post


Link to post
Share on other sites

The issue is wether there is an issue.

If the action is entirely clientside I can simply run it like this:

Init.sqf

if (local player) then {

//run the addaction scripts
};

This appears to add clientside actions for every player that runs init.sqf, which basically every player does that connected. I tested this on a dedicated (being the only player) and it seems to work.

So if every connecting client slaps 2000+ addactions on buildings on his local machine only then there should be no issue. The action itself messes with the clients variables who called it, so it should be safe. Unless I overlooked something.

Now if that script would call something that would affect others like spawning things, then using createvehicle would work properly, would it?

local------------------------------------ local------------------------------------ local--------------------------------------------- global?

client calls init.sqf --------- runs script locally that adds actions --------- action calls script that spawns stuff --------- will that globally happen?

Share this post


Link to post
Share on other sites

The script that creates objects would have to be server side... Well, you could create them locally, but use server instead.

---------- Post added at 23:10 ---------- Previous post was at 23:07 ----------

You could also look into mp framework rADDACTION. You may be able to use that how you wanted.

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  

×