Jump to content
Sign in to follow this  
McArcher

problem with addAction

Recommended Posts

I know that addAction is a local function, so I add action to an object with if (not isServer) check. The script, given as a parameters for this action seems to be running strangely. The situation is following...

To test, if this script is running on client or server I add isServer check and wrote diag_log with some text for server and client, to check. For client it works ok, but... my aim is to run this script on sever, and when I look in server's .rpt i see

2009/12/26, 23:38:44 Server: Update of object 2:35 arrived from nonowner

2009/12/26, 23:39:10 Server: Update of object 2:348 arrived from nonowner

2009/12/26, 23:39:54 Server: Update of object 2:668 arrived from nonowner

instead of 3 records of diag_log And of course my global object isn't updated by this script... :(

Why? What's wrong? How can I make script in addAction be executed by server? Thanks.

---------- Post added at 01:05 ---------- Previous post was at 00:53 ----------

I tried to execute this script on client only. Here are results:

1. setMarkerColor sets new color for marker properly, at least on map it changes (if it is changed on other clients I don't know yet)

2. special global variables change their values, it's ok

3. setFlagTexture changes texture of a flag , BUT (!!!) in some seconds it returns back the old texture (there was empty one before that). How???

What did I do to solve it? Gone to Biki, on setFlagTexture page I see both Local and Global pictures :eek:

So... How can I change texture of flag permanently? Or is it a new bug?? how can it disappear in a few secconds??

Please help me. Thanks again!

---------- Post added at 01:56 ---------- Previous post was at 01:44 ----------

P.S. flagpoles were created by server's script, so they must be global.

Edited by McArcher

Share this post


Link to post
Share on other sites

Depends what your trying to do with your Action. But there are two methods, each one has its own set of behaviour. For example if you want to execute a script on all clients and server from a user action. And that script requires a variety of parameters, then use AddPublicVariableEventHandler.

If you only need to pass a single object, like the person who activated the action. You can use setVehicleInit.

That's just a basic rule of thumb, you can sometimes get away with using either of the above methods to accomplish the same task, with and without some minor restrictions.

You also have to consider that every call to setVehicleInit is remembered by the server. So anyone who JIP's will have them all executed one after the other. Where as PublicVariables only remember the last action sent.

By way of an example lets take your flag texture problem...

AddPublicVariableEventHandler

Init.sqf:

"MY_FLAG_POLE" AddPublicVariableEventHandler {((_This Select 1) Select 0) setFlagTexture ((_This Select 1) Select 1)}

Your addAction script would then look like this:

_Object=_This Select 0;
MY_FLAG_POLE=[_Object,"\ca\misc\data\sever_vlajka.paa"];
PublicVariable "MY_FLAG_POLE";

With SetVehicleInit you just need this in your addAction script:

_Object=_This Select 0;
_Object SetVehicleInit "This setFlagTexture ""\ca\misc\data\sever_vlajka.paa""";
ProcessInitCommands;

Well that's just a basic example, you can execute scripts or code. Again the best method is down to what you want to do. For one of two flag poles i.e. like a Capture The Flag mission, then AddPublicVariableEventHandler will do. If you have multiple objects, you might be better off with setVehicleInit.

Share this post


Link to post
Share on other sites
_Object=_This Select 0;

_Object SetVehicleInit "This setFlagTexture ""\ca\misc\data\sever_vlajka.paa""";

ProcessInitCommands;

this works fine! thank you very much!

Edited by McArcher

Share this post


Link to post
Share on other sites

I have a similar problem. I started out with a flag pole with a small trigger surrounding it and stepping inside the trigger radius would cause the flag to change, the marker color to change, respawn area to move to that area, hint message and a few other things. Then I decided to add an action to the flag pole called "Raise Flag" and take all the things from my trigger and put them into the "raise flag" script and then I got rid of the trigger. Then problems started to occur where things were happening locally that only the specific client that used the raise flag action would see. Others on the server would not see the same results. So I searched around and wound up here and I'm still confused and need help. There are 10 (0-9) enemy flags that we capture in my coop mission. The flags cannot be recaptured by the enemy. this is my addAction for flag_raise0.sqs:

"0" objStatus "DONE";
tskobj_0 setTaskState "SUCCEEDED";
player setCurrentTask tskobj_1;
obj_0 = true;
publicVariable "obj_0";
playSound "drumroll";
US_Flag1 setFlagTexture "usa.paa";
ammobox2 setPos (getmarkerPos "box0");
"respawn_west" setMarkerPos getMarkerPos "base1";
"base1" setMarkerColor "ColorGreen";
hint composeText [parsetext format["<t size='1.4' align='center' color='#6698FF'>OBJECTIVE COMPLETED%1</t><br/><t size='1.1' align='center' color='#FFFFFF'>This is your HQ. You can respawn and rearm at this location%1</t>"]];
"respawn_west" setMarkerPos getMarkerPos "base1";
"respawn_west" setMarkerType "Flag";
Tak_Flag0 removeAction 0;
exit

Some of the commands work for everybody on the server, like the command that moves our ammo crate and sets the area as our new respawn location, but the hint message and sound file was seen and heard only by the client that raised the flag and only the leader seemed to be able to change the flag image. How do I would make the raise flag commands process correctly for all clients on the server so if one of the clients performed the action it would process the commands for all clients and remove the action for all clients? Any help would be appreciated.

Edited by A-SUICIDAL

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  

×