Arrays
#1

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];
Reply
#2

if(targetName == "dopgs9NPC")

>>

if(!strcmp(targetName, "dopgs9NPC"))
Reply
#3

Quote:
Originally Posted by Crayder
Посмотреть сообщение
if(targetName == "dopgs9NPC")

>>

if(!strcmp(targetName, "dopgs9NPC"))
Thank you very much.
Reply
#4

Quote:
Originally Posted by arjanforgames
Посмотреть сообщение
Thank you very much.
Easy fix, keep learning! This was just basics...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)