Timeban
#1

hi,
how to properly timeban through sscanf and that there was no tmp strtok and so on
for example, I'm putting code from one system admin
and that if this could be to sscanf

PHP код:
if(strcmp(cmd"/tempban"true) == 0//Credits to LuxAdmin
    
{
        new 
name[MAX_PLAYER_NAME];
        new 
giveplayer[MAX_PLAYER_NAME];
        new 
giveplayerid;
        if(
Account[playerid][Level] < 5) return SendClientMessage(playerid,Red,"ERROR: You are not a high enough level to use this command");
            
tmp strtok(cmdtext,idx);
            if(!
strlen(tmp))
            {
                  
SendClientMessage(playerid,COLOR_ERROR"{6EF83C}Usage: {FFFFFF}/tempban [PlayerID] [Day(s)] [Reason]");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            if(
IsPlayerConnected(giveplayerid))
            {
                
tmp strtok(cmdtextidx);
                if (!
strlen(tmp))
                {
                
SendClientMessage(playeridCOLOR_ERROR"{6EF83C}Usage: {FFFFFF}/tempban [PlayerID] [Day(s)] [Reason]");
                return 
1;
                }
                new 
days strval(tmp);
                if(!
IsNumeric(tmp))
                return 
SendClientMessage(playeridRed"ERROR: Invalid Day! Only Numbers!");
                if(
strval(tmp) <= || strval(tmp) > 1000)
                return 
SendClientMessage(playeridRed"ERROR: Invalid Day! (1-1000)");
                new 
reason[128];
                
reason strtok2(cmdtext,idx);
                if (!
strlen(reason))
                return 
SendClientMessage(playeridRed"ERROR: Reason not Specified!");
                if (
strlen(reason) <= || strlen(reason) > 100)
                return 
SendClientMessage(playeridRed"ERROR: Invalid Reason length!");
                new 
ip[15];
                
GetPlayerIp(giveplayerid,ip,15);
                
GetPlayerName(playeridnamesizeof name);
                
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                new 
File:tempban fopen("ZeroAdmin/Logs/TempBans.ban"io_append);
                if (
tempban)
                {
                    new 
year,month,day;
                    
getdate(yearmonthday);
                    
day += days;
                    if (
IsMonth31(month))
                    {
                        if (
day 31)
                        {
                            
month += 1;
                            if (
month 12)
                            {
                                
year += 1;
                                while(
day 31day -= 31;
                            }
                            else while(
day 31day -= 31;
                        }
                    }
                    else if (!
IsMonth31(month))
                    {
                        if (
day 30)
                        {
                            
month += 1;
                            if (
month 12)
                            {
                                
year += 1;
                                while(
day 30day -= 30;
                            }
                            else while(
day 30day -= 30;
                        }
                    }
                    else if (!
IsMonth31(month) && IsMonth29(year) && month == 2)
                    {
                        if (
day 29)
                        {
                            
month += 1;
                            if (
month 12)
                            {
                                
year += 1;
                                while(
day 29day -= 29;
                            }
                            else while(
day 29day -= 29;
                        }
                    }
                    else if (!
IsMonth31(month) && !IsMonth29(year) && month == 2)
                    {
                        if (
day 28)
                        {
                            
month += 1;
                            if (
month 12)
                            {
                                
year += 1;
                                while(
day 28day -= 28;
                            }
                            else while(
day 28day -= 28;
                        }
                    }
                    
format(stringsizeof string"%d|%d|%d|%s\n"daymonthyearip);
                    
fwrite(tempbanstring);
                    
fclose(tempban);
                }
                
format(string,128,"Administrator %s Temporarily Banned %s for %d Day(s)  Reason: %s",name,giveplayer,days,reason);
                
SendClientMessageToAll(Red,string);
                
Kick(giveplayerid);
                
format(stringsizeof string"Admin %s Temporarily Banned %s for %d Day(s)  Reason: %s",name,giveplayer,days,reason);
                
SaveLogs("TempBansLog",string);
            }
            else
            {
               
SendClientMessage(playerid,Red,"ERROR: Player is not connected");
            }
    }
    return 
0;

Reply


Messages In This Thread
Timeban - by EmpireSk - 14.01.2015, 20:07
Re: Timeban - by xVIP3Rx - 14.01.2015, 20:17
Re: Timeban - by EmpireSk - 14.01.2015, 20:23

Forum Jump:


Users browsing this thread: 3 Guest(s)