Jump to content
  • 0

pomoc Timeban


Mivčo

Dotaz

Zdravim upravil som si timeban od QWER

 

 

 

#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(strong, sizeof(strong),"Nick: %s \n", Jmeno(playerid));

strcat(ban,strong);

format(strong, sizeof(strong),"IP: %s \n", ip);

strcat(ban,strong);

format(strong, sizeof(strong), "Dôvod: %s \n", dovod);

strcat(ban,strong);

format(strong, sizeof(strong), "Admin: %s \n", Admin);

strcat(ban,strong);

format(strong, sizeof(strong), "Kedy: %s \n", date(strval(string)));

strcat(ban,strong);

format(strong, sizeof(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(playerid, params[])

{

//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(strong, sizeof(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(i < len+1)

{

if(i == len && chcount != 0)

{

strmid(variables[varcount],str,start+1,strlen(str),128);

chcount++;

}

if(str == cha)

{

if((m == 0) || (chcount != m-1))

{

strmid(variables[varcount],str,start + ((start == 0) ? 0 : 1),i,128);

start = i;

chcount++;

varcount++;

}

}

i++;

}

return chcount;

}

 

stock date( timestamp, _form=1 )

{

new year=1970, day=0, month=0, hour=0, mins=0, sec=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 % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) timestamp -= 86400;

year++;

}

if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) )

days_of_month[1] = 29;

else

days_of_month[1] = 28;

while(timestamp>86400)

{

timestamp -= 86400, day++;

if(day==days_of_month[month]) day=0, month++;

}

while(timestamp>60)

{

timestamp -= 60, mins++;

if( mins == 60) mins=0, hour++;

}

sec=timestamp;

switch( _form )

{

case 1: format(returnstring, 31, "%02d/%02d/%d %02d:%02d:%02d", day+1, month+1, year, hour, mins, sec);

case 2: format(returnstring, 31, "%s %02d, %d, %02d:%02d:%02d", names_of_month[month],day+1,year, hour, mins, sec);

case 3: format(returnstring, 31, "%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(returnstring, 31, "%02d.%02d.%d %02d:%02d:%02d", day+1, month+1, year, hour, mins, sec);

}

return returnstring;

}

 

 

Keď na servery chcem niekoho zabanovať tak nikoho nezabanuje a neuloží nič do zložky... Jak to a pre čo? Už sa stím trápim celé hodiny -_-

Link to comment
Share on other sites

Recommended Posts

  • 0
  • Globální moderátor

1) Vyzkoušet můžeš tím, že si opravíš tu chybu se zapisováním (po 4. ti to říkám)

2) tak to mě mrzí :(

 

 

napsal jsem ti příklad se zapisováním... 

new name[24];
GetPlayerName(playerid,name,sizeof(name));
INI_WriteString(Fi:soubor,"Jmeno",name);

takže jestli nevíš jak pohnout, proč vlastně ještě děláš v pawnu?

Edited by HighPrint
Link to comment
Share on other sites

  • 0

 

 

Chceš ty data ČÍST (read) a ne ZAPISOVAT (write)
 

 

Mivčo, ty tam máš Write, musíš tam dát funkci na čtení, v tom je ta chyba co ti tu furt říká se zapisováním...

Jestli jsem teda pochopil dobře... :d

Link to comment
Share on other sites

  • 0

Ale keď zadám /ban tak v chate mi neukáže že hráč bol zabanovaný a nedá ani kick..... V zložke vytvorý meno hráča ale je prázdny... Riadil som sa podľa registračky čo mám ale tá mi funguje normálne....

Link to comment
Share on other sites

  • 0

Jestli jsem teda pochopil dobře... :d

Ne, nepochopil jsi to správně. Ty fce na načítání začnou pouze v patřičném callbacku, protože potřebují 2 parametry(name[] a value[]).

Link to comment
Share on other sites

  • 0

Jestli jsem teda pochopil dobře... :d

Ked zadam prikaz /ban tak txt subor sa vytvori ale v nom nič neukaze a ked a ked cítat jedine ked hrac pride na server na ukaze sa mu ze este je zabanovany alebo neni :)

Link to comment
Share on other sites

  • 0
  • Hlavní moderátor

Očividně ti nikdo nehodlá pomoci, tak tě (asi už posté) odkážu na asi nejlepší návod. Když si to nastuduješ, možná se někam pohneš.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...