How can i make an police wanted file? -
ImTobi - 25.04.2018
I want an police wanted file, like wenn ich do "/akte (German) PlayerName", then an Dialog should appear where all crimes that he did in the past are listed.
But i don't want 4 fields in my MYSQL Table with "file1, file2,file3,file4" and so one or crime1 2 3 4, but something, that creates an entry in the table, that you can see in the dialog. But i must save it somewhere in my enum, but i don't know how
Re: How can i make an police wanted file? -
jasperschellekens - 25.04.2018
Create a new table called crimes or something.
Add 2 fields. ID or playername and a field maybe called crime.
Now save the crime in the crime field and the name/userid into the other field.
You can then select them like this:
PHP код:
SELECT * FROM `crimes` WHERE `PlayerName` = ''
Re: How can i make an police wanted file? -
ImTobi - 25.04.2018
Quote:
Originally Posted by jasperschellekens
Create a new table called crimes or something.
Add 2 fields. ID or playername and a field maybe called crime.
Now save the crime in the crime field and the name/userid into the other field.
You can then select them like this:
PHP код:
SELECT * FROM `crimes` WHERE `PlayerName` = ''
|
I know that, but i don't know how to save them, they should not be deleted at restart or something, they should be saved forever, or until someoone deletes it with an mdc from the police that i made, but how can i show it in a dialog? I must save it in an array or something, but without limits
Re: How can i make an police wanted file? -
Phreak - 25.04.2018
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]; // edited
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.
Re: How can i make an police wanted file? -
ImTobi - 25.04.2018
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
Re: How can i make an police wanted file? -
Phreak - 25.04.2018
What mysql plugin do you use and what version of it?
This should work with BlueG r41.
(What's the error by the way?)
Re: How can i make an police wanted file? -
jasperschellekens - 25.04.2018
Quote:
Originally Posted by ImTobi
when i take this version, everything is undefined and i don't want to change so many lines
|
Ever heard of CTRL + h? Its not gonna fix itself you know