PDA

View Full Version : Help: /unban command!


Areax
28/05/2013, 05:35 PM
Hello!

It's me again :) Well I tried to make an /unban command, but I can't unban an disconnected players, only connected ones.

Code:

CMD:unban(playerid, params[])
{
new string[200];
new banner;
if(pInfo[playerid][Adminlevel] < gCommands[UNBAN])return SCM(playerid, COLOR_RED, "[ERROR]: You can't use this command!");
if(isnull(params)) return SCM(playerid, COLOR_GREY, "[USAGE]: /unban [playername]");
if(pInfo[banner][Banned] == 0) return SCM(playerid, COLOR_RED, "[ERROR]: This player is not Banned!");
pInfo[banner][Banned] = 0;
format(string, sizeof(string), "[Admin]: You have succesfully Unbaned %s's account!", GetName(banner));
SCM(playerid, COLOR_YELLOW, string);
return 1;
}

Can someone tell, how to make an /unban command, which can unban an offline players?

Thanks :)

DobbysGamertag
28/05/2013, 05:38 PM
What's the ban command? You just have to turn it around :P

Areax
28/05/2013, 05:42 PM
What's the ban command? You just have to turn it around :P

Ban command:

CMD:ban(playerid, params[])
{
new targetid;
new reason[70];
new string[200];
if(pInfo[playerid][Adminlevel] < gCommands[BAN])return SCM(playerid, COLOR_RED, "[ERROR]: You can't use this command!");
if(sscanf(params, "us[70]", targetid, reason))return SCM(playerid, COLOR_GREY, "[USAGE]: /ban [playerid] [reason]");
if(!IsPlayerConnected(targetid))return SCM(playerid, COLOR_RED, "[ERROR]: This player is not connected!");
if(pInfo[playerid][Adminlevel] == pInfo[targetid][Adminlevel]) return SCM(playerid, COLOR_YELLOW, "[WARNING]: You can't Ban an Admin with a same Level then you!");
if(pInfo[playerid][Adminlevel] < pInfo[targetid][Adminlevel]) return SCM(playerid, COLOR_YELLOW, "[WARNING]: You can't Ban an Higher Admin then you!");
format(string, sizeof(string), "{80FF00}[Admin]: {DFF709}%s(ID:%d) has Banned %s(ID:%d) from the Server!{FF0000}||{DFF709}Reason: %s", GetName(playerid), playerid, GetName(targetid), targetid, reason);
SCMToAll(COLOR_YELLOW, string);
pInfo[playerid][Banned] = 1;
Kick(targetid);
return 1;
}

OnPlayerSpawn:

public OnPlayerSpawn(playerid)
{
if(pInfo[playerid][Banned] == 1)
{
SCM(playerid, COLOR_GREY, "{999999}You are Banned from this Server!");
Kick(playerid);
}
return 1;
}

doreto
28/05/2013, 05:48 PM
In your ban command you does not save ban infomation , with mean after they are kicked they can connect again !

Areax
28/05/2013, 05:50 PM
In your ban command you does not save ban infomation , with mean after they are kicked they can connect again !

It's saves

public OnPlayerDisconnect(playerid, reason)
{
new string[200];
format(string, sizeof(string), "***{00FF00}[LEFT]: {FB041D}%s(ID:%d){00FF00} has left The Server***", GetName(playerid), playerid);

new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
INI_WriteInt(file,"Banned",pInfo[playerid][Banned]);
INI_Close(file);
return 1;
}

HurtLocker
28/05/2013, 05:57 PM
The input will be the player's name, like /unban HurtLocker because it is obvious that you can't unban the player with id cause he can't enter the server. What you will do is turning the Banned = 1 to Banned = 0 in the player's .ini file.

Areax
28/05/2013, 05:59 PM
The input will be the player's name, like /unban HurtLocker because it is obvious that you can't unban the player with id cause he can't enter the server. What you will do is turning the Banned = 1 to Banned = 0 in the player's .ini file.

I know that, but I don't know how to do that...But I will try :)

xXShadowXx
28/05/2013, 06:03 PM
CMD:unban(playerid, params[])
{
new string[200];
new banner[24];
if(pInfo[playerid][Adminlevel] < gCommands[UNBAN])return SCM(playerid, COLOR_RED, "[ERROR]: You can't use this command!");
if(isnull(params)) return SCM(playerid, COLOR_GREY, "[USAGE]: /unban [playername]");
format(file,sizeof(file),"change/me/%s.ini",banner);
if(!fexist(file)) return 0;
format(string, sizeof(string), "[Admin]: You have succesfully Unbaned %s's account!", GetName(banner));
SCM(playerid, COLOR_YELLOW, string);
new INI:file = INI_Open(file);
INI_WriteInt(file,"Banned",0);
INI_Close(file);
return 1;
}

HurtLocker
28/05/2013, 06:04 PM
I know that, but I don't know how to do that...But I will try :)
Are you serious? How did you write the onplayerdisconnect code then?

xXShadowXx
28/05/2013, 06:05 PM
Are you serious? How did you write the onplayerdisconnect code then?

By copying a tutorial I guess.

Areax
28/05/2013, 06:21 PM
Something like this?

CMD:unban(playerid, params[])
{
new banner[24];
new string[200];
new INI:file = INI_Open(Path(playerid));
if(sscanf(params, "s", banner)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /unban [playername]");
format(string,sizeof(string),UserPath,banner);
INI_Load(string);
if(!fexist(string)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This name doesn't exist!");
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"Banned",0);
INI_Close(file);
format(string, sizeof(string), "[Admin]: You have succesfully Unbaned %s's account!", banner);
SCM(playerid, COLOR_YELLOW, string);
return 1;
}