Comparing query result to player name
#1

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
Reply
#2

Bump :/
Reply
#3

pawn Код:
// Inside a callback
mysql_fetch_field_row(save3, "actname");
// Further down
if(!strcmp(save3,GetName(playerid),true,MAX_PLAYER_NAME))
{
    //some code
}
Reply
#4

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?
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)