PDA

View Full Version : Mysql help


zeth98
13/06/2015, 10:29 AM
Hello i want to make this command,
To show me the name of player who have "Leader" = 2
But not working i don't know very good mysql,

if(strcmp(cmd, "/leader2", true) == 0)
{
mysql_query("SELECT NULL FROM players WHERE Leader=2");
mysql_store_result();
mysql_free_result();
new result[50];
mysql_fetch_field_row(result,"username");
format(string, sizeof(string), " %s Leader 2",result);
SendClientMessage(playerid,-1,string);
}

zeth98
13/06/2015, 01:10 PM
up everybody know?

Konstantinos
13/06/2015, 01:14 PM
http://wiki.sa-mp.com/wiki/MySQL#mysql_retrieve_row

zeth98
13/06/2015, 01:39 PM
i don't understand, how can take the name of player that command?

Konstantinos
13/06/2015, 01:46 PM
You should select the player's name (the field of it and not NULL) and then as there might be more than 1 row, you use the loop with the function I linked above and then mysql_fetch_field_row (http://wiki.sa-mp.com/wiki/MySQL#mysql_fetch_field_row) to get the data.

Though the version of the plugin plugin you use is very outdated, it's better to learn how to use threaded queries and update to R39-3.

zeth98
13/06/2015, 02:01 PM
But i have mysql r5 i can't update because i don't know how
And give many error :|
error 017: undefined symbol "mysql_store_result"
error 017: undefined symbol "mysql_free_result"
error 017: undefined symbol "mysql_ping"
error 017: undefined symbol "mysql_fetch_row"
error 017: undefined symbol "mysql_retrieve_row"
error 017: undefined symbol "mysql_fetch_field_row"