Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Lottery function by KingOfVC
- */
- IsLotteryStarted <- false;
- LotteryPrize <- 0;
- LotteryNumber <- 0;
- function onScriptLoad()
- {
- Lot <- array( GetMaxPlayers(), null );
- NewTimer("StartLottery",60000,0);
- print( "\nLottery: lottery script by KingOfVC was loaded." );
- }
- function onPlayerJoin( player )
- {
- Lot[ player.ID ] = LotteryArray;
- }
- function onPlayerPart( player, reason )
- {
- Lot[ player.ID ] = LotteryArray;
- }
- function StartLottery()
- {
- if ( IsInLottery == false )
- {
- Message("Lottery: The lottery has started, type /lotto <1-60> for your chance to win $" + LotteryPrize );
- IsLotteryStarted = true;
- NewTimer( "EndLottery", 15000, 1 );
- }
- }
- function EndLottery()
- {
- local
- kek = rand()%60,
- LotteryNumber = kek;
- Message("Lottery: The lottery is over, the lucky number was " + LotteryNumber );
- local plr, b;
- for( local i = 0; i < GetMaxPlayers(); i++ )
- {
- local plr = FindPlayer( i );
- if ( plr && Lot[ plr.ID ].IsInLottery == true )
- {
- if ( Lot[ plr.ID ].Number == LotteryNumber )
- {
- Message( "Lottery: The winner is..." );
- Message( "Lottery: " + plr.Name + ". ( won " + LotteryNumber + " )" );
- IsLotteryStarted = false;
- }
- else
- {
- local
- kes = LotteryNumber + 100000,
- LotteryNumber = kes;
- Message( "Lottery: No winners this time, the prize is now " + LotteryPrize )
- IsLotteryStarted = false;
- }
- }
- Lot[ player.ID ] = LotteryArray;
- }
- }
- class LotteryArray
- {
- IsInLottery = false;
- Number = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement