zkb1325 28 Posted October 10, 2013 I'm trying to make a lottery script for a life mission where players go up to an option and enter the lottery. Then every so often it will pick a winner and broadcast who the winner is. The problem I am having is when it gets to the point of picking the winner from an array. There are 2 variables: lotteryarray = []; lotterymoney = 0; I think i got the first script working the way i intended it to but it's hard to tell since the second script does not work right. lotteryplayer = name vehicle player; if ("geld" call INV_GetItemAmount < 5000) then { player sideChat"You need more money to buy a lottery ticket."; } else { ["geld", -5000] call INV_AddInvItem; player sideChat "You bought a lottery ticket for $5000 you can buy more to increase your chance of winning."; lotteryarray = lotteryarray + [[lotteryplayer]]; publicVariable "lotteryarray"; ["lotteryarray", lotteryarray] spawn ClientSaveVar; lotterymoney = lotterymoney + 5000; publicVariable "lotterymoney"; }; The second script is where I'm having problems getting it to select a random name/player. lotterywinner = lotteryarray select floor(random(count lotteryarray)); sleep 5; while {true} do { sleep 10; server globalchat format ["A Lottery winner will be picked in 10 seconds"] call broadcast; sleep 10; server globalChat format ["The Lottery has been drawn and the winner is %1. They have won $%2", lotterywinner, lotterymoney] call broadcast; sleep 1; lotteryarray = []; publicvariable "lotteryarray"; ["lotteryarray", lotteryarray] spawn ClientSaveVar; lotterymoney = 0; publicvariable "lotterymoney"; ["lotterymoney", lotterymoney] spawn ClientSaveVar; }; I have tried multiple ways of this: lotterywinner = lotteryarray select floor(random(count lotteryarray)); But it results in say either "ANY" or "NULL". Any help is much appreciated. Share this post Link to post Share on other sites