Jump to content
noname no skill

Script for Multiplayer - Select one player with Opfor team, get him Somename like "spy1" and createDiaryRecord

Recommended Posts

Need Help me Guys. I try makes scenaries for Multiplayer. And tried to resolve this issue - Select one player with Opfor team, assign him Somename as "spy1" and createDiaryRecord for him.

i try many scripts but not rusult.:down:

one script work in my computer but not work with my friends.

i try that in init.sqf

_arr=[r1,r2,r3];  
rozv1 = selectRandom _arr;  
rozv1 createDiaryRecord ["Diary", ["Bla-bla", "Bla-bla-bla"]];   
if (alive rozv1) then {hint format ["%1 is chosen", rozv1];};

and that

fn_SelectRandomOpfor = {   
_unit = objNull;
_unitsArray = []; 
{  if ((side _x == east ) and (isPlayer _x)) then { _unitsArray = _unitsArray + [_x]; }; } forEach allunits;  
rozv1 = _unitsArray call BIS_fnc_selectRandom;} call fn_SelectRandomOpfor;
rozv1 createDiaryRecord ["Diary", ["Bla-bla", "Bla-bla-bla"]];

and that

waitUntil {player == player};  
  
playerarray = [];  
{  
playerarray = playerarray + [_x];  
} forEach playableUnits;   
if (side player == opfor) exitWith { rozv1 = playerarray call BIS_fnc_selectRandom;  
rozv1 createDiaryRecord ["Diary", ["Bla-bla", "Bla-bla-bla"]]; 
if (alive rozv1) then {hint format ["%1 is chosen",rozv1];}; };

but every times when i tested with my friends we have problem with Select that one spy player.

say me please what I need to do to achieve the desired result.

Share this post


Link to post
Share on other sites

I think the problem could be that when you globally execute a command like selectRandom, each client that executes the command could select a different element from the array. So, in your example of rozv1 = selectRandom [r1,r2,r3]; one client could choose r1, while another chooses r2 and the server chooses r3, etc. I think the way around this would be to execute selectRandom on the server only and share the result with the clients.

 

Not sure if it would work, but you could try putting something similar to this in your initServer.sqf:

rozv1 = selectRandom [r1,r2,r3];
publicVariable "rozv1";

After that, hopefully you'd be able to use rozv1 in a separate script to add the diary entry. Again, not sure if that would work (and, even if it does, I"m sure there are better solutions).

Share this post


Link to post
Share on other sites

Thank you very much for the time being working fine. For everyone who needs a script:

we makes 9 players with somename - r2, r3, r4, r5, r6, r7, r8, r9, r10

Two triggers need to be made:

and put

First - with code in Act

_arr=[r2,r3,r4,r5,r6,r7,r8,r9,r10];   
rozv1 = selectRandom _arr;    
publicVariable "rozv1";    

AND you need to put a check mark on the server in this trigger

 

in the second -

 

when activated:

rozv1 createDiaryRecord ["Diary", ["Bla-bla", "Bla-bla-bla-bla"]];

And script get one random player and assign him Somename as "rozv1" then second trigger create Diary for this player.

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

×