[MYSQL]Unban not working - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [MYSQL]Unban not working (
/showthread.php?tid=536337)
[MYSQL]Unban not working -
Type-R - 09.09.2014
Hey, guys well im translating my server from R5 into R39, and everything was going well until i got into the Unban command. For some reason the name of the player that im trying to unban, doesnt get moved on to the callback, and then i cannot delete the row that i need to delete. Heres the command:
pawn Код:
COMMAND:unban(playerid, params[])
{
new query[200];
// Check is player an admin
if(GetPVarInt(playerid, "Admin_lygis") < 5)
{
// Send message and exit
SendClientMessage(playerid, raudona, "[FunZoneLT]>> Jus negalite naudoti sitos komandos.");
return 1;
}
// Create variable
new
lookupname[16];
// Check did admin enter player ID
if(sscanf(params, "s[16]", lookupname))
{
// Send messages and exit
SendClientMessage(playerid, COLOR_RED, "{FBDF89}[FunZoneLT]>> /unban [vardas]");
return 1;
}
// Process unban process
// UnBanPlayer(playerid, lookupname);
mysql_format(mysql, query, sizeof(query),"SELECT * FROM `banai` WHERE `Player` = '%s' LIMIT 1", lookupname);
mysql_tquery(mysql, query, "UnBanPlayer", "i", "playerid, lookupname");
// Exit here
return 1;
}
The callback:
pawn Код:
forward UnBanPlayer(playerid, lookupname[]);
public UnBanPlayer(playerid, lookupname[])
{
new rows, fields, query[200]; //a variable that will be used to retrieve rows and fields in the database.
cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
if(rows) //if there is row
{//then
mysql_format(mysql, query, sizeof(query), "DELETE FROM `banai` WHERE `Player` = '%s'", lookupname);
mysql_tquery(mysql, query);
format(TempStr, sizeof TempStr, "[FunZoneLT]>> Jus sekmingai atbaninote zaideja vardu '%s'", lookupname);
SendClientMessage(playerid, COLOR_GREEN, TempStr);
}
return 1;
}
Heres the MySQL log:
Код:
[19:51:34] [DEBUG] mysql_format - connection: 1, len: 200, format: "SELECT * FROM `banai` WHERE `Player` = '%s' LIMIT 1"
[19:51:34] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `banai` WHERE `Player` = 'TypeR' LIMIT 1", callback: "UnBanPlayer", format: "i"
[19:51:34] [DEBUG] CMySQLQuery::Execute[UnBanPlayer] - starting query execution
[19:51:34] [DEBUG] CMySQLQuery::Execute[UnBanPlayer] - query was successfully executed within 0.245 milliseconds
[19:51:34] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[19:51:34] [DEBUG] Calling callback "UnBanPlayer"..
[19:51:34] [DEBUG] cache_get_data - connection: 1
[19:51:34] [DEBUG] mysql_format - connection: 1, len: 200, format: "DELETE FROM `banai` WHERE `Player` = '%s'"
[19:51:34] [DEBUG] mysql_tquery - connection: 1, query: "DELETE FROM `banai` WHERE `Player` = '%s
'", callback: "(null)", format: "(null)"
[19:51:34] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[19:51:34] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[19:51:34] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.269 milliseconds
[19:51:34] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
I dont understand what is the problem here. Do you guys see an issue?
Re: [MYSQL]Unban not working -
Riwerry - 09.09.2014
You've missed the s specifier for string here:
pawn Код:
mysql_tquery(mysql, query, "UnBanPlayer", "i", "playerid, lookupname");
That should be:
pawn Код:
mysql_tquery(mysql, query, "UnBanPlayer", "is", "playerid, lookupname");
Re: [MYSQL]Unban not working -
Type-R - 09.09.2014
Thanks!