SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/01/2017, 10:25 AM   #1
Mivco
Big Clucker
 
Mivco's Avatar
 
Join Date: Mar 2015
Location: Slovakia
Posts: 59
Reputation: 0
Post Help timeban

Hi, I have problem of timeban. Servers when I use the command so it does not show anything on chat.
PHP Code:
#include <YSI\y_ini>
#include <YSI\y_commands>
#define HODINA(%0) 3600*%0
#define DIALOG_ID 874


public OnPlayerConnect(playerid)
{
new 
strong[100];
if(
fexist(strong))
{
    new 
dovod[75],Admin[25],dokedy,string[128],ip[20];
    
GetPlayerIp(playerid,ip,20);
    new 
INI:Fi INI_Open(BanPath(playerid));
    
INI_WriteString(Fi,"%s",ip);
    
INI_WriteString(Fi,"%s",dovod);
    
INI_WriteString(Fi,"%s",Admin);
    
INI_WriteInt(Fi,"%s",strval(string));
    
dokedy strval(string);
    
INI_WriteInt(Fi,"%s",dokedy);
    
INI_Close(Fi);
    if(
gettime() > dokedy)
    {
        
SendClientMessage(playerid,0x0000FFFF,"[ TimeBan ] {FF0000}Ban ti vypršal, dúfam že si sa poučil");
        
fremove(strong);
        }else{
        new 
ban[128];
        
strcat(ban,"Tvoj ešte stále nevypršal !\n");
        
format(strongsizeof(strong),"Nick: %s \n"Jmeno(playerid));
        
strcat(ban,strong);
        
format(strongsizeof(strong),"IP: %s \n"ip);
        
strcat(ban,strong);
        
format(strongsizeof(strong), "Dôvod: %s \n"dovod);
        
strcat(ban,strong);
        
format(strongsizeof(strong), "Admin: %s \n"Admin);
        
strcat(ban,strong);
        
format(strongsizeof(strong), "Kedy: %s \n"date(strval(string)));
        
strcat(ban,strong);
        
format(strongsizeof(strong), "Platnosť %s \n"date(dokedy));
        
strcat(ban,strong);
        
ShowPlayerDialog(playerid,DIALOG_ID,DIALOG_STYLE_MSGBOX,"{0000FF}TimeBan",ban,"OK","");
        
Kick(playerid);
    }
}
return 
1;
}

CMD:timeban(playeridparams[])
{
    
//if(admin[playerid] == false) return SendClientMessage(playerid,0x0000FFFF,"[Server]: Nie si Administrátor");
    
if(GetPlayerState(playerid) == PLAYER_STATE_WASTED) return SendClientMessage(playerid,0x0000FFFF,"[Server]: Nemôžeš byť vo výbere postáv !");
    new 
a[3][60],id,hodiny;
    if(
UnFormat(params,a,' ',3) != 3) return SendClientMessage(playerid,0x0000FFFF,"[Server]: /timeban [id] [hodinky] [dovod]");
    
id strval(a[0]);
    if(!
IsPlayerConnected(id)) return SendClientMessage(playerid,0x0000FFFF,"[Server]: Hráč není na servery !");
    if(
IsPlayerAdmin(id)) return SendClientMessage(playerid,0x0000FFFF,"[Server]: Nemôžeš zabanovať hlavného admina !");
    
hodiny strval(a[1]);
    new 
str2[75];
    
GetPlayerIp(id,str2,75);
    new 
INI:Fi INI_Open(BanPath(playerid));
    
INI_WriteString(Fi,"%s\r\n",str2);
    
INI_WriteString(Fi,"%s\r\n",a[2]);
    
INI_WriteString(Fi,"%s\r\n",Jmeno(playerid));
    
INI_WriteInt(Fi,"%d\r\n",gettime());
    
INI_WriteInt(Fi,"%d\r\n",HODINA(hodiny)+gettime());
    
INI_Close(Fi);
    new 
strong[128];
    
format(strongsizeof(strong),"[ TimeBan ] {FF0000}Admin {FFFFFF}%s{FF0000} dal hráčovy {FFFFFF}%s {FF0000}ban na %d hodín Dôvod: %s",Jmeno(playerid),Jmeno(id),hodiny,a[2]);
    
SendClientMessageToAll(-1,strong);
    
Kick(id);
    return 
true;
}

stock BanPath(playerid)
{
    new 
string[128],playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(string,sizeof(string),"Timeban/%s.txt",playername);
    return 
string;
}


