Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #define MAX_NUMBER 50
- #define SendClientMessage SCM
- #define SendClientMessageToAll SCMTA
- #define LottoOff !LottoNumbers[0]
- #define LottoOn LottoNumbers[0]
- new LottoNumbers[MAX_NUMBER+1];
- new string[48];
- new LottoPrize;
- new LottoTimer;
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[15],num,idx;
- cmd = strtok(cmdtext,idx);
- num = strval(strtok(cmdtext,idx));
- if (strcmp("/startlotto", cmd, true)) {
- if(LottoOn) return SCM(playerid,-1,"The lotto is active already");
- else if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1,"you don't have rcon access");
- else if(num <= 0) return SCM(playerid,-1,"please write win prize ( /startlotto < prize > )");
- for(new i=1;i < 51;i++) LottoNumbers[i] = -1;
- LottoNumbers[0] = 1;
- LottoPrize = num;
- SCMTA(-1,"lotto is active please register with the command : /lotto < number >");
- LottoTimer = SetTimer("EndLotto",30000,false);
- return 1;
- }
- else if(strcmp("/stoplotto", cmdtext,true)) {
- if(LottoOff) return SCM(playerid, -1,"The lotto is Off already");
- else if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1,"you don't have rcon access");
- LottoNumbers[0] = 0;
- KillTimer(LottoTimer);
- return SCMTA(-1,"The admin is stopped the lotto");
- }
- else if(strcmp("/lotto", cmd,true)) {
- if(LottoOff) return SCM(playerid, -1,"The lotto is Off already");
- format(string,48,"/lotto < 1-%d >",MAX_NUMBER);
- if(num <= 1) return SCM(playerid,-1,string);
- new lotto = GetPVarInt("lotto");
- if(LottoNumbers[lotto] == playerid) return SCM(playerid,-1,"you already registered");
- LottoNumbers[num] = playerid;
- SetPvarInt("lotto",num);
- return SCM(playerid,-1,"you registerd to the lotto");
- }
- return 0;
- }
- forward EndLotto();
- public EndLotto() {
- new winner = random(50)+1;
- GivePlayerMoney(LottoNumbers[winner],LottoPrize);
- LottoNumbers[0] = 0;
- return SCMTA("for the lotto has a winner... ");
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement