17.03.2013, 19:24
(
Последний раз редактировалось L.Hudson; 02.04.2013 в 11:57.
)
Fixed
CMD:setlotto(playerid, params[])
{
new string[256], lottonum;
if(!IsPlayerLoggedIn(playerid)) return SCM(playerid, COLOR_GREY, "You must be logged in to use commands.");
if(PlayerInfo[playerid][pAdmin] < 5) return SCM(playerid, COLOR_WHITE, "[{FF0606}ERROR{FFFFFF}]: You have no authorization to use this command.");
if(sscanf(params, "d", lottonum)) return SCM(playerid, COLOR_GREY, "USAGE: /setlotto [prize]");
if(lottonum < 10000 || lottonum > 1500000) return SCM(playerid, COLOR_GREY, "Invalid prize number. Prize must be between $10,000 and $1,500,000.");
if(LottoNum != 0) return SCM(playerid, COLOR_GREY, "There is a lottery already going on.");
else
{
SCMTA(COLOR_ORANGE, "A lottery has started and will end in 30 seconds! Type /lotto to pick your number.");
format(string, sizeof(string), "Prize: $%d", lottonum);
SCMTA(COLOR_ORANGE, string);
LottoNum = random(99)+1;
LottoPrize = lottonum;
SetTimer("Lottery", 30000, false);
format(string, sizeof(string), "[OwnerMsg]: The number for lotto is %d.", LottoNum);
SendAdminMessage(COLOR_LIGHTRED, 7, string);
}
return 1;
}
forward Lottery(playerid);
public Lottery(playerid)
{
new name[MAX_PLAYER_NAME], string[256];
format(string, sizeof(string), "The lottery winning number is %d!",LottoNum);
SCMTA(COLOR_ORANGE, string);
foreach(Player, i)
{
//add authorization checks!
if(PlayerInfo[i][pLottoNum] == LottoNum)
{
GetPlayerName(i, name, sizeof(name));
LottoNum = -1;
format(string, sizeof(string), "Congratulations! You have won the lottery of {FFFFFF}$%d.", LottoPrize);
SCM(i, COLOR_GREY, string);
format(string, sizeof(string), "Congratulations to %s! He has won the lottery of $%d!", RPN(i), LottoPrize);
SCMTA(COLOR_ORANGE, string);
GiveZaiatMoney(i, LottoPrize);
LottoPrize = 0;
}
else SCM(i, COLOR_GREY, "You haven't won the lottery! Better luck next time."), PlayerInfo[i][pLottoNum] = 0;
PlayerInfo[i][pLottoNum] = 0;
}
return 1;
}
// ---
foreach(Player, i)
{
GetPlayerName(i, name, sizeof(name));
if(PlayerInfo[i][pLottoNum] == LottoNum)
{
LottoNum = 0;
format(string, sizeof(string), "Congratulations! You have won the lottery of {FFFFFF}$%d.", LottoPrize);
SCM(i, COLOR_GREY, string);
format(string, sizeof(string), "Congratulations to %s! He has won the lottery of $%d!", RPN(i), LottoPrize);
SCMTA(COLOR_ORANGE, string);
GiveZaiatMoney(i, LottoPrize);
LottoPrize = 0;
}
else
{
LottoNum = 0; // This
SCM(i, COLOR_GREY, "You haven't won the lottery! Better luck next time.");
}
PlayerInfo[i][pLottoNum] = 0;
}
forward Lottery(playerid);
public Lottery(playerid)
{
new name[MAX_PLAYER_NAME], string[256];
format(string, sizeof(string), "The lottery winning number is %d!",LottoNum);
SCMTA(COLOR_ORANGE, string);
foreach(Player, i)
{
GetPlayerName(i, name, sizeof(name));
if(PlayerInfo[i][pLottoNum] == LottoNum)
{
format(string, sizeof(string), "Congratulations! You have won the lottery of {FFFFFF}$%d.", LottoPrize);
SCM(i, COLOR_GREY, string);
format(string, sizeof(string), "Congratulations to %s! He has won the lottery of $%d!", RPN(i), LottoPrize);
SCMTA(COLOR_ORANGE, string);
GiveZaiatMoney(i, LottoPrize);
LottoNum = 0;
}
else SCM(i, COLOR_GREY, "You haven't won the lottery! Better luck next time.");
PlayerInfo[i][pLottoNum] = 0;
}
LottoPrize = 0;
return 1;
}