05.04.2013, 16:27
Can someone help me to convert this fs to ZCMD i dont know because i am beginner.
Код:
#include <a_samp> #define FILTERSCRIPT #pragma tabsize 0 #define COLOR_RED 0xAA3333AA #define LOTTO_PRICE 2000 //price of lotto ticket #define MAX_LOTTO_JACKPOT_INCREASE 20 //jackpot grows every second with a random value, which can not be bigger than stated here new LottoParticipant[MAX_PLAYERS]; new PlayerLottoGuess[MAX_PLAYERS]; new NumberUsed[99]; new LottoJackpot = 1; forward public LottoDraw(); forward public LottoJackpotIncrease(); forward public Warning1(); forward public Warning2(); forward public Warning3(); forward public Warning4(); public OnFilterScriptInit() { print("\nLotto filterscript by player007\n"); SetTimer("LottoJackpotIncrease", 1000, 1); SetTimer("LottoDraw", 1440000, 1); SetTimer("Warning1", 360000, 0); return 1; } public OnFilterScriptExit() { return 1; } public OnPlayerRequestSpawn(playerid) { return 1; } public OnPlayerConnect(playerid) { SendClientMessage(playerid, COLOR_RED, "Use /lotto in your local 24/7 to buy a lotto ticket. Use /jackpot to check the current jackpot."); return 1; } public OnPlayerDisconnect(playerid, reason) { return 1; } public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) { if (newinteriorid == 17 || newinteriorid == 10 || newinteriorid == 18 || newinteriorid == 16 || newinteriorid == 6 || newinteriorid == 4) { SendClientMessage(playerid, COLOR_RED, "Type /lotto [number] to buy a lotto ticket, and /jackpot to see today's jackpot."); } return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256]; new idx; cmd = strtok(cmdtext, idx); if (strcmp(cmd, "/lotto", true) == 0) { new dir[256]; dir = strtok(cmdtext, idx); if (!strlen(dir)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /lotto [number]"); return 1; } new number = strval(dir); new interior = GetPlayerInterior(playerid); if (interior == 17 || interior == 10 || interior == 18 || interior == 16 || interior == 6 || interior == 4) { if (LottoParticipant[playerid] == 1) { SendClientMessage(playerid, COLOR_RED, "You have already guessed a number for today."); } else { if (GetPlayerMoney(playerid) >= LOTTO_PRICE) { if (number > 0 && number < 100) { if (NumberUsed[number] == 0) { new string[256]; format(string, sizeof(string), "~w~Your lotto number is:~g~ %d ~w~.", number); GameTextForPlayer(playerid, string, 4000, 3); PlayerLottoGuess[playerid] = number; LottoParticipant[playerid] = 1; GivePlayerMoney(playerid, -LOTTO_PRICE); } else { SendClientMessage(playerid, COLOR_RED, "The number you selected is already used."); } } else { SendClientMessage(playerid, COLOR_RED, "The number you entered is invalid, please type a number between 0 and 99."); } } else { SendClientMessage(playerid, COLOR_RED, "You do not have enought money to buy a lotto ticket."); } } } else { SendClientMessage(playerid, COLOR_RED, "You can buy lotto tickets only in 24/7 shops."); } return 1; } if (strcmp(cmd, "/jackpot", true) == 0) { new string[256]; format(string, sizeof(string), "Current jackpot is: %d.", LottoJackpot); SendClientMessage(playerid, COLOR_RED, string); return 1; } if (strcmp(cmd, "/resetjackpot", true) == 0) { if (IsPlayerAdmin(playerid)) { ResetJackpot(); SendClientMessage(playerid, COLOR_RED, "Jackpot set to 0."); } else { SendClientMessage(playerid, COLOR_RED, "Only admins can reset the lotto jackpot. See /lottocommands."); } return 1; } if (strcmp(cmd, "/lottocommands", true) == 0) { if (IsPlayerAdmin(playerid)) { SendClientMessage(playerid, COLOR_RED, "Lotto filterscript made by player007."); SendClientMessage(playerid, COLOR_RED, "/lotto [number] (only in 24/7 shops), /jackpot (see today's jackpot)"); SendClientMessage(playerid, COLOR_RED, "Admins can also use /resetjackpot to reset the jackpot (set it to 0)."); } else { SendClientMessage(playerid, COLOR_RED, "Lotto filterscript made by player007."); SendClientMessage(playerid, COLOR_RED, "/lotto [number] (only in 24/7 shops), /jackpot (see today's jackpot)"); } return 1; } return 0; } 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; } public LottoJackpotIncrease() { LottoJackpot = LottoJackpot+random(MAX_LOTTO_JACKPOT_INCREASE); } public LottoDraw() { new LottoWinningNumber = random(99)+1; new IsThereAWinner = 0; new WinnerID; new WinnerName[MAX_PLAYER_NAME]; new tempJackpot = LottoJackpot; for (new i = 0; i < MAX_PLAYERS; i++) { if (LottoParticipant[i] == 1) { if (PlayerLottoGuess[i] == LottoWinningNumber) { IsThereAWinner = 1; WinnerID = i; GetPlayerName(i, WinnerName, sizeof(WinnerName)); GivePlayerMoney(i, LottoJackpot); ResetJackpot(); } } } if (IsThereAWinner == 1) { new string[256], string2[256]; format(string, sizeof(string), "Today's winner is %s (%d), who has recieved today's jackpot, $%d! Winning number: %d.", WinnerName, WinnerID, tempJackpot, LottoWinningNumber); format(string2, sizeof(string2), "Buy a ticket for tomorrow's lotto drawing in your local 24/7 with /lotto [number] command!"); SendClientMessageToAll(COLOR_RED, string); SendClientMessageToAll(COLOR_RED, string2); } if (IsThereAWinner == 0) { new string[256], string2[256]; format(string, sizeof(string), "We have no winner for today, so the jackpot remains $%d! Today's winning number was: %d.", LottoJackpot, LottoWinningNumber); format(string2, sizeof(string2), "Buy a ticket for tomorrow's lotto drawing in your local 24/7 with /lotto [number] command!"); SendClientMessageToAll(COLOR_RED, string); SendClientMessageToAll(COLOR_RED, string2); } ResetLotto(); } stock ResetLotto() { for (new i = 0; i < MAX_PLAYERS; i++) { LottoParticipant[i] = 0; PlayerLottoGuess[i] = 0; } for (new number = 0; number < 99; number++) { NumberUsed[number] = 0; } } stock ResetJackpot() { LottoJackpot = 0; } public Warning1() { GameTextForAll("~w~Only ~g~18 ~w~hours til next lotto number picking! Buy a lotto ticket at your local 24/7 store!", 6500, 3); new string[256]; format(string, sizeof(string), "~n~~w~Today's jackpot is: ~g~$%d~w~.", LottoJackpot); SetTimer("Warning2", 360000, 0); } public Warning2() { GameTextForAll("~w~Only ~g~12 ~w~hours til next lotto number picking! Buy a lotto ticket at your local 24/7 store!", 6500, 3); new string[256]; format(string, sizeof(string), "~n~~w~Today's jackpot is: ~g~$%d~w~.", LottoJackpot); SetTimer("Warning3", 360000, 0); } public Warning3() { GameTextForAll("~w~Only ~g~6 ~w~hours til next lotto number picking! Buy a lotto ticket at your local 24/7 store!", 6500, 3); new string[256]; format(string, sizeof(string), "~n~~w~Today's jackpot is: ~g~$%d~w~.", LottoJackpot); SetTimer("Warning4", 360000, 0); } public Warning4() { SetTimer("Warning1", 360000, 0); }