If PlayerName == ? - 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)
+--- Thread: If PlayerName == ? (
/showthread.php?tid=545886)
If PlayerName == ? -
TheINCDope - 11.11.2014
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.
Re: If PlayerName == ? -
TheINCDope - 11.11.2014
someone?
Re: If PlayerName == ? -
dominik523 - 11.11.2014
Код:
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]);
Re: If PlayerName == ? -
TheINCDope - 11.11.2014
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.
Re: If PlayerName == ? -
Anuris - 11.11.2014
As I remember, you can not return a string value.
Re: If PlayerName == ? -
TheINCDope - 11.11.2014
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 ?
Re: If PlayerName == ? -
M0HAMMAD - 11.11.2014
pawn Код:
if(strfind(pName(playerid), iHos[haI][haOwner], true) != -1)
Re: If PlayerName == ? -
dominik523 - 11.11.2014
Quote:
Originally Posted by Anuris
As I remember, you can not return a string value.
|
Callbacks can't return string values, stock functions can.
Re: If PlayerName == ? -
TheINCDope - 11.11.2014
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?
Re: If PlayerName == ? -
DavidBilla - 11.11.2014
-1 value is returned if the strings don't match, so he's checking if that doesn't return -1