Server Crashing after Command
#1

My server crash after command for showing admin slots. I am beginner so sry for bad code . Pls help
Код:
CMD:adminlist(playerid,params[])
{
	new afile[65];
	new test[35];
	new test1[800];
	new test2[128];
	for(new i = 0; i < 20; i++)
	{
		format(afile,sizeof(afile),"admini/%d.txt",i);
	        new File:adminfile = fopen(afile,io_read);
		fread(adminfile,test);
		fclose(adminfile);
		format(test2,sizeof(test2),"%s\n",test);
		strcat(test1,test2);
	}
	return 1;
}
CrashInfo
Код:
Loaded Modules:

samp-server.exe	A: 0x00400000 - 0x00519000	(C:\Users\x\Desktop\Old Express\samp-server.exe)

ntdll.dll	A: 0x76F40000 - 0x770D0000	(C:\WINDOWS\SYSTEM32\ntdll.dll)

KERNEL32.DLL	A: 0x76CF0000 - 0x76DD0000	(C:\WINDOWS\System32\KERNEL32.DLL)

KERNELBASE.dll	A: 0x75810000 - 0x759F4000	(C:\WINDOWS\System32\KERNELBASE.dll)

SHELL32.dll	A: 0x73BE0000 - 0x74F2A000	(C:\WINDOWS\System32\SHELL32.dll)

msvcrt.dll	A: 0x76AA0000 - 0x76B5F000	(C:\WINDOWS\System32\msvcrt.dll)

cfgmgr32.dll	A: 0x76810000 - 0x76849000	(C:\WINDOWS\System32\cfgmgr32.dll)

ucrtbase.dll	A: 0x76B80000 - 0x76C9E000	(C:\WINDOWS\System32\ucrtbase.dll)

shcore.dll	A: 0x752F0000 - 0x75378000	(C:\WINDOWS\System32\shcore.dll)

RPCRT4.dll	A: 0x74FB0000 - 0x75070000	(C:\WINDOWS\System32\RPCRT4.dll)

SspiCli.dll	A: 0x73800000 - 0x73820000	(C:\WINDOWS\System32\SspiCli.dll)

CRYPTBASE.dll	A: 0x737F0000 - 0x737FA000	(C:\WINDOWS\System32\CRYPTBASE.dll)

bcryptPrimitives.dll	A: 0x76540000 - 0x76598000	(C:\WINDOWS\System32\bcryptPrimitives.dll)

sechost.dll	A: 0x767C0000 - 0x76804000	(C:\WINDOWS\System32\sechost.dll)

combase.dll	A: 0x73940000 - 0x73B9C000	(C:\WINDOWS\System32\combase.dll)

windows.storage.dll	A: 0x75A10000 - 0x75FCA000	(C:\WINDOWS\System32\windows.storage.dll)

advapi32.dll	A: 0x74F30000 - 0x74FA8000	(C:\WINDOWS\System32\advapi32.dll)

shlwapi.dll	A: 0x73880000 - 0x738C5000	(C:\WINDOWS\System32\shlwapi.dll)

GDI32.dll	A: 0x75FD0000 - 0x75FF2000	(C:\WINDOWS\System32\GDI32.dll)

gdi32full.dll	A: 0x75090000 - 0x751F4000	(C:\WINDOWS\System32\gdi32full.dll)

msvcp_win.dll	A: 0x76DD0000 - 0x76E4D000	(C:\WINDOWS\System32\msvcp_win.dll)

USER32.dll	A: 0x765A0000 - 0x7672D000	(C:\WINDOWS\System32\USER32.dll)

win32u.dll	A: 0x76B60000 - 0x76B77000	(C:\WINDOWS\System32\win32u.dll)

kernel.appcore.dll	A: 0x76530000 - 0x7653F000	(C:\WINDOWS\System32\kernel.appcore.dll)

profapi.dll	A: 0x75260000 - 0x75278000	(C:\WINDOWS\System32\profapi.dll)

