Jump to content
Sign in to follow this  
Enigx

Execute function to other client to assign ACE_SelfActions menu

Recommended Posts

I have defined a function that assigns an ACE_SelfActions menu to specific players in a list (the mission administrators).

So in initPlayerLocal.sqf I have

_uid = getPlayerUID player;   
if(_uid in adminList)
    then 
    {    
        player call FUN_fnc_addPersonalMenu;        
    }; 

So when server starts the players in the adminList have the PersonalMenu in their ace self interaction menu.

Now I want to assign this menu when in game to another player connected and not in the original adminlist.

I will run an sqf by the PersonalMenu, that I can see because I'm an administrator, with the command to assign the menu to this player.

Because the ace actions are client side I have to execute the function on the client pc.

I immagine something like that

 

AssignPersonalMenuToPlayer.sqf

... other lines to identify the player in a list 
... player available in the variable "playerObject"

playerObject remoteExecCall ["FUN_fnc_addPersonalMenu", targets,false];

the targets is the  clientOwner ID . Here the problem to find it. Biki is not very clear about that (or maybe I couldn't figure it out)

I tried with this solution

... other lines to identify the player in a list 
... player available in the variable "playerObject"

flagCl = createVehicle ["Land_PenBlack_F",[0,0,0]];
flagCl setFlagOwner playerObject;
_clientID = owner flagCl;

playerObject remoteExecCall ["FUN_fnc_addPersonalMenu", _clientID];

deleteVehicle flagCl;

that means to assign a temporary flag object to the player and use the function "owner" to identify his clientOwner ID. Then use the ID as target of the remoteexeccall and exectute the function on the player pc

Unfortunately I cannot test it.

Any help about that? Can it work?

Thanks

Share this post


Link to post
Share on other sites

For those interested I solved the problem.

After searching some information on web, here a method I've found to execute a function on other client in MP. It uses the steam ID of the target client instead of his clientOwner ID

That's the general code to insert in your script 

TargetFunction ={                              // define a function inside the script
   _uidPlr = _this select 0;                   // input passed to the function (the Steam ID target)
   if(getPlayerUID player == _uidPlr)then{     // check if ID of client executing the script is the ID target
   ... Here any codes for the target client to execute. This code is executed only by the target 
   };    
};

// call the function to be executed on all clients except the server, passing the Steam ID of the target player
[getPlayerUID playerObject] remoteExec ["TargetFunction", -2]; // in playerObject the target player selected from a list for example

It is sufficient to insert in "... Here any codes for the target client to execute" the lines to be executed by the client.

In my case (see above).

AssignPersonalMenuToPlayer.sqf

... other lines to identify the player in a list 
... player available in the variable "playerObject"

TargetFunction ={
    _uidPlr = _this select 0;
    if(getPlayerUID player == _uidPlr)then{                          
    player call FUN_fnc_addPersonalMenu;
    hint "This message is visible only by the target client";
    };    
};
[getPlayerUID playerObject] remoteExec ["TargetFunction", -2];
hint format["You have assigned the menu to %1", name playerObject]; // this message is visible only by the caller

This executes the TargetFunction on all the clients (except server) and only the target client will execute the FUN_fnc_addPersonalMenu in the "if" statement.

 

I hope this can be useful to the comunity.

Cheers

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  

×