/unban using MySQL - 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: /unban using MySQL (
/showthread.php?tid=496356)
/unban using MySQL -
venomlivno8 - 21.02.2014
pawn Код:
command(unban, playerid, params[])
{
new giveplayername[24];
if(sscanf(params, "s[24]", giveplayername)) return SendClientMessage(playerid, COLOR_WHITE, " USAGE: /unban [player name]");
mysql_format(sqldb, query, sizeof(query), "SELECT * FROM accounts WHERE accname ='%e' LIMIT 0, 1", giveplayername);
mysql_tquery(sqldb, query);
new rows = mysql_num_rows();
if(!rows)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "That player doesn't exists in server's database!");
}
if(rows == 1)
{
if(cache_get_row_int(0, 4, sqldb))
{
mysql_format(sqldb, query, sizeof(query), "UPDATE accounts SET banvar ='0' WHERE accname ='%e'", giveplayername);
mysql_tquery(sqldb, query);
}
if(cache_get_row_int(0, 4, sqldb)) return SendClientMessage(playerid, COLOR_LIGHTRED, " That player isn't banned!");
}
return 1;
}
It allways returns "That player doesn't exists in server's database!"
What's wrong?
Re: /unban using MySQL -
Vince - 21.02.2014
Must use callback!
Re: /unban using MySQL -
venomlivno8 - 21.02.2014
I found out that and now I did that... But now my callback won't print SendClientMessage, I did this:
pawn Код:
command(unban, playerid, params[])
{
new giveplayername[24];
if(sscanf(params, "s[24]", giveplayername)) return SendClientMessage(playerid, COLOR_WHITE, " USAGE: /unban [player name]");
mysql_format(sqldb, query, sizeof(query), "SELECT * FROM accounts WHERE accname ='%e' LIMIT 0, 1", giveplayername);
mysql_tquery(sqldb, query, "UnbanPlayer", "is", playerid, giveplayername);
return 1;
}
pawn Код:
forward UnbanPlayer(playerid, giveplayername);
public UnbanPlayer(playerid, giveplayername)
{
new rows = mysql_num_rows();
if(!rows)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "That player doesn't exists in server's database!");
}
if(rows == 1)
{
new temp[24], isbanned;
cache_get_row(0, 4, temp); isbanned = strval(temp);
if(isbanned == 1)
{
mysql_format(sqldb, query, sizeof(query), "UPDATE accounts SET banvar ='0' WHERE accname ='%e' LIMIT 0, 1", giveplayername);
mysql_tquery(sqldb, query);
}
else if(isbanned == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, " That player isn't banned!");
}
}
return 1;
}