If PlayerName == ?
#1

Hello, Im trying to make that it would check if the player name is same as the name in the talbe.

So I made this stock
Код:
stock pName(playerid)
{
	new Name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, Name, sizeof(Name));
	return Name;
}
then I made this if for deciding if he matches the name or not.

Код:
if(strcmp(pName(playerid), iHos[haI][haOwner], true)==0)
							{
							    new string1[128];
	  							format(string, sizeof(string), "This house belongs to: %f", iHos[haI][haOwner]);
	  							format(string, sizeof(string1), "And its locked!");
								SendClientMessage(playerid, COLOR_RED, string);
								SendClientMessage(playerid, COLOR_RED, string1);
							}
It doesnt work. can someone help me? it compiles but it doesnt work.
Reply
#2

someone?
Reply
#3

Код:
format(string, sizeof(string), "This house belongs to: %f", iHos[haI][haOwner]);
You are setting specifier to a float value, and name is string.
Код:
format(string, sizeof(string), "This house belongs to: %s", iHos[haI][haOwner]);
Reply
#4

Quote:
Originally Posted by dominik523
Посмотреть сообщение
Код:
format(string, sizeof(string), "This house belongs to: %f", iHos[haI][haOwner]);
You are setting specifier to a float value, and name is string.
Код:
format(string, sizeof(string), "This house belongs to: %s", iHos[haI][haOwner]);
I know I fixed that allready The s missspelled, but, it doesnt check if the owner matches the name anyways.
Reply
#5

As I remember, you can not return a string value.
Reply
#6

Quote:
Originally Posted by Anuris
Посмотреть сообщение
As I remember, you can not return a string value.
ahh, daum, is there any way I can set varuble or something for haOwner ?
Reply
#7

pawn Код:
if(strfind(pName(playerid), iHos[haI][haOwner], true) != -1)
Reply
#8

Quote:
Originally Posted by Anuris
Посмотреть сообщение
As I remember, you can not return a string value.
Callbacks can't return string values, stock functions can.
Reply
#9

Quote:
Originally Posted by M0HAMMAD
Посмотреть сообщение
pawn Код:
if(strfind(pName(playerid), iHos[haI][haOwner], true) != -1)
Thanks, can u please explain what the -1 does at this situation? I understand that strfind, finds the the name in the table from haOwner true makes it that if its true, and != not -1? That means if its not -1 letters or sm?
Reply
#10

-1 value is returned if the strings don't match, so he's checking if that doesn't return -1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)