powrprof.dll	A: 0x76900000 - 0x76945000	(C:\WINDOWS\System32\powrprof.dll)

FLTLIB.DLL	A: 0x75600000 - 0x75608000	(C:\WINDOWS\System32\FLTLIB.DLL)

WSOCK32.dll	A: 0x69050000 - 0x69058000	(C:\WINDOWS\SYSTEM32\WSOCK32.dll)

WS2_32.dll	A: 0x75280000 - 0x752E7000	(C:\WINDOWS\System32\WS2_32.dll)

WINMM.dll	A: 0x710D0000 - 0x710F4000	(C:\WINDOWS\SYSTEM32\WINMM.dll)

WINMMBASE.dll	A: 0x70800000 - 0x70823000	(C:\WINDOWS\SYSTEM32\WINMMBASE.dll)

IMM32.DLL	A: 0x73BA0000 - 0x73BC6000	(C:\WINDOWS\System32\IMM32.DLL)

sscanf.dll	A: 0x10000000 - 0x1000F000	(C:\Users\x\Desktop\Old Express\plugins\sscanf.dll)

VCRUNTIME140.dll	A: 0x71100000 - 0x71115000	(C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll)

mswsock.dll	A: 0x6F210000 - 0x6F266000	(C:\WINDOWS\system32\mswsock.dll)

napinsp.dll	A: 0x71E00000 - 0x71E11000	(C:\WINDOWS\system32\napinsp.dll)

pnrpnsp.dll	A: 0x71DE0000 - 0x71DF6000	(C:\WINDOWS\system32\pnrpnsp.dll)

NLAapi.dll	A: 0x71DC0000 - 0x71DD3000	(C:\WINDOWS\system32\NLAapi.dll)

DNSAPI.dll	A: 0x70830000 - 0x708BE000	(C:\WINDOWS\SYSTEM32\DNSAPI.dll)

NSI.dll	A: 0x738D0000 - 0x738D7000	(C:\WINDOWS\System32\NSI.dll)

IPHLPAPI.DLL	A: 0x72F60000 - 0x72F90000	(C:\WINDOWS\SYSTEM32\IPHLPAPI.DLL)

winrnr.dll	A: 0x71DB0000 - 0x71DBC000	(C:\WINDOWS\System32\winrnr.dll)

bcrypt.dll	A: 0x6F2C0000 - 0x6F2D9000	(C:\WINDOWS\SYSTEM32\bcrypt.dll)

rasadhlp.dll	A: 0x68C90000 - 0x68C98000	(C:\Windows\System32\rasadhlp.dll)
Reply
#2

I recommend using Crashdetect plugin to know exactly why, however there's a chance that the file handle (in your case - adminfile is invalid)

Try:
Код:
    for(new i = 0; i < 20; i++)
    {
        format(afile,sizeof(afile),"admini/%d.txt",i);
            new File:adminfile = fopen(afile,io_read);
        if(adminfile)
        {
            fread(adminfile,test);
            fclose(adminfile);
            format(test2,sizeof(test2),"%s\n",test);
            strcat(test1,test2);
         }
         else
            printf("[ERROR] file admini/%d.txt doesn't exist", i), continue;   
    }
Reply
#3

Try cmd .Chance variable admins

CMD:admins(playerid,params[])
{
foreach(Player, i)
{
new level[128],status[200], string[128];

if(PlayerInfo[i][pAdmin] >= 1)
{
switch(PlayerInfo[i][pAdmin])
{
case 1: level = "[Trial Staff Member] ";
case 2: level = "[Junior Moderator] ";
case 3: level = "[Moderator] ";
case 4: level = "[Junior Admin] ";
case 5: level = "[Lead Admin] ";
case 6: level = "[Community Co-Owner] ";
case 7: level = "[Community Owner] ";
}
// Other if ststement removed to stop copying of my main code
format(string, sizeof(string), "%s %s\n", level, GetName(i));
ShowPlayerDialog(playerid, DIALOG_ONLINE_ADMINS, DIALOG_STYLE_LIST, "Online Staff", string, "Close", "");
}
else{
ShowPlayerDialog(playerid, DIALOG_ONLINE_ADMINS, DIALOG_STYLE_LIST, "Online Staff", "[SERVER] Anti-Cheat Is: Administrating", "Close", "");
}
}
return 1;
}
Reply
#4

