Newbie Needs Help (v2.0)(RemoteExecution)

ITr1ckst3rI

Member
My code
Code:
waituntil { !isNil "BIS_fnc_init" };
[nil, _x, rEXECVM, "foldername\foldername2\FreezePlayer.sqf", freeze] call RE;

FreezePlayer.sqf
Code:
_freeze = player switchMove "CtsDoktor_Vojak_hulakani1";

Desired Result = Having a cliented connected to the server switch into CtsDoktor_Vojak_hulakani1
by compiling and executing FreezePlayer.sqf

Actual Result = Nothing.

Can anyone help me out? This seems like a simple task that is eluding me


I know i can use this
Code:
waituntil { !isNil "BIS_fnc_init" };
[nil, _x, rSWITCHMOVE, "rodriguez_c0briefing"]

However i want to compile the other file. I will be adding more to it later.

SOLUTION:

For anyone who googled this, when i removed the following line in the init.sqf
Code:
#include "\z\addons\dayz_code\system\REsec.sqf"

All RE commands started to work.
 
Last edited:
in your init.sqf if the resec check is enabled then it prevents all the RE calls.
I have never had much luck with the RE calls anyways. What I do is this:

Create a variable in your init.sqf called RE_VAR
now create a public variable event handler "https://community.bistudio.com/wiki/addPublicVariableEventHandler
"RE_VAR" addpublicvariableeventhandler { player switchMove "CtsDoktor_Vojak_hulakani1"}

on the server when you want to call the re code, do this
RE_VAR = "some value"
publicvariable "RE_VAR"
and on the client the the event handler code will be executed. You can use the value of RE_VAR to determine which move you want or something else.
 
Thanks for the reply :)

Can you give an example for the code so I can get a visual of it?

Or paste a pre existing code.

Of course you don't have to, but I would understand better if I can see it :)
 
http://killzonekid.com/arma-scripting-tutorials-basic-multiplayer-coding/
https://community.bistudio.com/wiki/addPublicVariableEventHandler
the code has a decent example but they chose to put a bunch of random characters to its hard to tell what is actually being used.

So in your init.sqf file you need to add an event handler that will run a bit of code whenever the variable CHANGES. it doesnt matter what the variable is changed to, its the fact that it changes that makes the code be executed. Its useful to set the variable to some value that you can use in the script though.

So this is the handler. It runs the {code} whenever publicThis variable changes. So if I do publicthis = 3, the code runs, publicthis="boobies", it runs.
Code:
"publicThis" addPublicVariableEventHandler {
    hint format [ "publicThis has been updated to: %2", publicthis   ]
};
Imagine the above code on the client computer. and the below code on the server or some other players computer.
To change the variable we simply assign it a value like any other value, but to TELL all the computers that it has changed you have to use
Code:
publicthis = newvalue;
"publicthis" publicvariable;

Think of the publicvariable command as sending the variable to all other multiplayer computers. Thats all the code there is up there, very short and simple really and it allows you to run code on any computer. Remember you can send ANY kind of data to other computers by assigning it to the publicvariable (publicThis in this example). You can assign an array of values or an object such as player.

to review: the event handler code is run whenever the variable changes value .. it does not matter what the value of the variable is.
to trigger that code running on some other computer just change the value of the variable and then use publicvariable.
IMPORTANT: always remember to put the variable name in quotes, it sends the variabel name as a string. "publicThis" publicvariable.

publicThis publicvariable is how other functions would use the variable but that is incorrect in this instance
 
Okay, so I think I get it. How would I make it so only player _x executes the public variable? And not everyone currently connected?
 
Also is there a way to put the public variable deceleration in the same sqf that executes it? And not in the init file?
 
Last edited:
I am Not sure what you mean about the public variable declaration, it is treated just like any other variable.
To execute only for one players, set the public variable to that players uid and in your event handler you compare.
If pvar == player uid then ...

This event handler code will be the same as any other code you do for the event. Any informatuon you want to pass to the code, you set the p-var to. Create an array of alll the data your code req, assign it to the p-var. In the event code you get that data with p-var select 0 etc

I have a script for wasteland that saved player locations tents, inventory, vehicles all with this code. I can link it later for reference
 
okay so i have a file with a menu where i select a player. This player is defined in the code as variable _x.

instead of putting

Code:
"publicThis" addPublicVariableEventHandler {
hint format [ "publicThis has been updated to: %2", publicthis ]
};
in the init.sqf, could i put it in the menu.sqf i have and then execute it within the same file? (My guess is yes)