stock Jmeno(playerid)
{
    new 
n[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
    return 
n;
}

stock UnFormat(str[],variables[][],cha,m=0)
{
    new 
len strlen(str),chcount,i,start,varcount;
    while(
len+1)
    {
        if(
== len && chcount != 0)
        {
            
strmid(variables[varcount],str,start+1,strlen(str),128);
            
chcount++;
        }
        if(
str[i] == cha)
        {
            if((
== 0) || (chcount != m-1))
            {
                
strmid(variables[varcount],str,start + ((start == 0) ? 1),i,128);
                
start i;
                
chcount++;
                
varcount++;
            }
        }
        
i++;
    }
    return 
chcount;
}

stock datetimestamp_form=)
{
    new 
year=1970day=0month=0hour=0mins=0sec=0;
    new 
days_of_month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    new 
names_of_month[12][10] = {"Januar","Februar","Marec","April","Maj","Jun","Jul","August","September","Oktober","November","December"};
     new 
returnstring[32];
      while(
timestamp>31622400)
      {
           
timestamp -= 31536000;
        if ( ((
year == 0) && (year 100 != 0)) || (year 400 == 0) ) timestamp -= 86400;
        
year++;
    }
    if ( ((
year == 0) && (year 100 != 0)) || (year 400 == 0) )
    
days_of_month[1] = 29;
    else
    
days_of_month[1] = 28;
    while(
timestamp>86400)
    {
        
timestamp -= 86400day++;
        if(
day==days_of_month[month]) day=0month++;
    }
    while(
timestamp>60)
    {
        
timestamp -= 60mins++;
         if( 
mins == 60mins=0hour++;
    }
    
sec=timestamp;
    switch( 
_form )
    {
        case 
1format(returnstring31"%02d/%02d/%d %02d:%02d:%02d"day+1month+1yearhourminssec);
        case 
2format(returnstring31"%s %02d, %d, %02d:%02d:%02d"names_of_month[month],day+1,yearhourminssec);
        case 
3format(returnstring31"%d %c%c%c %d, %02d:%02d"day+1,names_of_month[month][0],names_of_month[month][1],names_of_month[month][2], year,hour,mins);
        default: 
format(returnstring31"%02d.%02d.%d %02d:%02d:%02d"day+1month+1yearhourminssec);
    }
    return 
returnstring;

Mivco is offline   Reply With Quote
Old 14/01/2017, 11:29 AM   #2
Mivco
Big Clucker
 
Mivco's Avatar
 
Join Date: Mar 2015
Location: Slovakia
Posts: 59
Reputation: 0
Default Re: Help timeban

Help me
Mivco is offline   Reply With Quote
Old 17/01/2017, 08:28 PM   #3
Mivco
Big Clucker
 
Mivco's Avatar
 
Join Date: Mar 2015
Location: Slovakia
Posts: 59
Reputation: 0
Default Re: Help timeban

Help me
Mivco is offline   Reply With Quote
Old 17/01/2017, 08:36 PM   #4
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: Help timeban

pawn Code:
new strong[100];
if(fexist(strong))
You have a problem right off the bat - the "strong" string array is empty, so it will always return false
Misiur is offline   Reply With Quote
Old 17/01/2017, 08:41 PM   #5
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,070
Reputation: 2655
Default Re: Help timeban

There are so many flaws that I don't even know where to start.

You declare an empty string "strong". Then you check if a file exists, which name is stored in variable "strong". Since we have just established that "strong" is empty you're checking if, um, nothing exists. Of course this check fails so anything after that automatically becomes useless.

In that block (that doesn't get executed, anyway) you declare an empty variable string and you do pretty much the same thing. You try to get the integer value of string, but since we have established that this variable is empty you will just get 0 all the time.

Also read the manual on Y_INI because you're doing it totally and utterly wrong.

Excuse me if this seemed rude but it's been three days and you've made no effort to solve your own problem by doing, you know, research.
__________________
Vince is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
timeban GeneralAref Scripting Help 4 07/04/2016 06:21 PM
ban cmd > timeban pls! rouse Scripting Help 1 15/03/2016 08:52 PM
[NEED] Timeban Fantje Scripting Help 2 15/03/2015 01:32 PM
Timeban EmpireSk Scripting Help 2 14/01/2015 08:23 PM
Timeban sim_sima Scripting Help 3 23/11/2011 01:24 PM


All times are GMT. The time now is 05:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.