Help in converting(+rep) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help in converting(+rep) (
/showthread.php?tid=637903)
Help in converting(+rep) -
bugmenotlol - 23.07.2017
Hi all
I am Changing my old commands to zcmd
so i have ended up with having errors:
PHP код:
C:\Users\Farha\Desktop\New Server\CNRSF\pawno\include\cnr/lotto.inc(81) : error 017: undefined symbol "strtok"
C:\Users\Farha\Desktop\New Server\CNRSF\pawno\include\cnr/lotto.inc(81) : error 033: array must be indexed (variable "cmds")
C:\Users\Farha\Desktop\New Server\CNRSF\pawno\include\cnr/lotto.inc(83) : error 017: undefined symbol "strtok"
C:\Users\Farha\Desktop\New Server\CNRSF\pawno\include\cnr/lotto.inc(83) : error 033: array must be indexed (variable "dir")
C:\Users\Farha\Desktop\New Server\CNRSF\pawno\include\cnr/lotto.inc(80) : warning 203: symbol is never used: "idxs"
My code is this
PHP код:
CMD:lotto(playerid, params[])
{
new cmds[256];
new idxs;
cmds = strtok(cmdtext, idxs);
new dir[256];
dir = strtok(cmdtext, idxs);
if (!strlen(dir))
{
SendClientMessage(playerid, COLOR_RED, "SYNTAX: /lotto [number]");
return 1;
}
new number = strval(dir);
if (LottoParticipant[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You already have a lotto ticket.");
}
else
{
if (GetPlayerMoney(playerid) >= LOTTO_PRICE)
{
if (number > 0 && number < 100)
{
if (NumberUsed[number] == 0)
{
new strings[256];
format(strings, sizeof(strings), "You have purchased the lotto number %d and you have been charged $5000 for the ticket.", number);
SendClientMessage(playerid,COLOR_YELLOW,strings);
SendClientMessage(playerid,COLOR_YELLOW,"Draw will commence at 06:00 and 18:00.");
PlayerLottoGuess[playerid] = number;
LottoParticipant[playerid] = 1;
takeMoney(playerid,5000);
}
else
{
SendClientMessage(playerid, COLOR_RED, "The number you selected is already choosed by another player.");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "The number you entered is invalid, please type a number between 0 and 98.");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You do not have enought money to buy a lotto ticket.");
}
}
return 1;
}
Re: Help in converting(+rep) -
Ebisu - 23.07.2017
Use sscanf, It'll be easier
Код:
CMD:lotto(playerid, params[])
{
new number;
if (sscanf(params, "i", number)) return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /lotto [number]");
if (LottoParticipant[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You already have a lotto ticket");
if (GetPlayerMoney(playerid) < LOTTO_PRICE) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money");
if (number < 0 || number > 100) return SendClientMessage(playerid, COLOR_RED, "ERROR: Choose a number between 0 and 100");
if (NumberUsed[number] == 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: This number is already taken");
new strings[256];
format(strings, sizeof(strings), "You have purchased the lotto number %d and you have been charged $5000 for the ticket.", number);
SendClientMessage(playerid,COLOR_YELLOW,strings);
SendClientMessage(playerid,COLOR_YELLOW,"Draw will commence at 06:00 and 18:00.");
PlayerLottoGuess[playerid] = number;
LottoParticipant[playerid] = 1;
takeMoney(playerid,5000);
return 1;
}
Re: Help in converting(+rep) -
RomaNScripteR - 23.07.2017
Quote:
Originally Posted by Ebisu
Use sscanf, It'll be easier
|
Exactly, I also uses sscanf
Re: Help in converting(+rep) -
bugmenotlol - 23.07.2017
thnx
++ reped