View difference between Paste ID: iE8wrD8v and weTsc9s5
SHOW: | | - or go back to the newest paste.
1
/* ===========================================================================================
2
				  ************* Lottery System with ticket nunber system* ****************
3
				  ************************MADE BY - BroZeus****************************
4
				  Credits--
5
				  SAMP Team -- For Making SAMP
6
				  YSI       -- For sscanf2 and foreach
7
				  Zeex      -- For ZCMD
8
				  BroZeus   -- For scipting
9
				  
10
				  Please Do Not Remove The Credits Or Redistrubate.
11
==============================================================================================*/
12
13
#include <a_samp>
14
#include <zcmd>
15
#include <sscanf2>
16
#include <foreach>
17
18
19-
#define lottoadd 50000  /*<------Specifies the amount from which the lottery beguns when /startlotto
19+
#define lottoadd 50000  //<------Specifies the amount from which the lottery beguns when /startlotto
20-
                        or when a player wins and also the amount of money to add to lotto at every lotto*/
20+
                        //or when a player wins and also the amount of money to add to lotto at every lotto
21
#define ticketprice 500  //<----Price of taking a ticket
22
#define numrange 150  //<-----For number range to specify the winning nuber should be between 0-numrange
23
#define lottogap 1   //<-----For the time gap between lottery [the valuse should be in minutes] [NO DECIMAL VALUES]
24
#define minlottoadd 100  //<----Specifies the minimum amount of money a player can add to lotto
25
26
#if defined FILTERSCRIPT
27
28
    public OnFilterScriptInit()
29
    {
30
31
    print("******************************************************************************** ");
32
    print("                                        Lottrey System - Version 1.0 Loaded                                            ");
33
    print("                                                  Made By- BroZeus                                          ");
34
    print(" ");                                                                                                                                                                ");
35
    print("                                       Please Do Not Remove The Credits Or   ");                                              ");
36
    print("                                                         Redistrubate.                                                                           ");
37
    print("******************************************************************************** ");
38
39
    return 1;
40
    }
41
    public OnFilterScriptExit()
42
    {
43
44
    print("******************************************************************************** ");
45
    print("                       Lottorey System - Version 1.0 Un-Loaded");                                            ");
46
    print("                                 Made By- BroZeus");
47
48
return 1;
49
    }
