SA-MP Forums Archive
for /ban command - 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: for /ban command (/showthread.php?tid=312535)



for /ban command - Tanush123 - 21.01.2012

How can i make if a admin attempts to /ban "Tan" they get auto banned too
So i mean if they try to ban the name "Tan" they get auto banned
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] > 1)
    {
        if(sscanf(params, "us[128", ID, message)) return SCM(playerid, grey, "USAGE: /ban [playerid / partofname] [reason]");
        if(ID == INVALID_PLAYER_ID) return SCM(playerid, 0xFF0000FF, "That player isn't connected!");
        GetPlayerName(playerid,Nam,sizeof(Nam));
        GetPlayerName(ID, pname, sizeof(pname));
        if(ID == playerid) return SCM(playerid,red,"ERROR: You cannot ban yourself");
        if(PlayerData[ID][AdminLevel] >= PlayerData[playerid][AdminLevel]) return SCM(playerid,red,"ERROR: That person is a higher admin level than you");
        if(TrophyData[ID][Banned] == 0)
        {
            GetPlayerPos(ID,X,Y,Z);
            PlayerData[ID][Achievement] = PlayerData[ID][Achievement]+1;
            TrophyData[ID][Banned] = 1;
            PlayerPlaySound(ID,1058,X,Y,Z);
            SCM(ID,-1,"You have completed the achievement {8080FF}Bad Boy");
        }
        gettime(bhour,bminute,bsecond);
        getdate(byear,bmonth,bday);
        format(str, sizeof(str), "Administartor %s has banned %s from the server for: %s",Nam,pname, message);
        SendClientMessageToAll(0xFF9900AA, str);
        SCM(ID,0xFF0000FF,"Banned Wrongfully?? Go to http://www.texascountyroleplay.smfnew.com to make a ban appeal!");
        format(str,sizeof(str),"{FF0000}Name:{FFFFFF} %s",pname);
        SCM(ID,-1,str);
        if(bmonth == 1)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} January %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 2)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} Feburary %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 3)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} March %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 4)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} April %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 5)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} May %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 6)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} June %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 7)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} July %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 8)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} August %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 9)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} September %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 10)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} October %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 11)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} November %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        if(bmonth == 12)
        {
            format(str,sizeof(str),"{FF0000}Banned Date:{FFFFFF} December %d %d | Time: %d:%d",bday,byear,bhour,bminute);
            SCM(ID,-1,str);
        }
        format(str,sizeof(str),"{FF0000}Reason:{FFFFFF} %s",message);
        SCM(ID,-1,str);
        SCM(playerid,COLOR_YELLOW,"Screen this with F8 if you want to get unbanned quicker");
        GetPlayerIp(ID,tmp3,50);
        format(str,sizeof(str),"Banned ip %s", tmp3);
        SCM(playerid,0xFF9900AA,str);
        Ban(ID);
    }
    else return SCM(playerid,-1,"SERVER: Unknown command.");
    return 1;
}



Re: for /ban command - [HiC]TheKiller - 21.01.2012

Your sscanf is missing a closing bracket to start with. All you need to do is use strcmp with pname, detect if it's 'Tan' using strcmp then change the ID and name to theirs if it is 'Tan'. I'm pretty sure you know how to do that.


Re: for /ban command - Tanush123 - 21.01.2012

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Your sscanf is missing a closing bracket to start with. All you need to do is use strcmp with pname, detect if it's 'Tan' using strcmp then change the ID and name to theirs if it is 'Tan'. I'm pretty sure you know how to do that.
for the missing bracket it doesn't affect my /ban command because when i never had [128 it cuts off string but when i add [128 it doesn't cut off and thank you for telling how to detect name.