Help: /unban command!
#1

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:

pawn Код:
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
Reply
#2

What's the ban command? You just have to turn it around :P
Reply
#3

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
What's the ban command? You just have to turn it around :P
Ban command:

pawn Код:
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:

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(pInfo[playerid][Banned] == 1)
    {
        SCM(playerid, COLOR_GREY, "{999999}You are Banned from this Server!");
        Kick(playerid);
    }
    return 1;
}
Reply
#4

In your ban command you does not save ban infomation , with mean after they are kicked they can connect again !
Reply
#5

Quote:
Originally Posted by doreto
Посмотреть сообщение
In your ban command you does not save ban infomation , with mean after they are kicked they can connect again !
It's saves

pawn Код:
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;
}
Reply
#6

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.
Reply
#7

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
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
Reply
#8

pawn Код:
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;
}
Reply
#9

Quote:
Originally Posted by Areax
Посмотреть сообщение
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?
Reply
#10

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
Are you serious? How did you write the onplayerdisconnect code then?
By copying a tutorial I guess.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)