Код:
/* ===========================================================================================
************* Lottery System with ticket nunber system* ****************
************************MADE BY - BroZeus****************************
Credits--
SAMP Team -- For Making SAMP
YSI -- For sscanf2 and foreach
Zeex -- For ZCMD
BroZeus -- For scipting
Please Do Not Remove The Credits Or Redistrubate.
==============================================================================================*/
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <foreach>
#define lottoadd 100000 //<------Specifies the amount from which the lottery beguns when /startlotto
//or when a player wins and also the amount of money to add to lotto at every lotto
#define ticketprice 1000 //<----Price of taking a ticket
#define numrange 150 //<-----For number range to specify the winning nuber should be between 0-numrange
#define lottogap 10 //<-----For the time gap between lottery [the valuse should be in minutes] [NO DECIMAL VALUES]
#define minlottoadd 1000 //<----Specifies the minimum amount of money a player can add to lotto
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("******************************************************************************** ");
print(" Lottrey System - Version 1.0 Loaded ");
print(" Made By- Zeus ");
print(" "); ");
print(" Please Do Not Remove The Credits Or "); ");
print(" Redistrubate. ");
print("******************************************************************************** ");
return 1;
}
public OnFilterScriptExit()
{
print("******************************************************************************** ");
print(" Lottorey System - Version 1.0 Un-Loaded"); ");
print(" Made By- Zeus");
return 1;
}
#endif
new ticketnum[MAX_PLAYERS],takenticket[MAX_PLAYERS]=0;
new lotto_timer;
new bool:IsLottoStarted=false;
new totallotto=lottoadd;
forward draw();
stock IsNumTaken(n)
{
new m;
foreach(m:Player)
{
if(takenticket[m]==1)
{
if(ticketnum[m]==n)return 1;
}}
return 0;
}
public draw()
{
new m,win,winname[MAX_PLAYER_NAME],wmes[300],iswin=0;
win=random(numrange);
SendClientMessageToAll(0xCCFF00,"LOTTERY DRAW-----------");
format(wmes,sizeof(wmes),"The winning number is %i",win);
SendClientMessageToAll(0xCCFF00,wmes);
foreach(m:Player)
{
if(takenticket[m]==1)
{
takenticket[m]=0;
if(ticketnum[m]==win)
{
GetPlayerName(m,winname,sizeof(winname));
format(wmes,sizeof(wmes),"%s(%i) has win the lottery and gets a total prize of %i $",winname,m,totallotto);
SendClientMessageToAll(0xCCFF00,wmes);
GivePlayerMoney(m,totallotto);
format(wmes,sizeof(wmes),"Congratulations!! You have won total prize of %i $ from lotto",totallotto);
SendClientMessage(m,0xCCFF00,wmes);
totallotto=lottoadd;
format(wmes,sizeof(wmes),"The lotto money has been reseted to %i $",totallotto);
SendClientMessageToAll(0xCCFF00,wmes);
iswin=1;
}
ticketnum[m]=20000;//resets the no. if ticket to value that cannot be taken in /ticket
}
}
if(iswin==0)
{
totallotto+=lottoadd;
format(wmes,sizeof(wmes),"No one has won the lottery and the total lotto prize now is %i $",totallotto);
SendClientMessageToAll(0xCCFF00,wmes);
}
return 1;}
CMD:startlotto(playerid,params[])
{
new startername[MAX_PLAYER_NAME],stri[200];
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "{ff0000}You are not authorized to use this command");
if(IsLottoStarted==true)return SendClientMessage(playerid, 0xFF4500AA, "Lottery has already been started");
IsLottoStarted=true;
GetPlayerName(playerid,startername,sizeof(startername));
format(stri,sizeof(stri),"%s has started Lottery",startername);
SendClientMessageToAll(0xCCFF00,stri);
format(stri,sizeof(stri),"It will be drawed after %i minutes.",lottogap);
SendClientMessageToAll(0xCCFF00,stri);
format(stri,sizeof(stri),"Current lottery is of %i $",lottoadd);
SendClientMessageToAll(0xCCFF00,stri);
format(stri,sizeof(stri),"Do /ticket [your number] to take a ticket | The number should be in range of 0-%i",numrange);
SendClientMessageToAll(0xCCFF00,stri);
lotto_timer=SetTimer("draw",1000*60*lottogap,true);
return 1;
}
CMD:lotto(playerid,params[])
{
new ru[200],ti;
if(IsLottoStarted==false)return SendClientMessage(playerid, 0xFF4500AA, "Lottery has not been started yet.");
if(sscanf(params,"i",ti))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage of command | Correct Usage : /lotto [your number]");
format(ru,sizeof(ru),"The nuber should be in range of 0-%i",numrange);
if(ti > numrange || ti < 0)return SendClientMessage(playerid,0xFF4500AA,ru);
format(ru,sizeof(ru),"You need to have %i $ to buy ticket.",ticketprice);
if(GetPlayerMoney(playerid)<ticketprice)return SendClientMessage(playerid,0xFF4500AA,ru);
if(takenticket[playerid]==1)return SendClientMessage(playerid,0xFF4500AA,"You have already taken a lottrey ticket.");
if(IsNumTaken(ti))return SendClientMessage(playerid,0xFF4500AA,"The number has already been chosen by other user. | Please chose other number");
takenticket[playerid]=1;
GivePlayerMoney(playerid,-ticketprice);
ticketnum[playerid]=ti;
format(ru,sizeof(ru),"You have chosen %i as your lucky number!!",ti);
SendClientMessage(playerid,0xCCFF00,ru);
return 1;
}
CMD:stoplotto(playerid,params[])
{
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "{ff0000}You are not authorized to use this command.");
if(IsLottoStarted!=true)return SendClientMessage(playerid,0xFF4500AA,"No lottery is currently going on.");
new m;
IsLottoStarted=false;
KillTimer(lotto_timer);
SendClientMessageToAll(0xFF4500AA,"The lottery has been stopped by an admin");
foreach(m:Player)
{
takenticket[m]=0;
ticketnum[m]=20000;//resets the no. if ticket to value that cannot be taken in /ticket
}
return 1;
}
CMD:lotto(playerid,params[])
{
if(IsLottoStarted!=true)return SendClientMessage(playerid,0xFF4500AA,"No lottery is currently going on");
new rm[200];
format(rm,200,"Current lottery prize is %i $",totallotto);
SendClientMessage(playerid,0xCCFF00,rm);
if(takenticket[playerid]==1)format(rm,200,"Your Current number is %i",ticketnum[playerid]);
else format(rm,200,"Do /ticket [your number] to take a lottery ticket",ticketnum[playerid]);
SendClientMessage(playerid,0xCCFF00,rm);
return 1;
}
CMD:addlotto(playerid,params[])
{
new adm,oo[120],playername[MAX_PLAYER_NAME];
if(IsLottoStarted!=true)return SendClientMessage(playerid,0xFF4500AA,"No lottery is currently going on");
if(sscanf(params,"i",adm))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage | Correct Usage : /addlotto [amount of money to add]");
if(GetPlayerMoney(playerid)<adm)return SendClientMessage(playerid,0xFF4500AA,"Not enough money to donate.");
format(oo,sizeof(oo),"You cannot doante less than %i $.",minlottoadd);
if(adm<minlottoadd)return SendClientMessage(playerid,0xFF4500AA,oo);
GivePlayerMoney(playerid,-adm);
GetPlayerName(playerid,playername,sizeof(playername));
format(oo,sizeof(oo),"%s(%i) has doanted %i $ to lottery.",playername,playerid,adm);
SendClientMessageToAll(0xCCFF00,oo);
totallotto+=adm;
format(oo,sizeof(oo),"Now the total lotto prize has become %i $",totallotto);
SendClientMessageToAll(0xCCFF00,oo);
return 1;
}
CMD:lottohelp(playerid,params[])
{
new show[300];
if(IsPlayerAdmin(playerid))format(show,sizeof(show),"{9ACD32}/startlotto\t\tStarts a lottery\n/stoplotto\t\tStops a lottery\n/ticket [your number]\tSelect your lucky number for lottery\n/lotto\t\t\tShows the current lotto prize and your lucky number if selected\n/addlotto [amount]\tUse to Doante to lottery");
else format(show,sizeof(show),"{9ACD32}/ticket [your number]\tSelect your lucky number for lottery\n/lotto\t\t\tShows the current lotto prize and your lucky number if selected\n/addlotto [amount]\tUse to Doante to lottery");
ShowPlayerDialog(playerid, 110, DIALOG_STYLE_MSGBOX, "{00BFFF}Available Lottery commands",show, "Cool", "");
return 1;
}
/* ===========================================================================================
************* Lottery System with ticket number system****************
************************MADE BY - BroZeus****************************
Credits--
SAMP Team -- For Making SAMP
YSI -- For sscanf2 and foreach
Zeex -- For ZCMD
BroZeus -- For scipting
Please Do Not Remove The Credits Or Redistrubate.
==============================================================================================*/