Also, i think i would have to get _x's UID then execute the line only for him


Something like
Code:
_UID = getPlayerUID _x;




"Freeze" addPublicVariableEventHandler {             //creating commands to run
_UID2 = getPlayerUID player ;                              //getting local UID from client running the script

if (_UID  == _UID2) //comparing UID from _x and player to confirm it is the same person

then{
player enablesimulation false; //do i use the semi-colon in this?
}
};
//calling it

freeze = true;
publicvariable freeze;
that?
 
Last edited:
I dont know that you could use _x as a variable. that is the 'magic' variable that refers to an object in a foreach loop.
Lets see if we understand what you are going to do.
Each player is going to have a menu addaction item listing all the players (or some players) and they can 'freeze' another player.
So the issue you have to solve are how to freeze a player on a different computer which means the actual code to do your freeze MUST run on that targets computer.

this is just a guess on how to would go about this.
So in your addaction menu, instead of running a script, just assign the publicvariable the players UID (freezeUID = playerUID; publicvariable "freezeUID";) This will cause the publicvariableeventhandler to fire and it will have the playersUID as the value of freezeUID;
So your eventhandler code would look like


Code:
"Freeze" addPublicVariableEventHandler {             //creating commands to run
_UID2 = getPlayerUID player ;                              //getting local UID from client running the script
_UID = freeze;

if (_UID  == _UID2)  then{
     player enablesimulation false; //do i use the semi-colon in this?
    }
};
Code:
player addAction ["PlayerName", {freezeUID = getplayeruid target_player; publicvariable "freezeUID"  }];
BTW: the freezeUID = getplayeruid target_player is just saying what you WANT, not sure thats how it would be done. getplayeruid would require you to have the targets player object on the other computers.

What I dont know off the top of my head is how you would get a list of all the players names into your addaction menu. One method would be in init.sqf to create an array of currently connected playernames and UIDs in a global variable and declare that as a publicvariable so its sent to all the clients, Then each computer would have connected player names and UID to utilize in their addaction menu. there is probably already a variable or function in dayz with that info but I am not aware of what it would be, but it seems like something that would already exist.
 
Im going to test that out now and edit this post with the results.

I have a framework that someone else wrote up that i am trying to use. If i don't get this to work i will post a pastie and you can take a look at it

also, _name in the framework i am using is pselect5; which is who is selected using the mouse wheel.

so instead of using _x i will use _name
 
Last edited:
Ah wonderful. You are using cursortarget on the player. That will make things easier as it returns an object . So if you are looking at a player,

targetPlayer = cursortarget;
Now on the person performing the FREEZE you can actually have the playeruid
targetUID = getplayerUID targetPlayer;

and simply set freezeUID = targetUID , make freezeUID public, and now the event handler code runs on all compturs and compares the local players UID to the freezeUID that is supposed to be frozen.
 
No, I made my post before you posted that.
all that cmd menu code ... do you NEED a menu? Or can you just pop up an addaction that says FREEZE when you look at a player.
If you need the menu, that looks right. You are cycleing though all objects and getplayerUID _x which will work in the foreach loop.
 
what about this code here?

  1. _UID2 = getPlayerUID player ; //getting local UID from client running the script
  2. _UID = getPlayerUID _name;

It looks like your menu is passing the targets name. getplayerUID only works with an OBJECT, you can't replace it with the name of the player object...
 
Your code LOOKS like it would work except for using the _name instead of the player object. The cmd menu must pass the player object or uid, not the players names. Why don't you test some of the code and see what happens. Put a bunch of diag_log in and print out the variables. Remember, if the code runs on the client, your diag_log will print to the players rpt and not to the server rpt.
 
i tested this
Code:
    {
        if(name _x == _name) then
        {
            _tempException = getPlayerUID _x;
            tempList = [
                "_tempException"
            ];
     
          "Freeze" addPublicVariableEventHandler {             //creating commands to run
           _UID2 = getPlayerUID player ;                              //getting local UID from client running the script
           _UID = getPlayerUID _x;

            if (_UID  == _UID2)  then{
            player enablesimulation false; //do i use the semi-colon in this?
                                    }
                               }        
            _tempException = nil;
            tempList = [
                "_tempException"
            ];
        };
    } forEach entities "CAManBase";
};
and nothing happened. Im going to include the diag_log here in a second.

To sum it up

1) Menu gets all players on server
2) Code gets selected players UID
3) Code runs and the local players UID is collected.
4) Code compares the two, and runs if they are equal

Makes sense, but doing it is turning out to be a pain in my ass lol
 
Back
Top