PDA

View Full Version : Help in converting(+rep)


bugmenotlol
23/07/2017, 03:54 PM
Hi all
I am Changing my old commands to zcmd
so i have ended up with having errors:

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
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;
}

Ebisu
23/07/2017, 04:03 PM
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;
}

RomaNScripteR
23/07/2017, 04:21 PM
Use sscanf, It'll be easier

Exactly, I also uses sscanf

bugmenotlol
23/07/2017, 04:26 PM
thnx
++ reped