Slawon
Компетентный
Привет всем в этом уроке я вам раскожу как сделать лотерею от администратора
И так начнем
К New
Ко всем forward
Ко всем enum pInfo
В public OnPlayerConnect
в public OnPlayerCommandText(playerid, cmdtext[]) добавляем
В конец мода
Автор Saimon_Jones
И так начнем
К New
PHP:
new Jackpot = 0;
PHP:
forward Lotto(number);
PHP:
pLottoNr
PHP:
PlayerInfo[playerid][pLottoNr] = 0;
в public OnPlayerCommandText(playerid, cmdtext[]) добавляем
PHP:
if(strcmp(cmd, "/lotto", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pLottoNr] > 0)
{
SendClientMessage(playerid, COLOR_GREY, " У вас уже есть лотерейный билет!");
return 1;
}
if(GetPlayerMoney(playerid) < 1500)
{
SendClientMessage(playerid, COLOR_GREY, " Недостаточно денег (1500$)!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE," Используйте : /lotto [number]");
return 1;
}
new lottonr = strval(tmp);
if(lottonr < 1 || lottonr > 20) { SendClientMessage(playerid, COLOR_GREY, " Число может быть от 1 до 20!"); return 1; }
format(string, sizeof(string),"ВЫ купили билет под номером %d.", lottonr);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
NormMoney[playerid] = 2;
AntiMoney[playerid] = AntiMoney[playerid] - 1500;
GiveMoney(playerid, - 1500);
PlayerInfo[playerid][pLottoNr] = lottonr;
}
return 1;
}
if(strcmp(cmd, "/startlotto", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] > 6)
{
format(string, sizeof(string), "Лотерея началась!");
OOCOff(COLOR_WHITE, string);
new rand = random(20) + 1;
Lotto(rand);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " ВЫ не админ!");
return 1;
}
}
return 1;
}
PHP:
public Lotto(number)
{
new JackpotFallen = 0;
new string[256];
new winner[MAX_PLAYER_NAME];
format(string, sizeof(string), "Сегодня выйграл номер %d", number);
OOCOff(COLOR_WHITE, string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pLottoNr] > 0)
{
if(PlayerInfo[i][pLottoNr] == number)
{
JackpotFallen = 1;
GetPlayerName(i, winner, sizeof(winner));
format(string, sizeof(string), "%s выйграл $%d", winner, Jackpot);
OOCOff(COLOR_WHITE, string);
format(string, sizeof(string), "Вы выйграли $%d ", Jackpot);
SendClientMessage(i, COLOR_YELLOW, string);
ConsumingMoney[i] = 1;
NormMoney[i] = 2;
AntiMoney[i] = AntiMoney[i] + Jackpot;
GiveMoney(i, Jackpot);
}
else
{
SendClientMessage(i, COLOR_LIGHTBLUE, "Ваш билет проиграл.");
}
}
PlayerInfo[i][pLottoNr] = 0;
}
}
if(JackpotFallen)
{
new rand = random(125000); rand += 15789;
Jackpot = rand;
SaveStuff();
format(string, sizeof(string), "Установлен новый джекпот $%d.", Jackpot);
OOCOff(COLOR_WHITE, string);
}
else
{
new rand = random(15000); rand += 2158;
Jackpot += rand;
SaveStuff();
format(string, sizeof(string), "Джекпот поднят до $%d.", Jackpot);
OOCOff(COLOR_WHITE, string);
}
return 1;
}
public DelP(playerid)
{
return 1;
}
