Temporary Ban System [+REP]
#1

Here i have my permamently ban command

PHP код:
CMD:ban(playerid,params[])
{
    if(
pInfo[playerid][pAdminLevel] >= 2)
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
targetid,reason[105],string[256];
            if(
sscanf(params"us[105]"targetid,reason)) return SendClientMessage(playerid,-1,""chat" /ban [playerid] [reason]");
            if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
            
format(string,sizeof(string),""chat""COL_WHITE" [{B3432B}ADMIN{FFFFFF}]%s {EEC900}permanent banned{FFFFFF} [player:%s] [reason:%s]",PlayerName(playerid),PlayerName(targetid), reason);
               
SendClientMessageToAll(-1,string);
              
printf("%s %s has banned %s [Reason: %s]",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid),reason);
            
//pInfo[targetid][pBanned] = 1;
             
new AdminDutyMsg[128];
            
format(AdminDutyMsgsizeof(AdminDutyMsg), ""COL_WHITE"["COL_CADMIN"ADMIN"COL_WHITE"]"COL_CGREY" %s > banned > %s" ,PlayerName(playerid), PlayerName(targetid));
            
SendMessageToAllAduty(-1,AdminDutyMsg);
               
BanPlayer(targetid,reason,GetAdminName(playerid));
              new 
str[128];
            
format(strsizeof(str), "%s(%d) /ban %s(%d) (Reason: %s)"GetName(playerid), playeridGetName(targetid), targetidreason);
            new 
File:log;
            
log fopen("CommandsUsed.txt"io_append);
            
fwrite(logstr);
            
fwrite(log,"\r\n");
            
fclose(log);
        }
    }
    else {
        
SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
    }
    return 
1;


And Here is the Ban

PHP код:
stock BanPlayer(playerid,reason[],admin[])
{
    new 
playerIP[16],HourMinuteSecondYearMonthDay,timeBanned[80],bannedstring[256],Query[256];
    
GetPlayerIp(playeridplayerIPsizeof(playerIP));
    
gettime(HourMinuteSecond);
    
getdate(YearMonthDay);
    
format(timeBannedsizeof(timeBanned), "%02d:%02d:%02d on %02d/%02d/%d"HourMinuteSecondDayMonthYear);
    
//format(Query, sizeof(Query), "UPDATE `users` SET `pBannedReason` = '%s', `pBannedBy` = '%s', `pIPBanned` = '%s', `pTime` = '%s', `pAccountLock` = '1' WHERE `Username` = '%s'", reason,admin,playerIP,timeBanned,PlayerName(playerid));
    
format(Querysizeof(Query), "INSERT INTO `banlog` (`Name`, `pBannedReason`, `pBannedBy`, `pTime`, `pIPBanned`, `pAccountLock`) VALUES ('%s', '%s', '%s', '%s', '%s', 1)"PlayerName(playerid), reasonadmintimeBannedplayerIP);
    
mysql_query(Query);
    
mysql_free_result();
    
format(bannedstring,sizeof(bannedstring),"You are currently banned from this server. \r\nUser: %s \r\nIP: %s  \r\nTime: %s \r\nAdmin: %s\r\nReason: %s",PlayerName(playerid),playerIP,timeBanned,admin,reason);
    
ShowPlayerDialog(playerid,DIALOG_BANNED,DIALOG_STYLE_MSGBOX,"You have been banned!",bannedstring,"Leave","");
    
Kick(playerid);
    return 
1;

And here its the check if banned when connect
PHP код:
stock CheckBan(playerid)
{
       new 
Query[256],playerIP[16],timeBanned[94],largestringtwo[256],adminName[24],bannedName[24],reasonBanned[128];
    
GetPlayerIp(playeridplayerIPsizeof(playerIP));
    
format(Querysizeof(Query), "SELECT * FROM `banlog` WHERE ( `Name` = '%s' OR `pIPBanned` = '%s' ) AND `pAccountLock` = '1' LIMIT 1",PlayerName(playerid),playerIP);
    
mysql_query(Query);
    
mysql_store_result();
    if(
mysql_num_rows() != 0)
    {
        while(
mysql_fetch_row(Query))
        {
                
mysql_fetch_field_row(reasonBanned"pBannedReason");
                
mysql_fetch_field_row(adminName"pBannedBy");
                
mysql_fetch_field_row(timeBanned"pTime");
                
mysql_fetch_field_row(playerIP"pIPBanned");
                
mysql_fetch_field_row(bannedName"Name");
        }
        
format(largestringtwosizeof(largestringtwo), "You are currently banned from this server. \r\nUser: %s \r\nIP: %s  \r\nTime: %s \r\nAdmin: %s\r\nReason: %s"bannedNameplayerIPtimeBannedadminNamereasonBanned);
        
ShowPlayerDialog(playeridDIALOG_BANNEDDIALOG_STYLE_MSGBOX"You are banned from this server"largestringtwo"Leave""");
        
Kick(playerid);
        
printf("Username %s || IP %s is banned!",PlayerName(playerid),playerIP);
    }
    return 
1;

Can i have this temporary ban with days please ?

I need to make it temporary
Thank you

See you tomorow for the answer byeee
Reply
#2

SomeOne ?
Reply
#3

Use gettime.
If you want a ban system with days:
PHP код:
CMD:daysban(playeridparams[])
{
    new 
daysidbantime;
    if(
sscanf(params"ui"iddays)) return SendClientMessage(playerid, -1"CORRECT SYNTAX: /daysban [name/id] [days]");
    
bantime gettime()+(days*24*60*60*1000);
    return 
true;

Like this.
Reply
#4

Hmm ok this but i want something like this but this nneed to be expired and to be check when end the daysban
Reply
#5

Try to use a newer mysql version with threaded queries.
To check for you ban, you are going to use something like this:
PHP код:
stock CheckForBan(playerid)
{
    if(
gettime() < time)
    {
        
SendClientMessage(playerid, -1"Banned.");
        
Kick(playerid);
    }
    else (
unban the player..)
    return 
true;

Reply
#6

I didnt understand this exactly can you adapts like my stock CheckBan
Look it in it are created
*pBannedReason
*pBannedBy
*pTime
*pIPBanned
*Name
Reply
#7

You copied the script, right? Otherwise you would know, how to fix it, couse the guy above already helped you.
Reply
#8

Of course but i didint understand it verry well
Reply
#9

Read this:https://sampforum.blast.hk/showthread.php?tid=254915

Try to understand it and script it yourself.
Reply
#10

stock CheckForBan(playerid)
{
if(gettime() < time)
{
SendClientMessage(playerid, -1, "Banned.");
Kick(playerid);
}
else (unban the player..)
return true;
}

Try to use a newer mysql version with threaded queries.
To check for you ban, you are going to use something like this:
PHP код:
stock CheckForBan(playerid)
{
    if(
gettime() < time)
    {
        
SendClientMessage(playerid, -1"Banned.");
        
Kick(playerid);
    }
    else (
unban the player..)
    return 
true;

I created somthing like this but nothing work
When i ban myself and i relog it wont tell mee i am banned
It not work
Where need to save it ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)