Need help with idx - 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: Need help with idx (
/showthread.php?tid=474791)
Need help with idx -
D3vin - 09.11.2013
I need some help understanding the following errors with my Command
Код:
error 017: undefined symbol "length"
error 029: invalid expression, assumed zero
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Код:
CMD:reportbug(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pBugMuted] == 1)
{
return SendClientMessage(playerid, COLOR_GREY, " You are banned from using /reportbug ! ");
}
if(JustBugReported[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, " Wait 20 seconds after sending a next bug report ! ");
return 1;
}
strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
//new length = strlen;
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /reportbug [text]");
return 1;
}
JustBugReported[playerid] = 1;
SetTimerEx("BugReportReset", 20000, false, "i", playerid);
format(string, sizeof(string), "Bug Report From [%d]%s: %s",playerid, sendername, (result));
SendTesterMessage(SCOLOR_GREEN, string);
SendClientMessage(playerid, COLOR_YELLOW, "Your bug report message was sent to the online testers, thank you.");
}
return 1;
}
Giving +REP for quick replies and help
Re: Need help with idx -
DanishHaq - 09.11.2013
Just use sscanf.
Re: Need help with idx -
Konstantinos - 09.11.2013
Do NOT use strtok for that. Use sscanf for parameters, though in your case is not needed.
pawn Код:
CMD:reportbug(playerid, params[])
{
if(PlayerInfo[playerid][pBugMuted] == 1) return SendClientMessage(playerid, COLOR_GREY, " You are banned from using /reportbug ! ");
if(JustBugReported[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, " Wait 20 seconds after sending a next bug report ! ");
if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /reportbug [text]");
strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
JustBugReported[playerid] = 1;
SetTimerEx("BugReportReset", 20000, false, "i", playerid);
format(string, sizeof(string), "Bug Report From [%d]%s: %s",playerid, sendername, params);
SendTesterMessage(SCOLOR_GREEN, string);
SendClientMessage(playerid, COLOR_YELLOW, "Your bug report message was sent to the online testers, thank you.");
return 1;
}
Assuming string and sendername are declared as global according to your command.
Re: Need help with idx -
D3vin - 09.11.2013
Alright thanks for your help