Jump to content
Sign in to follow this  
Hailthorn

Public Arrays

Recommended Posts

I'm a relative noob at scripting but I'm trying to write a script to put into the init.sqf file of a multi-player mission which will check the user ID of the player logging onto the server against an array containing the user IDs of banned players. I was wondering if I'd need to make such an array public and if so how would I go about it? I've was thinking of a script along the lines of:

_uid = getPlayerUID player;
_uidArray = [000010,00020001,...];
if (_uid == forEach _uidArray) Then {forceEnd};

However whenever I try this out it doesn't work any ideas why?

Share this post


Link to post
Share on other sites

This

(_uid == forEach _uidArray)

is wrong.

Check the wiki for proper use of the forEach command.

You want to use the in command here.

Share this post


Link to post
Share on other sites

if (!isServer && isMultiplayer) then {
 // add id's below
 _blackList = ["12356","654321"]; // enter ID's here
 waitUntil {!isNull player};
 waitUntil {(getPlayerUID player) != ""};
 _id = getPlayerUID player;
 if (_id in _blackList) then {
   sleep 1;
   endMission "LOSER";
 }; 
};

Wil only work in MP.

Share this post


Link to post
Share on other sites

Thanks guys hopefully it will work now. Just thinking, would it be possible for an admin to add an ID to the list without editing it, via addAction maybe?

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  

×