#1

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");
Reply
#2

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

cnr.pwn(1162) : error 017: undefined symbol "connectionHandle"
cnr.pwn(1169) : error 017: undefined symbol "connectionHandle"
Reply
#4

Replace it by the connection you made to the database under OnGameModeInit or under OnFilterScriptInit!

pawn Код:
new connection = mysql_connect(..);
Reply
#5

this is my connection

pawn Код:
mysql_connect(mysql_host,mysql_user,mysql_db,mysql_pass);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)