Error, Array.
#1

pawn Код:
if(HQInfo[i][Owner] == pname)
Код:
error 033: array must be indexed (variable "pname")
It's quite obvious what I'm trying to do: I'm trying to make it check if HQ[i][Owner] is the players name.
Reply
#2

lol, use strcmp.

EDIT:
pawn Код:
if(!strcmp(HQInfo[i][Owner], pname, true))
{
        // the same name
}
else
{
        // not the same name
}
Reply
#3

if(strcmp(HQInfo[i][Owner],pname)) doesn't work Guess I'm failing.

Edit: Atleast it says that I'm not the owner even though I am
Reply
#4

Quote:
Originally Posted by oliverrud
Посмотреть сообщение
if(strcmp(HQInfo[i][Owner],pname)) doesn't work Guess I'm failing.

Edit: Atleast it says that I'm not the owner even though I am
strcmp works %100 fine.
There's something wrong with the values in it.
Reply
#5

Found a solution, just had to change it.
pawn Код:
if(strcmp(HQInfo[i][Owner],pname))
                {
                    // Right Message if owner
                }
                else
                {
                       // Wrong message if not owner
                }
Just replaced that with:

pawn Код:
if(strcmp(HQInfo[i][Owner],pname))
                {
                    // wrong message if not owner
                }
                else
                {
                       // right message if owner
                }
Reply
#6

Did you use the '!' (not) or '== 0'? strcmp does return 0, if the strings are identical.

EDIT: Ok, your other solution is possible, too.
Reply
#7

Yea should have used the ! now that your saying it anyways got it fixed, thanks to you both!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)