Hello there.
sscanf is used to seperate a string of text into multiple variables, mostly by finding spaces between each parameter.
If you load all of a player's data from the mysql database into variables when they connect, you can just display those variables (as long as they are updated when the player may change on of them).
If however you wish to retrieve the information for your /trackperson command with a mysql query, then the following will work:
(you will need to update the appropriate sections though)
pawn Код:
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;
}
That code is untested (mainly because I don't have the required tables or command.
You will need to modify it yourself, so hopefully if I have made any mistakes you will notice them.