Quote:
Originally Posted by Phreak
PHP код:
new playerName[MAX_PLAYER_NAME];
new query[128];
GetPlayerName(playerid, playerName, sizeof playerName);
mysql_format(db, query, sizeof query, "INSERT INTO `crimes` (`playername`, `commitedcrime`) VALUES ('%e', '%e')", playerName, commitedCrime); // commitedCrime would be the variable where you'd store the crime that the player has commited
mysql_tquerry(db, query);
And when you wanna show the dialog.
PHP код:
new playerName[MAX_PLAYER_NAME];
new query[128];
GetPlayerName(playerid, playerName, sizeof playerName);
mysql_format(db, query, sizeof query, "SELECT * FROM `crimes` WHERE `playername` = '%e'", playerName);
mysql_tquery(db, query, "CrimeCallback");
forward CrimeCallback();
public CrimeCallback(){
new rows_found = cache_num_rows();
if(rows_found > 0){
new crimesArray[rows_found]; // max number of crimes to be shown in the brackets
for(var i=0; i<rows_found;i++){
cache_get_value_name(i, "commitedcrime", crimesArray[i], max_size_of_crime);
}
format(bla bla bla, crimesArray[0],crimesArray[1]...);
ShowPlayerDialog(bla bla bla, the_formatted_string);
} else {
ShowPlayerDialog(bla bla bla, "No crimes commited");
}
}
And if this doesn't work straight away you may have to save the cache and activate it first.
|
That doesnt work, because cache_get_value_name is not defined and rows_found is an error