Inside the processing for the /trackperson command{
...
new query[128],opname[24];
GetPlayerName(otherplayerID,opname,sizeof(opname));
mysql_format(connection, query,"SELECT `times arrested`, `number of crimes`,.... FROM `PlayersTable` WHERE `Username`='%s' LIMIT 0,1",opname);
/*
Connection = The connection to the mysql server (connection ID 1 by default)
The query selects all the data you wish to display for the police officer, which is in the mysql table
OtherplayerID=The ID of the player that the cop wishes to track
*/
mysql_function_query(connection,query,true, "TrackQuery","i",playerid);
//This'll run the query using a thread and caching
//It will require the ID of the player who SENT the command, so the information can be sent to them
}
forward TrackQuery(playerid);
public TrackQuery(playerid){
new rows,fields;
cache_get_rows(rows,fields);
if(!rows)SendClientMessage(playerid,0xFF0000FF,"No data was found on that player!";
else {
new timesArrested,num_of_crimes,temp[11];
cache_get_field_content(0,"Times Arrested",temp),timesArrested=strval(temp);
cache_get_field_content(0,"Number Of Crimes",temp),num_of_crimes=strval(temp);
new str[128];
format(str,128,"That player has committed %d crimes and has been arrested %d times",timesArrested,num_of_crimes);
SendClientMessage(playerid,0xFFFFFFFF,str);
}
return 1;
}
No problem. I am new to using mysql in SA:MP mysql.
(I assume you are using BlueG's plugin) I found this useful topic on caching/threading queries: https://sampforum.blast.hk/showthread.php?tid=337810 If you need additional information there is the wiki: https://sampwiki.blast.hk/wiki/MySQL and the original topic: https://sampforum.blast.hk/showthread.php?tid=56564 |