Server shutdown after type command
#1

Hello i got issue so when i type command /ban id days reason server shutdown
server-log showing
Код:
 sscanf warning: Strings without a length are deprecated, please add a destination size.
*** YSI Error: INI_Open could not find or create file /Bans/Test_Player.ini
Command
Код:
CMD:ban(playerid,parmas[])
{
    if(pInfo[playerid][pAdminLevel] >= 3)
    {
    new tid,du,res[150],ppp[50];
    if(sscanf(parmas,"uis",tid,du,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /ban id duration(In Days) Reason");
    if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
    new banmt[300],banma[300],adminname[MAX_PLAYER_NAME],targetn[MAX_PLAYER_NAME];
    GetPlayerName(playerid,adminname,sizeof(adminname));
    new exp=gettime()+(60*60*24*du);
    GetPlayerIp(tid,ppp,sizeof(ppp));
    new INI:File = INI_Open(UserBanPath(tid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Banexp",exp);
    INI_WriteInt(File,"BanPerm",0);
    INI_WriteString(File,"BanAdmin",adminname);
    INI_WriteString(File,"Reason",res);
    INI_WriteString(File,"IP",ppp);
    INI_Close(File);
    GetPlayerName(tid,targetn,sizeof(targetn));
    new INI:iFile = INI_Open(UserIPPath(tid));
    INI_SetTag(iFile,"data");
    INI_WriteInt(iFile,"Banexp",exp);
    INI_WriteInt(iFile,"BanPerm",0);
    INI_WriteString(iFile,"BanPlayer",targetn);
    INI_WriteString(iFile,"BanAdmin",adminname);
    INI_WriteString(iFile,"Reason",res);
    INI_Close(iFile);
    new File:logg=fopen("BannedPlayers.txt",io_append);
    fwrite(logg, targetn);
    fwrite(logg,"\n");
    fclose(logg);
    format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for %i days due to %s",adminname,du,res);
    format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s for %i days due to %s",adminname,targetn,du,res);
    SendClientMessage(tid,-1,banmt);
    SendClientMessageToAll(-1,banma);
    SetTimerEx("KickPlayer",100,false,"i",tid);
    }
	else SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
    return 1;
}
Reply
#2

PHP код:
CMD:ban(playerid,parmas[])
{
    if(
pInfo[playerid][pAdminLevel] >= 3)
    {
        new 
tid,du,res[150],ppp[50];
        if(
sscanf(parmas,"uis[150]",tid,du,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /ban id duration(In Days) Reason");
        if(!
IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
        new 
banmt[300],banma[300],adminname[MAX_PLAYER_NAME],targetn[MAX_PLAYER_NAME];
        
GetPlayerName(playerid,adminname,sizeof(adminname));
        new 
exp=gettime()+(60*60*24*du);
        
GetPlayerIp(tid,ppp,sizeof(ppp));
        new 
INI:File INI_Open(UserBanPath(tid));
        
INI_SetTag(File,"data");
        
INI_WriteInt(File,"Banexp",exp);
        
INI_WriteInt(File,"BanPerm",0);
        
INI_WriteString(File,"BanAdmin",adminname);
        
INI_WriteString(File,"Reason",res);
        
INI_WriteString(File,"IP",ppp);
        
INI_Close(File);
        
GetPlayerName(tid,targetn,sizeof(targetn));
        new 
INI:iFile INI_Open(UserIPPath(tid));
        
INI_SetTag(iFile,"data");
        
INI_WriteInt(iFile,"Banexp",exp);
        
INI_WriteInt(iFile,"BanPerm",0);
        
INI_WriteString(iFile,"BanPlayer",targetn);
        
INI_WriteString(iFile,"BanAdmin",adminname);
        
INI_WriteString(iFile,"Reason",res);
        
INI_Close(iFile);
        new 
File:logg=fopen("BannedPlayers.txt",io_append);
        
fwrite(loggtargetn);
        
fwrite(logg,"\n");
        
fclose(logg);
        
format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for %i days due to %s",adminname,du,res);
        
format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s for %i days due to %s",adminname,targetn,du,res);
        
SendClientMessage(tid,-1,banmt);
        
SendClientMessageToAll(-1,banma);
        
SetTimerEx("KickPlayer",100,false,"i",tid);
    }
    else 
SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
    return 
1;

1- use this code ^^
2- create directory scriptfiles/Bans/

3 - use crashdetect plugin

test it and post logs here
Reply
#3

You should check if the file was opened successfully! otherwise if you write on a non-opened file it will crash. (Kos has once helped me with this)
Reply
#4

Ok i didn't get any sscanf warnning and find problems bat its till shut down me server
server-log just show this
ECBA4008B06DAE4A063C6AF82DBE1D85C2AFE9A62CBE81F659 C1A5EE3DBFEA1A686508EA42FE0B1F14B5D0C3A93BCE93EF72 7C78BA811C6C895416D8AC0D3B56
Reply
#5

Help please
Reply
#6

Crashdetect show this
Код:
[00:33:27] [debug] Run time error 6: "Invalid instruction"
[00:33:27] [debug]  Unknown opcode 0x3afa900 at address 0x00000038
[00:33:27] [debug] AMX backtrace:
[00:33:27] [debug] #0 00000038 in public cmd_ban () from zma.amx
[00:33:27] [debug] #1 native CallLocalFunction () from samp-server.exe
[00:33:27] [debug] #2 00000748 in public OnPlayerCommandText (0, 7030768) from zma.amx
[00:33:28] [chat] [Henry_Groc]: ha
[00:33:33] [debug] Run time error 4: "Array index out of bounds"
[00:33:33] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[00:33:33] [debug] AMX backtrace:
[00:33:33] [debug] #0 00031ec8 in public OnPlayerTakeDamage (0, 65535, 1084122727, 54, 3) from zma.amx
[00:33:39] [debug] Run time error 4: "Array index out of bounds"
[00:33:39] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[00:33:39] [debug] AMX backtrace:
[00:33:39] [debug] #0 00031ec8 in public OnPlayerTakeDamage (0, 65535, 1084122727, 54, 3) from zma.amx
[00:34:09] [debug] Run time error 6: "Invalid instruction"
[00:34:09] [debug]  Unknown opcode 0x203af at address 0x00000032
[00:34:09] [debug] AMX backtrace:
[00:34:09] [debug] #0 00000032 in public cmd_ban () from zma.amx
[00:34:09] [debug] #1 native CallLocalFunction () from samp-server.exe
[00:34:09] [debug] #2 00000748 in public OnPlayerCommandText (0, 7030768) from zma.amx
[00:34:11] [debug] Run time error 4: "Array index out of bounds"
[00:34:11] [debug]  Attempted to read/write array element at negative index -1
[00:34:11] [debug] AMX backtrace:
[00:34:11] [debug] #0 0001d084 in ?? (-1) from zma.amx
[00:34:11] [debug] #1 0004a6f0 in ?? (0) from zma.amx
[00:34:11] [debug] #2 00029b04 in public FIXES_OnPlayerDisconnect (0, 1) from zma.amx
[00:34:11] [debug] #3 native CallLocalFunction () from samp-server.exe
[00:34:11] [debug] #4 00023310 in public Streamer_OnPlayerDisconnect (0, 1) from zma.amx
[00:34:11] [debug] #5 native CallLocalFunction () from samp-server.exe
[00:34:11] [debug] #6 0002008c in public Itter_OnPlayerDisconnect (0, 1) from zma.amx
[00:34:11] [debug] #7 native CallLocalFunction () from samp-server.exe
[00:34:11] [debug] #8 00006efc in public SSCANF_OnPlayerDisconnect (0, 1) from zma.amx
[00:34:11] [debug] #9 00000cf8 in public OnPlayerDisconnect (0, 1) from zma.amx
Reply
#7

up up up
Reply
#8

Do i have to repeat what i said above? che if the damn file is open before writing and come back here with report.
Reply
#9

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Do i have to repeat what i said above? che if the damn file is open before writing and come back here with report.
It would be nice if you explain better.
Reply
#10

I used this system https://sampforum.blast.hk/showthread.php?tid=503631
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)