[SOLVED]name1 == name2 - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED]name1 == name2 (
/showthread.php?tid=94796)
[SOLVED]name1 == name2 -
kevin974 - 01.09.2009
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;
}
Re: name1 == name2 -
Norn - 01.09.2009
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 ==..
Re: name1 == name2 -
Backwardsman97 - 01.09.2009
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;
}
Re: name1 == name2 -
kevin974 - 01.09.2009
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
Re: name1 == name2 -
kevin974 - 01.09.2009
Also how do i make it so if they dont equal each other?
Re: name1 == name2 -
JaTochNietDan - 01.09.2009
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)