How could I do an unban cmd ? -
anou1 - 08.02.2014
Hi everybody,
Do you know how could I do a unban CMD that could unban an offline player from the database ?
My ban CMD is like that;
Код:
CMD:aban(playerid, params[])
{
if(pInfo[playerid][Admin] >= 60)
{
new string[128], raison[128], id;
if(sscanf(params, "us[128]", id, raison)) return SendClientMessage(playerid, Gris, "Utilisation: /aban [ID Joueur] [Raison]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, Rouge,"Ce joueur n'est pas connectй !");
GetPlayerName(playerid, joueuremetteur, sizeof(joueuremetteur));
GetPlayerName(id, joueurdestinataire, sizeof(joueurdestinataire));
if(pInfo[playerid][Admin] < pInfo[id][Admin])
{
new msg[128];
format(msg, sizeof(msg), "[ADMIN]:%s a essayй de ban l'admin %s", playerid, joueurdestinataire);
ChannelAdmin(Rouge, msg);
return SendClientMessage(playerid, Rouge, "Vous ne pouvez pas ban un admin de rang supйrieur au votre !");
}
GetPlayerName(playerid, joueuremetteur, sizeof(joueuremetteur));
GetPlayerName(id, joueurdestinataire, sizeof(joueurdestinataire));
format(string, sizeof(string), "[ADMIN]:%s a йtй ban par %s. Raison: %s", joueurdestinataire, joueuremetteur, raison);
ChannelAdmin(Rouge, string);
format(string, sizeof(string), "Vous avez йtй ban du serveur par %s. Raison: %s", joueuremetteur, raison);
SendClientMessage(id, Rouge, string);
format(pInfo[id][RaisonBan], 128, "%s", raison);
pInfo[id][Bannis] = 1;
new query[512];
mysql_format(mysql, query, sizeof(query), "UPDATE `joueurs` SET `Bannis`=%d, `RaisonBan`='%s' WHERE `ID`=%d", pInfo[id][Bannis], pInfo[id][RaisonBan], pInfo[id][ID]);
mysql_tquery(mysql, query, "", "");
SetTimerEx("BanJoueur", 1000, 0, "d", id);
return 1;
}
return SendClientMessage(playerid, Rouge,"La commande entrйe est inconnue !");
}
So when I ban someone it makes "Bannis" to 1 and "RaisonBan" to the reason.
I'm trying to do an unban cmd, but how could I check if the player exists, and if he's banned ?
Thank you !
PS:if you have any idea to improve my ban system or something like that, tell me please !
Re: How could I do an unban cmd ? -
anou1 - 08.02.2014
Please, nobody know ?
Re: How could I do an unban cmd ? -
Don_Cage - 08.02.2014
I don't know mysql so I can't help you with unban. But I think you should change the ban so it wont save as a variable. It can cause problems in the future, trust me.
I had problem with that so I made a folder called AccBans and then edited my ban cmd to create a file with the banned persons name as the file name and inside the file I put reason and admin who banned. Then in OnPlayerConnect I checked if the players name.ini was in the AccBans folder. If it was, send him a message saying that he is still banned and then kick him.
Re: How could I do an unban cmd ? -
anou1 - 08.02.2014
What type of problems can it cause ?
So should I create a table for banned people ?
But I don't know how to check if a player is banned if I do something like that and I will still have the same problem to unban the player.
Re: How could I do an unban cmd ? -
Don_Cage - 08.02.2014
I got a problem that made random people get banned
Re: How could I do an unban cmd ? -
tyler12 - 08.02.2014
pawn Код:
CMD:unban(playerid,params[])
{
new name[24],string[128];
if(sscanf(params,"s[24]",name)) return SendClientMessage(playerid,0xFF0000FF,"/unban [player_name]");
format(string,sizeof(string),"SELECT * FROM `joueurs` WHERE `Bannis` = '1' AND `Name` = '%s' LIMIT 1",name);
mysql_query(string); mysql_store_result();
if(!mysql_num_rows()) return mysql_free_result(); SendClientMessage(playerid,0xFF0000FF,"Player is not banned.");
mysql_free_result();
mysql_format(mysql,string,sizeof(string),"UPDATE `joueurs` SET `Bannis` = '0' WHERE `Name` = '%e'",name); mysql_tquery(mysql,string,"","");
format(string,sizeof(string),"%s has been unbanned.",name); SendClientMessage(playerid,-1,string);
return 1;
}
Re: How could I do an unban cmd ? -
anou1 - 08.02.2014
Thank you !
I will try this and tell you if it worked !
Re: How could I do an unban cmd ? -
anou1 - 08.02.2014
Problem:
mysql_query(string);
I got: error 035: argument type mismatch (argument 1)
if(!mysql_num_rows()) return mysql_free_result();
I got: warning 209: function "mysql_free_result" should return a value