Quote:
Originally Posted by Itzhak E.
Посмотреть сообщение
I recommend using Crashdetect plugin to know exactly why, however there's a chance that the file handle (in your case - adminfile is invalid)

Try:
Код:
    for(new i = 0; i < 20; i++)
    {
        format(afile,sizeof(afile),"admini/%d.txt",i);
            new File:adminfile = fopen(afile,io_read);
        if(adminfile)
        {
            fread(adminfile,test);
            fclose(adminfile);
            format(test2,sizeof(test2),"%s\n",test);
            strcat(test1,test2);
         }
         else
            printf("[ERROR] file admini/%d.txt doesn't exist", i), continue;   
    }
its still crashing . I will try to see with crashdetect what is happening.
Quote:
Originally Posted by nbx2000
Посмотреть сообщение
Try cmd .Chance variable admins

CMD:admins(playerid,params[])
{
foreach(Player, i)
{
new level[128],status[200], string[128];

if(PlayerInfo[i][pAdmin] >= 1)
{
switch(PlayerInfo[i][pAdmin])
{
case 1: level = "[Trial Staff Member] ";
case 2: level = "[Junior Moderator] ";
case 3: level = "[Moderator] ";
case 4: level = "[Junior Admin] ";
case 5: level = "[Lead Admin] ";
case 6: level = "[Community Co-Owner] ";
case 7: level = "[Community Owner] ";
}
// Other if ststement removed to stop copying of my main code
format(string, sizeof(string), "%s %s\n", level, GetName(i));
ShowPlayerDialog(playerid, DIALOG_ONLINE_ADMINS, DIALOG_STYLE_LIST, "Online Staff", string, "Close", "");
}
else{
ShowPlayerDialog(playerid, DIALOG_ONLINE_ADMINS, DIALOG_STYLE_LIST, "Online Staff", "[SERVER] Anti-Cheat Is: Administrating", "Close", "");
}
}
return 1;
}
Am i dont need Online staff i need to read from slot files and write name of players on slots
Reply
#5

I would suggest, that the folder "admini" doesn't exist.

You should write it like this:

PHP код:
CMD:adminlist(playerid)
{
    const 
MAX_ADMINS 20;
    new 
tmp[32],string[MAX_PLAYER_NAME*MAX_ADMINS];
    for(new 
i,File:fMAX_ADMINSi++)
    {
        
format(tmp,sizeof(tmp),"admini/%d.txt",i);
        if(!
fexist(tmp)) continue;
        
fopen(tmp,io_read),fread(f,tmp),fclose(f),
        
strcat(string,tmp),strcat(string,"\n");
    }
    return 
1;

But actually it would be smarter...to write it all in one file, or use a database like MySQL or SQLite
Reply
#6

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
I would suggest, that the folder "admini" doesn't exist.

You should write it like this:

PHP код:
CMD:adminlist(playerid)
{
    const 
MAX_ADMINS 20;
    new 
tmp[32],string[MAX_PLAYER_NAME*MAX_ADMINS];
    for(new 
i,File:fMAX_ADMINSi++)
    {
        
format(tmp,sizeof(tmp),"admini/%d.txt",i);
        if(!
fexist(tmp)) continue;
        
fopen(tmp,io_read),fread(f,tmp),fclose(f),
        
strcat(string,tmp),strcat(string,"\n");
    }
    return 
1;

But actually it would be smarter...to write it all in one file, or use a database like MySQL or SQLite
TY its working now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)