50
#endif
51
52
new ticketnum[MAX_PLAYERS],takenticket[MAX_PLAYERS]=0;
53
new lotto_timer;
54
new bool:IsLottoStarted=false;
55
new totallotto=lottoadd;
56
57
forward draw();
58
59
stock IsNumTaken(n)
60
{
61
new m;
62
foreach(m:Player)
63
{
64
if(takenticket[m]==1)
65
{
66
if(ticketnum[m]==n)return 1;
67
}}
68
return 0;
69
}
70
71
72
public draw()
73
{
74
new m,win,winname[MAX_PLAYER_NAME],wmes[300],iswin=0;
75
win=random(numrange);
76
SendClientMessageToAll(0xCCFF00,"LOTTERY DRAW-----------");
77
format(wmes,sizeof(wmes),"The winning number is %i",win);
78
SendClientMessageToAll(0xCCFF00,wmes);
79
foreach(m:Player)
80
{
81
if(takenticket[m]==1)
82
{
83
takenticket[m]=0;
84
if(ticketnum[m]==win)
85
{
86
GetPlayerName(m,winname,sizeof(winname));
87
format(wmes,sizeof(wmes),"%s(%i) has win the lottery and gets a total prize of %i $",winname,m,totallotto);
88
SendClientMessageToAll(0xCCFF00,wmes);
89
GivePlayerMoney(m,totallotto);
90
format(wmes,sizeof(wmes),"Congratulations!! You have won total prize of %i $ from lotto",totallotto);
91
SendClientMessage(m,0xCCFF00,wmes);
92
totallotto=lottoadd;
93
format(wmes,sizeof(wmes),"The lotto money has been reseted to %i $",totallotto);
94
SendClientMessageToAll(0xCCFF00,wmes);
95
iswin=1;
96
}
97
ticketnum[m]=20000;//resets the no. if ticket to value that cannot be taken in /ticket
98
}
99
}
100
if(iswin==0)
101
{
102
totallotto+=lottoadd;
103
format(wmes,sizeof(wmes),"No one has won the lottery and the total lotto prize now is %i $",totallotto);
104
SendClientMessageToAll(0xCCFF00,wmes);
105
}
106
return 1;}
107
108
109
CMD:startlotto(playerid,params[])
110
{
111
new startername[MAX_PLAYER_NAME],stri[200];
112
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "{ff0000}You are not authorized to use this command");
113
if(IsLottoStarted==true)return SendClientMessage(playerid, 0xFF4500AA, "Lottery has already been started");
114
IsLottoStarted=true;
115
GetPlayerName(playerid,startername,sizeof(startername));
116
format(stri,sizeof(stri),"%s has started Lottery",startername);
117
SendClientMessageToAll(0xCCFF00,stri);
118
format(stri,sizeof(stri),"It will be drawed after %i minutes.",lottogap);
119
SendClientMessageToAll(0xCCFF00,stri);
120
format(stri,sizeof(stri),"Current lottery is of %i $",lottoadd);
121
SendClientMessageToAll(0xCCFF00,stri);
122
format(stri,sizeof(stri),"Do /ticket [your number] to take a ticket | The number should be in range of 0-%i",numrange);
123
SendClientMessageToAll(0xCCFF00,stri);
124
lotto_timer=SetTimer("draw",1000*60*lottogap,true);
125
return 1;
126
}
127
128
129
CMD:ticket(playerid,params[])
130
{
131
new ru[200],ti;
132
if(IsLottoStarted==false)return SendClientMessage(playerid, 0xFF4500AA, "Lottery has not been started yet.");
133
if(sscanf(params,"i",ti))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage of command | Correct Usage : /ticket [your number]");
134
format(ru,sizeof(ru),"The nuber should be in range of 0-%i",numrange);
135
if(ti > numrange || ti < 0)return SendClientMessage(playerid,0xFF4500AA,ru);
136
format(ru,sizeof(ru),"You need to have %i $ to buy ticket.",ticketprice);
137
if(GetPlayerMoney(playerid)<ticketprice)return SendClientMessage(playerid,0xFF4500AA,ru);
138
if(takenticket[playerid]==1)return SendClientMessage(playerid,0xFF4500AA,"You have already taken a lottrey ticket.");
139
if(IsNumTaken(ti))return SendClientMessage(playerid,0xFF4500AA,"The number has already been chosen by other user. | Please chose other number");
140
takenticket[playerid]=1;
141
GivePlayerMoney(playerid,-ticketprice);
142
ticketnum[playerid]=ti;
143
format(ru,sizeof(ru),"You have chosen %i as your lucky number!!",ti);
144
SendClientMessage(playerid,0xCCFF00,ru);
145
return 1;
146
}
147
148
149
CMD:stoplotto(playerid,params[])
150
{
151
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "{ff0000}You are not authorized to use this command.");
152
if(IsLottoStarted!=true)return SendClientMessage(playerid,0xFF4500AA,"No lottery is currently going on.");
153
new m;
154
IsLottoStarted=false;
155
KillTimer(lotto_timer);
156
SendClientMessageToAll(0xFF4500AA,"The lottery has been stopped by an admin");
157
foreach(m:Player)
158
{
159
takenticket[m]=0;
160
ticketnum[m]=20000;//resets the no. if ticket to value that cannot be taken in /ticket
161
}
162
163
return 1;
164
}
165
166
CMD:lotto(playerid,params[])
167
{
168
if(IsLottoStarted!=true)return SendClientMessage(playerid,0xFF4500AA,"No lottery is currently going on");
169
new rm[200];
170
format(rm,200,"Current lottery prize is %i $",totallotto);
171
SendClientMessage(playerid,0xCCFF00,rm);
172
if(takenticket[playerid]==1)format(rm,200,"Your Current number is %i",ticketnum[playerid]);
173
else format(rm,200,"Do /ticket [your number] to take a lottery ticket",ticketnum[playerid]);
174
SendClientMessage(playerid,0xCCFF00,rm);
175
return 1;
176
}
177
178
CMD:addlotto(playerid,params[])
179
{
180
new adm,oo[120],playername[MAX_PLAYER_NAME];
181
if(IsLottoStarted!=true)return SendClientMessage(playerid,0xFF4500AA,"No lottery is currently going on");
182
if(sscanf(params,"i",adm))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage | Correct Usage : /addlotto [amount of money to add]");
183
if(GetPlayerMoney(playerid)<adm)return SendClientMessage(playerid,0xFF4500AA,"Not enough money to donate.");
184
format(oo,sizeof(oo),"You cannot doante less than %i $.",minlottoadd);
185
if(adm<minlottoadd)return SendClientMessage(playerid,0xFF4500AA,oo);
186
GivePlayerMoney(playerid,-adm);
187
GetPlayerName(playerid,playername,sizeof(playername));
188
format(oo,sizeof(oo),"%s(%i) has doanted %i $ to lottery.",playername,playerid,adm);
189
SendClientMessageToAll(0xCCFF00,oo);
190
totallotto+=adm;
191
format(oo,sizeof(oo),"Now the total lotto prize has become %i $",totallotto);
192
SendClientMessageToAll(0xCCFF00,oo);
193
return 1;
194
}
195
196
CMD:lottohelp(playerid,params[])
197
{
198
new show[300];
199
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");
200
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");
201
ShowPlayerDialog(playerid, 110, DIALOG_STYLE_MSGBOX, "{00BFFF}Available Lottery commands",show, "Cool", "");
202
return 1;
203
}
204
205
/* ===========================================================================================
206
				  ************* Lottery System with ticket number system****************
207
				  ************************MADE BY - BroZeus****************************
208
				  Credits--
209
				  SAMP Team -- For Making SAMP
210
				  YSI       -- For sscanf2 and foreach
211
				  Zeex      -- For ZCMD
212
				  BroZeus   -- For scipting
213
214
				  Please Do Not Remove The Credits Or Redistrubate.
215
==============================================================================================*/