Arrays - 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: Arrays (
/showthread.php?tid=573947)
Arrays -
arjanforgames - 11.05.2015
So I have an annoying issue with arrays here.
I'm using FCNPC and I need to acquire the NPC name and match it with a string.
ERROR:
pawn Код:
error 033: array must be indexed (variable "targetName")
This is the code I'm using:
pawn Код:
new targetPlayer, targetName[64];
targetPlayer = GetClosestBot(playerid, 1.5);
format(targetName, 64, "%s", npcInfo[targetPlayer][Name]);
if(targetName == "dopgs9NPC") {}
The error line is:
pawn Код:
if(targetName == "dopgs9NPC")
My (almost empty and useless) enum:
pawn Код:
enum botDataEnum
{
Name[64]
}
new npcInfo[MAX_PLAYERS][botDataEnum];
Re: Arrays -
Crayder - 11.05.2015
if(targetName == "dopgs9NPC")
>>
if(!strcmp(targetName, "dopgs9NPC"))
Re: Arrays -
arjanforgames - 11.05.2015
Quote:
Originally Posted by Crayder
if(targetName == "dopgs9NPC")
>>
if(!strcmp(targetName, "dopgs9NPC"))
|
Thank you very much.
Re: Arrays -
Crayder - 11.05.2015
Quote:
Originally Posted by arjanforgames
Thank you very much.
|
Easy fix, keep learning! This was just basics...