Comparing query result to player name - 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: Comparing query result to player name (
/showthread.php?tid=391290)
Comparing query result to player name -
DBan - 10.11.2012
I've been trying compare the query result to the player's name, however, the if statement keeps on getting called when it only supposed to be called if the player's name doesn't match the name fetched.
pawn Код:
// Inside a callback
mysql_fetch_field_row(save3, "actname");
// Further down
if(!strcmp(save3, GetName(playerid)))
{
//some code
}
The code above supposed to compare the player's name inside the database to his current name in-game. If it doesn't match, then the server will set his name to the one found inside the database.
I know I must be doing something wrong, but can't put my finger on it. Any suggestions?
Thanks.
-DBan
Re: Comparing query result to player name -
DBan - 12.11.2012
Bump :/
Re: Comparing query result to player name -
Ballu Miaa - 12.11.2012
pawn Код:
// Inside a callback
mysql_fetch_field_row(save3, "actname");
// Further down
if(!strcmp(save3,GetName(playerid),true,MAX_PLAYER_NAME))
{
//some code
}
Re: Comparing query result to player name -
ReneG - 12.11.2012
Keep in mind, strcmp returns 0 if the strings match. So to check if the strings don't match you would do
pawn Код:
if(strcmp(save3, GetName(playerid)))
Also, I've been reading your posts lately and this part doesn't make any sense.
Quote:
The code above supposed to compare the player's name inside the database to his current name in-game. If it doesn't match, then the server will set his name to the one found inside the database.
|
How are you even selecting the row that corresponds to the player?
Re: Comparing query result to player name -
DBan - 12.11.2012
Quote:
Originally Posted by VincentDunn
Keep in mind, strcmp returns 0 if the strings match. So to check if the strings don't match you would do
pawn Код:
if(strcmp(save3, GetName(playerid)))
Also, I've been reading your posts lately and this part doesn't make any sense.
How are you even selecting the row that corresponds to the player?
|
Thanks, didn't realize that.
I have a MySQL system. I'm sending a query (which isnt shown above). It selects the whole user row, then I fetch the data with the function shown above. Pretty simple.