SA-MP Forums Archive
Ban cmds - 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: Ban cmds (/showthread.php?tid=630858)



Ban cmds - sscarface - 19.03.2017

PHP код:
CMD:ban(playerid,params[]) {
    if(
IsPlayerAdmin(playerid)) {
            new 
strdate[128],strtime[128], tmp[256], tmp2[256], Index;        tmp = strtok(params,Index), tmp2 = strtok(params,Index);
            if(!
strlen(params)) return SendClientMessage(playerid, 0xDC143CAA, "USAGE: /ban [playerid] [reason]");
            if(!
strlen(tmp2)) return SendClientMessage(playerid, 0xDC143CAA, "ERROR: You must give a reason");
              new 
player1, ip[128], string[128];
            
player1 = strval(tmp);
             if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && !IsPlayerAdmin(player1)) {
                
GetPlayerIp(playerid,ip,sizeof(ip));
                new 
year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
                
format(string,sizeof(string),"|- %s has been banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d] -|",Name[player1],Name[playerid],params[2],day,month,year,hour,minuite);
                
SendClientMessageToAll(COLOR_Silver,string);
                print(string);
                
format(strdate, sizeof(strdate), "%d-%d-%d ",year,month,day);
                
format(strtime,sizeof(strtime),"%d:%d:%d",hour,minuite,second);
                new 
Query[250];
                
format(Query, sizeof(Query), "UPDATE `banneds` SET `ip` = '%s', `date` = '%s', `time` = '%s', `bannedby` = '%s', `banned` = '%d', `reason` = '%s' WHERE `name` = '%s'", ip,strdate,strtime,Name[playerid],1,params[2],Name[playerid]);
                
mysql_tquery(mysql, Query, "", ""); totalbans ++;
                
format(Query, sizeof(Query),"INSERT INTO `bannedips`(`ip`) VALUES ('%s')",ip);
                
mysql_tquery(mysql, Query, "", ""); totalip ++;
                return 
SetTimerEx("kickplayer", 500, false, "i", tmp);
             } else return 
SendClientMessage(playerid, 0xDC143CAA, "Player is not connected or is yourself or is the highest level admin");
    } else return 
SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
}
CMD:tempban(playerid,params[]) {
    if(
IsPlayerAdmin(playerid)) {
            new 
strdate[128],strtime[128], player1w[128], reason[128], byearw[128],bmonthw[128],bdayw[128], Index; player1w = strtok(params,Index), reason = strtok(params,Index); byearw = strtok(params,Index), bmonthw = strtok(params,Index), bdayw = strtok(params,Index);
            if(!
strlen(player1w)) {
            
SendClientMessage(playerid, 0xDC143CAA, "USAGE: /tempban [playerid] [reason] [years months days]");
            return 
SendClientMessage(playerid, 0xFF9900AA, "Example: /tempban 1 example 0 0 6 [ player will be banned for six days ]");
            }
            if(!
strlen(reason)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
            if(!
strlen(byearw)) return SendClientMessage(playerid, red, "ERROR: You must give a year");
            if(!
strlen(bmonthw)) return SendClientMessage(playerid, red, "ERROR: You must give a month");
            if(!
strlen(bdayw)) return SendClientMessage(playerid, red, "ERROR: You must give a day");
            new 
player1n,byearn,bmonthn,bdayn,ip[128], string[150];
            
player1n = strval(player1w); byearn = strval(byearw); bmonthn = strval(bmonthw); bdayn = strval(bdayw);
             if(
IsPlayerConnected(player1n) && player1n != INVALID_PLAYER_ID) {
                
GetPlayerIp(playerid,ip,sizeof(ip));
                new 
year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
                
format(string,sizeof(string),"|- %s has been temporary banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d] -|",Name[player1n],Name[playerid],params[2],day,month,year,hour,minuite);
                
SendClientMessageToAll(COLOR_Silver,string);
                print(string);
                
format(strdate, sizeof(strdate), "%d-%d-%d ",year,month,day);
                
format(strtime,sizeof(strtime),"%d:%d:%d",hour,minuite,second);
                new 
tempbandate[3],bandate[128];
                
tempbandate[0] = year+byearn; tempbandate[1] = month+bmonthn; tempbandate[2] = day+bdayn;
                
format(bandate,sizeof bandate,"%d-%d-%d",tempbandate[0],tempbandate[1],tempbandate[2]);
                new 
Query[250];
                
format(Query, sizeof(Query), "UPDATE `banneds` SET `ip` = '%s', `date` = '%s', `time` = '%s', `bannedby` = '%s', `tempban` = '%d', `reason` = '%s', `bdate` = '%s' WHERE `name` = '%s'", ip,strdate,strtime,Name[playerid],1,params[2],bandate,Name[player1n]);
                
mysql_tquery(mysql, Query, "", ""); printf("%s",Query); totalbans ++;
                
format(Query, sizeof(Query),"INSERT INTO `bannedips`(`ip`) VALUES ('%s')",ip);
                
mysql_tquery(mysql, Query, "", ""); totalip ++;
                return 
SetTimerEx("kickplayer", 500, false, "i", player1n);
             } else return 
SendClientMessage(playerid, 0xDC143CAA, "Player is not connected or is yourself or is the highest level admin");
    } else return 
SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
} 
I don't get any error while complaining but cmd doesnt work in game whenever i type it. Any idea?