SA-MP Forums Archive
It wont ban / show messages - 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: It wont ban / show messages (/showthread.php?tid=515685)



It wont ban / show messages - Johnson_Brooks - 27.05.2014

These are my ban commands and they do not work .
It only kicks the player but it doesn't ban him .
It also doesn't show the ban information when banned.
NOTE : the /oban and /unban commands are from a tutorial on the sa-mp forums and i dont remember which tut was it
pawn Код:
CMD:ban(playerid, params[])
{
        new targetid, reason[128], string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
        new targetname[MAX_PLAYER_NAME];
        GetPlayerName(playerid,targetname,MAX_PLAYER_NAME);
        new day, month, year;
        getdate(day, month, year);
        new hour, minute, second;
        gettime(hour, minute, second);
        if(PlayerInfo[playerid][pAdmin] >= 1)
                {
                if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, -1, "USAGE:: /ban [id] [reason]");
                if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,COLOR_RED,"The player is not connected.");
                GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);
                format(string, sizeof(string), "You have been banned by an Administrator . If you feel that you were wrongly banned , appeal at : sfcnr.smfnew.com");
                SendClientMessage(targetid, COLOR_RED, string);
                SendClientMessage(targetid, COLOR_RED, "Ban Information");
                format(string, sizeof(string), "Banned by: %s(AdminLevel:%d)", pName, PlayerInfo[playerid][pAdmin]);
                SendClientMessage(targetid, COLOR_RED, string);
                format(string, sizeof(string), "Ban reason: %s", reason);
                SendClientMessage(targetid, COLOR_RED, string);
                format(string, sizeof(string), "Date & Time of the ban: %d/%d/%d at %d:%d:%d.", day, month, year, hour, minute, second);
                SendClientMessage(targetid, COLOR_RED, string);
                SendClientMessage(targetid, COLOR_RED,"Please press the F8 button to take a screenshot to use it on your appeal");
                format(string, sizeof(string), "[{FF0000}BAN{EEEEEE}]Administrator %s has banned %s for %s",pName,targetname,reason);
                SendClientMessageToAll(COLOR_WHITE,string);
                PlayerInfo[targetid][pBanned] = 1;
                Kick(targetid);
                }
                else SendClientMessage(playerid,COLOR_RED,"You need to be an administrator to use this command");
        return 1;
}
CMD:oban(playerid, params[])
{
    new targetname[24], filestring[79];
    if(sscanf(params, "s[24]", targetname)) return SendClientMessage(playerid,COLOR_RED, "USAGE:: /oban [Offline Player's Name]");
    format(filestring, sizeof(filestring), "/Users/%s.ini", targetname);
    if(!fexist(filestring)) return SendClientMessage(playerid,COLOR_RED, "The player is not registered");
    else if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "data");
        INI_WriteInt(File, "pBanned", 1);
        INI_Close(File);
        new done[128];
        format(done, sizeof(done), "You have banned %s", targetname);
        SendClientMessage(playerid,COLOR_RED , done);
    }
    return 1;
}
CMD:unban(playerid, params[])
{
    new tname[24];
    if(sscanf(params, "s[24]", tname)) return SendClientMessage(playerid,COLOR_RED,"USAGE:: /unban [Player Name] ");
    new filestring[79];
    format(filestring, sizeof(filestring), "/Users/%s.ini", tname);
    if(!fexist(filestring)) return SendClientMessage(playerid,COLOR_RED, "The player is not registered");
    else if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "data");
        INI_WriteInt(File, "Banned",0);
        INI_Close(File);
        INI_ParseFile(filestring, "LoadIP_%s", .bExtra = true , .extra = playerid);
        new cmdstring[44];
        format(cmdstring, sizeof(cmdstring), "unbanip %s", PlayerInfo[playerid][BannedIP]);
        SendRconCommand(cmdstring);
        SendRconCommand("reloadbans");
        new done[128];
        format(done, sizeof(done),"You have successfully unbanned %s", tname);
        SendClientMessage(playerid,COLOR_RED,done);
    }
    else return SendClientMessage(playerid,COLOR_RED,"You're not an Administrator");
    return 1;
}



Re: It wont ban / show messages - Threshold - 27.05.2014

pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_RED,"You need to be an administrator to use this command");
    new targetid, reason[30];
    if(sscanf(params, "us[30]", targetid, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [id] [reason]");
    if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "The player is not connected.");
    new pName[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], day, month, year, hour, minute, second, string[128];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    GetPlayerName(playerid,targetname,MAX_PLAYER_NAME);
    getdate(day, month, year);
    gettime(hour, minute, second);
    SendClientMessage(targetid, COLOR_RED, "You have been banned by an Administrator. If you feel that you were wrongly banned, appeal at: sfcnr.smfnew.com");
    SendClientMessage(targetid, COLOR_RED, "Ban Information");
    format(string, sizeof(string), "Banned by: %s(AdminLevel:%d)", pName, PlayerInfo[playerid][pAdmin]);
    SendClientMessage(targetid, COLOR_RED, string);
    format(string, sizeof(string), "Ban reason: %s", reason);
    SendClientMessage(targetid, COLOR_RED, string);
    format(string, sizeof(string), "Date & Time of the ban: %d/%d/%d at %d:%d:%d.", day, month, year, hour, minute, second);
    SendClientMessage(targetid, COLOR_RED, string);
    SendClientMessage(targetid, COLOR_RED,"Please press the F8 button to take a screenshot to use it on your appeal");
    format(string, sizeof(string), "[{FF0000}BAN{EEEEEE}]Administrator %s has banned %s for %s",pName,targetname,reason);
    SendClientMessageToAll(COLOR_WHITE,string);
    PlayerInfo[targetid][pBanned] = 1;
    SetTimerEx("BanPlayer", 200, false, "i", targetid);
    return 1;
}

forward BanPlayer(playerid);
public BanPlayer(playerid) return Ban(playerid);
Since 0.3e, when a user is kicked or banned, the server closes the connection from client to server immediately due to security updates. This means that the clients may not receive the messages that you send through SendClientMessage before applying Kick or Ban(playerid). A workaround to this is to use a timer such as 'SetTimerEx("BanPlayer", 200, false, "i", playerid);'.


Re: It wont ban / show messages - Johnson_Brooks - 27.05.2014

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_RED,"You need to be an administrator to use this command");
    new targetid, reason[30];
    if(sscanf(params, "us[30]", targetid, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [id] [reason]");
    if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "The player is not connected.");
    new pName[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], day, month, year, hour, minute, second, string[128];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    GetPlayerName(playerid,targetname,MAX_PLAYER_NAME);
    getdate(day, month, year);
    gettime(hour, minute, second);
    SendClientMessage(targetid, COLOR_RED, "You have been banned by an Administrator. If you feel that you were wrongly banned, appeal at: sfcnr.smfnew.com");
    SendClientMessage(targetid, COLOR_RED, "Ban Information");
    format(string, sizeof(string), "Banned by: %s(AdminLevel:%d)", pName, PlayerInfo[playerid][pAdmin]);
    SendClientMessage(targetid, COLOR_RED, string);
    format(string, sizeof(string), "Ban reason: %s", reason);
    SendClientMessage(targetid, COLOR_RED, string);
    format(string, sizeof(string), "Date & Time of the ban: %d/%d/%d at %d:%d:%d.", day, month, year, hour, minute, second);
    SendClientMessage(targetid, COLOR_RED, string);
    SendClientMessage(targetid, COLOR_RED,"Please press the F8 button to take a screenshot to use it on your appeal");
    format(string, sizeof(string), "[{FF0000}BAN{EEEEEE}]Administrator %s has banned %s for %s",pName,targetname,reason);
    SendClientMessageToAll(COLOR_WHITE,string);
    PlayerInfo[targetid][pBanned] = 1;
    SetTimerEx("BanPlayer", 200, false, "i", targetid);
    return 1;
}

forward BanPlayer(playerid);
public BanPlayer(playerid) return Ban(playerid);
Since 0.3e, when a user is kicked or banned, the server closes the connection from client to server immediately due to security updates. This means that the clients may not receive the messages that you send through SendClientMessage before applying Kick or Ban(playerid). A workaround to this is to use a timer such as 'SetTimerEx("BanPlayer", 200, false, "i", playerid);'.
It works , thanks .