shape1
shape2
shape3
shape4
shape7
shape8

Система "Лотереи" (старая)


ᴅᴀɴʏᴀ

Новичок
Пользователь
26.04.2021
140
3
0
18
Текстдравщик
Данная система включает в себя:​

Игрок покупает лотерейный билет и в PayDay может сорвать джекпот. Если выигравших нет, то сумма джекпота увеличивается. ​

Приступим к коду. ​

Ко всем new: ​

new Bilet[MAX_PLAYERS];
new Jackpot = 0;




Ко всем forward / в начало мода: 

forward Lotto(number);
forward LoadLoto();
forward SaveLoto();




В начало вашего паблик с PayDay: 

new randLoto = random(80);
if(randLoto < 77)
{
randLoto += 3;
}
Lotto(randLoto);




В конец мода: 


Спойлер
public Lotto(number) { new JackpotFallen = 0; new string[256]; new winner[MAX_PLAYER_NAME]; format(string,sizeof(string),"Новости лотто: Выигрышным номером является %i",number); OOCOff(COLOR_WHITE,string); for(new i = 0; i < MAX_PLAYERS; i++) { if(!IsPlayerConnected(i)) continue; if(Bilet > 0) { if(Bilet == number) { JackpotFallen = 1; GetPlayerName(i,winner,sizeof(winner)); format(string,sizeof(string), "Новости лотто: %s выигрывает джекпот %iр",winner,Jackpot); OOCOff(COLOR_WHITE,string); format(string,sizeof(string),"Вы выиграли %iр в лотто",Jackpot); SendClientMessage(i,COLOR_YELLOW,string); GivePlayerMoney(i,Jackpot); } else SendClientMessage(i,COLOR_LIGHTBLUE,"Вы ничего не выиграли."); } Bilet = 0; } if(JackpotFallen) { new rand = random(1250); rand += 1578; Jackpot = rand; SaveLoto(); format(string,sizeof(string),"Новости лотто: джекпот установлен на %i",Jackpot); OOCOff(COLOR_WHITE,string); } else { new rand = random(1500); rand += 2158; Jackpot += rand; SaveLoto(); format(string,sizeof(string),"Новости лотто: джекпот поднялся до %i",Jackpot); OOCOff(COLOR_WHITE,string); } return 1; } public LoadLoto() { new loadloto[16]; new strFromFile2[256]; new File:file = fopen("loto.ini",io_read); if(file) { fread(file,strFromFile2); Jackpot = strval(loadloto); fclose(file); } else GameModeExit(); return 1; } public SaveLoto() { new s[256]; format(s,sizeof(s),"%d",Jackpot); new File:file2 = fopen("loto.ini",io_write); fwrite(file2,s); fclose(file2); return 1; }








 





В OnPlayerCommandText:





 




if(strcmp(cmd, "/lotto", true) == 0)
{
if(!IsPlayerConnected(playerid)) return 1;
if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid,COLOR_GREY,"Билет стоит 100р");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"ИНФО: /lotto [number]");
new lottonr = strval(tmp);
if(lottonr < 1 || lottonr > 80) return SendClientMessage(playerid,COLOR_GREY,"Номер билета не должен превышать 80!");
format(string,sizeof(string),"Вы купили лотерейный билет под номером: %i",lottonr);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
GivePlayerMoney(playerid,-1500);
Bilet[playerid] = lottonr;
return 1;
}


 


UPD: Если кому то нужна будет команда на DC_CMD 

Код:
CMD:lotto(playerid, tmp[])
{
    if(!IsPlayerConnected(playerid)) return 1;
    if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid,COLOR_GREY,"Билет стоит 100р");
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"ИНФО: /lotto [number]");
    new lottonr = strval(tmp);
    if(lottonr < 1 || lottonr > 80) return SendClientMessage(playerid,COLOR_GREY,"Номер билета не должен превышать 80!");
    format(string,sizeof(string),"Вы купили лотерейный билет под номером: %i",lottonr);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    GivePlayerMoney(playerid,-1500);
    Bilet[playerid] = lottonr;
    return 1;
}