04.07.2012, 10:34
Hello
I am trying to learn how to use MySQL with PAWN and I have this quick inquiry. How would I go about storing the result of a query into a variable, so I could show it in a dialog?
Here's what I got:
(I am trying to show the reason of the ban to the player in a dialog)
I am trying to learn how to use MySQL with PAWN and I have this quick inquiry. How would I go about storing the result of a query into a variable, so I could show it in a dialog?
Here's what I got:
(I am trying to show the reason of the ban to the player in a dialog)
pawn Код:
// This is inside an if statement, which explains the indentation.
new reason[128]; // Variable I would like to store the result in.
format(query, sizeof(query), "SELECT reason FROM `bans` WHERE IP = '%s'", GetName(playerid)); // Format query (I already got the player's IP)
mysql_query(query);// Store query
mysql_store_result();// Store the result
// And here is where I want to store the result into a variable
format(ccstring, sizeof(ccstring), "We're sorry but you're IP is banned from the server.\nIf you would like to appeal, please appeal on our website\nat {0320FF}"website"\n\nReason: %s", reason); // Format the dialog
ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "{FF0303}[X]{FFFFFF} Banned", ccstring, "Okay", ""); // Show the dialog
Kick(playerid); // Kick the player because he's banned.
// Rest of code