error 033: array must be indexed - 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: error 033: array must be indexed (
/showthread.php?tid=489358)
error 033: array must be indexed -
zachemicals - 22.01.2014
error:
Код:
C:\Users\user\samp\samp\filterscripts\project.pwn(4857) : error 033: array must be indexed (variable "TargetID")
line:
Код:
if(TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID)) return SendClientMessage(playerid, COLOR_RED, "*Player Is Not Connected.");
Also another one I need help with
error:
Код:
project.pwn(4862) : error 035: argument type mismatch (argument 1)
line:
Код:
GetPlayerName(TargetID,targetname,24);
another line with the same error:
Код:
KickWithMessage(TargetID,"You have been kicked from this server.");
Here is the whole section
Код:
dcmd_kick(playerid, params[])
{
new TargetID[64];
if(pInfo[playerid][Adminlevel] < 2) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE"");
if(sscanf(params, "us", TargetID)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /kick [id]");
if(TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID)) return SendClientMessage(playerid, COLOR_RED, "*Player Is Not Connected.");
else
{
new str1[128];
new targetname[MAX_PLAYER_NAME];
GetPlayerName(TargetID,targetname,24);
format(str1,sizeof(str1),"**KICK: %s (%d) Reason: %s", targetname, TargetID);
SendClientMessageToAll(COLOR_HOTPINK, str1);
KickWithMessage(TargetID,"You have been kicked from this server.");
print(str1);
}
return 1;
}
thanks
Re: error 033: array must be indexed -
PowerPC603 - 22.01.2014
You defined TargetID as an array, while you're using it as an integer.
This will fix it.
Also, I noticed you supplied sscanf to extract a playerid AND a string ("us"), but you only specified TargetID to store the data.
Just removed the "s" from it.