BAN SYSTEM FOR TIME.
#1

Hi people.I need some help to do ban system like that: /ban [playerid] [time/hours](and only hours not like that /ban [playerid] [years,months and bla bla].I know it's hard to do,but maybe have and can give me,or make thanks for answers.
Reply
#2

Yes,but it's ban for minutes,i need for hours.I try to do that but nothing good...

Add:Maybe somebody can do that?to make foxban with hours.
Reply
#3

I made this, but didn't test. Try:

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(
strcmp(cmdtext"/ban"true) == 0)
    {
        if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF0000FF"You aren't a RCON Admin.");
        new 
b[256], idx;
        
strtok(cmdtextidx);
        new 
player strval(b);
        if(!
strlen(b)) return SendClientMessage(playerid0xFFFFFFFF"USE: /ban [playerid] [time/hours]");
        
strtok(cmdtextidx);
        new 
time strval(b);
        if(!
strlen(b)) return SendClientMessage(playerid0xFFFFFFFF"USE: /ban [playerid] [time/hours]");
        if(!
IsPlayerConnected(player) || player == INVALID_PLAYER_ID) return SendClientMessage(playerid0xFF0000FF"Invalid ID.");
        if(
time 1) return SendClientMessage(playerid0xFF0000FF"Iime must be greater than 0.");
        
SendClientMessage(player0xFFFF00FF"You was banned.");
        
GetPlayerName(playerb24);
        
format(b35"/Bans/%s.txt"b);
        if(!
fexist(b)) { dini_Create(b); }
        
dini_IntSet(b"BanTime", (gettime()+(time*3600)));
        
Kick(player);
        
SendClientMessage(playerid0xFFFF00FF"Player banned successfully.");
        return 
1;
    }
    return 
0;
}
public 
OnPlayerSpawn(playerid)
{
    new 
str[35];
    
GetPlayerName(playeridstr24);
    
format(str35"/Bans/%s.txt"str);
    if(
fexist(str))
    {
        if(
dini_Int(str"BanTime") < gettime())
        {
            
SendClientMessage(playerid0xFF0000FF"You are still banned.");
            
Kick(playerid);
        }
    }
    return 
1;

Reply
#4

Better yet: https://sampforum.blast.hk/showthread.php?pid=1205522#pid1205522
Reply
#5

No it's no better, i need only hours there is years months i don't need that?

Add:Shadow not need to change anything in foxban.inc?
Reply
#6

I fix fox ban now i can ban for hours,but one trouble.How to do that?public OnPlayerConnect(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
format(FB_tbDir,sizeof(FB_tbDir),FB_foxBanFile,pNa me);
if(FB_dini_Exists(FB_tbDir))
{
if(FB_dini_Int(FB_tbDir,"fbFB_Time")+FB_dini_Int(F B_tbDir,"fbDuration") > FB_Time())
{
new string[96];
new sekki=(FB_dini_Int(FB_tbDir,"fbFB_Time")+FB_dini_I nt(FB_tbDir,"fbDuration"))-FB_Time(),minni=sekki/60;
sekki=sekki-minni*60;
format(string,sizeof(string),"You are timebanned from this server. Remaining time: %d minutes %d seconds",minni,sekki);
SendClientMessage(playerid,0xADC7E7FF,string);
Kick(playerid);
} else { FB_dini_Remove(FB_tbDir); }
}
return CallLocalFunction("FB_OnPlayerConnect","i",playeri d);
}

There were remaining time be with hours like that: 01:59:12 is imposible to do that?
Reply
#7

Oh ! Sorry ... I didn't say this: You need to create the folder Bans inside the directory scriptfiles.

Quote:
Originally Posted by budelis
Посмотреть сообщение
I fix fox ban now i can ban for hours,but one trouble.How to do that?public OnPlayerConnect(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
format(FB_tbDir,sizeof(FB_tbDir),FB_foxBanFile,pNa me);
if(FB_dini_Exists(FB_tbDir))
{
if(FB_dini_Int(FB_tbDir,"fbFB_Time")+FB_dini_Int(F B_tbDir,"fbDuration") > FB_Time())
{
new string[96];
new sekki=(FB_dini_Int(FB_tbDir,"fbFB_Time")+FB_dini_I nt(FB_tbDir,"fbDuration"))-FB_Time(),minni=sekki/60;
sekki=sekki-minni*60;
format(string,sizeof(string),"You are timebanned from this server. Remaining time: %d minutes %d seconds",minni,sekki);
SendClientMessage(playerid,0xADC7E7FF,string);
Kick(playerid);
} else { FB_dini_Remove(FB_tbDir); }
}
return CallLocalFunction("FB_OnPlayerConnect","i",playeri d);
}

There were remaining time be with hours like that: 01:59:12 is imposible to do that?
Yes, you put this in OnPlayerConnect.

Would you like to ban with minutes and seconds ?

#EDIT

Sorry again, but this must be in OnPlayerSpawn. Code fixed.

I recommend you take the code again.
Reply
#8

Yes but i want to do that:

new seconds = PlayerDB[playerid][jail_time];

And how to make it to write it like that:

01:59:59
Reply
#9

You have to use a string, or 3 integer variables.
But like Calg00ne says, i recommand this too: https://sampforum.blast.hk/showthread.php?pid=1205522#pid1205522
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)