Jump to content
Sign in to follow this  
Toasted Duckie

Random player picked

Recommended Posts

Hello, it's been a long while since I've done anything ArmA2 related, but can someone tell me why the following doesn't work? Probably something with localities..

A trigger over an area of players with in the Cond field: true and on the OnAct field:

null = [thislist] execVM "randomselection.sqf"

randomselection.sqf

if (!isServer) exit;

_array = _this select 0;

_randomperson = _list select (floor(random(count _list)));

hintSilent format ["Randomperson select, his nameis %1",_randomperson];


_randomperson addWeapon "M16A2";

sleep 2;

if (player == _randomperson ) then 

{
hintSilent "You are the mole, hopefully ONLY YOU can read this message, but multiplayer testing will have to prove that";
}

exit

Players experience different people selected as a randomperson in the first hint. The second hint isn't displayed at all I think.

Halp:confused:

Thanks :) <3

Share this post


Link to post
Share on other sites

exit isnt an SQF command, thus first line isnt limiting script to just server, which causes everyone to randomly pick someone. It probably causes some syntax errors as well, as the IF is not used properly.

If the trigger covers all playable units, you could just do this without the trigger:

init.sqf

if isserver then {
 moleUnit = playableunits select floor(random(count playableunits));
 publicvariable "moleUnit";
};
waituntil {!isnil "moleUnit"};
waituntil {!isnull player};
if (player == moleUnit) then {
 player addweapon "M16A2";
 hintsilent "Hi mole!";
};

Share this post


Link to post
Share on other sites

Thanks for that lesson shk.

I'll try your example in a bit! What if I only wanted this to apply on 1 faction (only EAST for example?)

I know I should be able to figure this out myself on the fly, but my brain seems flooded :\

EDIT:

if isserver then {

while (side moleUnit  != east) do 
{
 moleUnit = playableunits select floor(random(count playableunits));
 publicvariable "moleUnit";
waituntil {!isnil "moleUnit"};
waituntil {!isnull player};
};
};
if (player == moleUnit) then {
 player addweapon "M16A2";
 hintsilent "Hi mole!";
};
};

if (true) exitWith {};

? :)

edit:

no :(

Edited by Toasted Duckie

Share this post


Link to post
Share on other sites

This would work great for a PVP mission ive been thinking of, You may of beat me to it with the 'mole' thing though.

As i have no idea about scripts and know absolutley nothing about the 'script' up there, Can you possibly give me a 'laymens' terms on how to get this to work please.

Share this post


Link to post
Share on other sites
I know I should be able to figure this out myself on the fly, but my brain seems flooded :\

if isserver then {
 _eastPlayers = [];
 {
   if (side _x == EAST) then {
     _eastPlayers set [count _eastPlayers,_x];
   };
 } foreach playableunits;
 moleUnit = _eastPlayers select floor(random(count _eastPlayers));
 publicvariable "moleUnit";
};
waituntil {!isnil "moleUnit"};
waituntil {!isnull player};
if (player == moleUnit) then {
 player addweapon "M16A2";
 hintsilent "Hi mole!";
};

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  

×