[SOLVED]name1 == name2
#1

I am trying to check if my players name is == to a name that i am getting from a dini variable.

Код:
if(HouseInfo[h][hName] == GetName(playerid))
{
}
But instead i get: error 033: array must be indexed (variable "GetName")



Код:
Other fuctions:
stock GetName(playerid)
{
	new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name));
	return name;
}
Reply
#2

pawn Код:
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0)
{
}
It's pretty obvious that it won't work the way you did it, you can't compare strings by simply ==..
Reply
#3

I was gonna say that. But anyway, here's a better version of your GetName function.

pawn Код:
stock ReturnPlayerName(playerid) //By Alex "******" Cole
{
    new pname[MAX_PLAYER_NAME];
    pname="Invalid PlayerID";
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, pname, sizeof (pname));
    }
    return pname;
}
Reply
#4

Lol, i cannot believe i didn't realize how to do that before. Maby am getting lazy or somthing.

But thanks both you guys works perfectly
Reply
#5

Also how do i make it so if they dont equal each other?
Reply
#6

Quote:
Originally Posted by kevin974
Also how do i make it so if they dont equal each other?
Please don't double post, use the edit button provided.

You can do it like so:
pawn Код:
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) != 0)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)