21.03.2013, 20:21
If you're already using threaded queries (which is the only type R7 supports) I recommend updating to R15 as it adds a couple of extra features and fixed some bugs.
/rant
Now ontopic: You're using mysql_num_rows inside OnPlayerConnect. mysql_num_rows retrieves the number of rows from a result set after sending a SELECT or SHOW query. You'll need to send a SELECT query to check for the player in the table, then in the callback (which you specify) you can use cache_get_data to retrieve the data and check for rows.
https://sampforum.blast.hk/showthread.php?tid=390428 Here's an example gamemode using this method. I recommend reading it - it helped me a lot!
Summary:
Send a SELECT query in OnPlayerConnect:
Check rows in the specified callback (OnUserCheck):
And that's about it. Keep in mind that this is just a very very rough example.
You should read this tutorial: https://sampforum.blast.hk/showthread.php?tid=337810 on using cache in R7 and newer
/rant
Now ontopic: You're using mysql_num_rows inside OnPlayerConnect. mysql_num_rows retrieves the number of rows from a result set after sending a SELECT or SHOW query. You'll need to send a SELECT query to check for the player in the table, then in the callback (which you specify) you can use cache_get_data to retrieve the data and check for rows.
https://sampforum.blast.hk/showthread.php?tid=390428 Here's an example gamemode using this method. I recommend reading it - it helped me a lot!
Summary:
Send a SELECT query in OnPlayerConnect:
pawn Код:
new
szQuery[ 90 ]
;
format( szQuery, sizeof( szQuery ), "SELECT * from `your_table_here` WHERE `name` = '%s' LIMIT 1", Name( playerid ));
mysql_function_query( handle, szQuery, true, "OnUserCheck", "i", playerid );
pawn Код:
forward OnUserCheck(playerid);
public OnUserCheck(playerid)
{
new
rows,
fields
;
cache_get_data( rows, fields, handle );
if( rows )
{
// exists - player should log in
}
else
{
// doesn't exist - player should register
}
return true;
}
You should read this tutorial: https://sampforum.blast.hk/showthread.php?tid=337810 on using cache in R7 and newer