Help - 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: Help (
/showthread.php?tid=499205)
Help -
Mriss - 07.03.2014
pawn Код:
COMMAND:registeredplayers(playerid, params[])
{
// Setup local variables
new NumPlayers, Msg[128];
// Execute the query to get all ID's from all accounts in table "Accounts"
mysql_function_query("SELECT ID FROM Accounts");
// Store the result
mysql_store_result();
// Count the amount of rows returned in the result
NumPlayers = mysql_num_rows();
// Free the result
mysql_free_result();
format(Msg, sizeof(Msg), "Registered players: %i", NumPlayers);
SendClientMessage(playerid, -1, Msg);
// Let the server know that this was a valid command
return 1;
}
Errors
Код:
(1166) : error 035: argument type mismatch (argument 1)
Line 1166
pawn Код:
mysql_function_query("SELECT ID FROM Accounts");
Re: Help -
RajatPawar - 07.03.2014
pawn Код:
mysql_function_query("SELECT ID FROM Accounts")
is a threaded query. I am not sure if you can use store result, etc on that.
pawn Код:
CMD:...()
{
mysql_function_query(connectionHandle, "SELECT COUNT(ID) FROM Accounts", true, "OnReturnNums", "d", playerid);
}
forward OnReturnNums(playerid);
public OnReturnNums(playerid)
{
new rows, fields, Msg[40];
cache_get_data(rows, fields, connectionHandle);
format(Msg, sizeof(Msg), "Registered players: %i", rows);
SendClientMessage(playerid, -1, Msg);
return 1;
}
Use cache to get the data. Use COUNT() instead of SELECT * FROM to save memory and time.
I am assuming you know your connectionHandle and some code is assumed to be known.
Cheers
Re: Help -
Mriss - 07.03.2014
cnr.pwn(1162) : error 017: undefined symbol "connectionHandle"
cnr.pwn(1169) : error 017: undefined symbol "connectionHandle"
Re: Help -
RajatPawar - 07.03.2014
Replace it by the connection you made to the database under OnGameModeInit or under OnFilterScriptInit!
pawn Код:
new connection = mysql_connect(..);
Re: Help -
Mriss - 07.03.2014
this is my connection
pawn Код:
mysql_connect(mysql_host,mysql_user,mysql_db,mysql_pass);