Can't figure it out
#1

This is my code for banning and unbanning players offline:
PHP код:
new bool:OfflineuserbanningBanned[MAX_PLAYERS];
new 
bool:OfflineuserbanningTempBanned[MAX_PLAYERS];
new 
OfflineuserbanningAdminLevel[MAX_PLAYERS];
// /unban
dcmd_unban(playeridparams[])
{
    new 
pName[MAX_PLAYER_NAME], string[64];
    if(
PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playeridCOLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
    if(
PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This command is unavailable for your admin rank.");
    if(!
admduty[playerid]) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: You must be on duty to use this command.");
    if(
sscanf(params"s[24]"pName)) return SendClientMessage(playeridCOLOR_ADMINBLUE"Correct usage: /unban [username]");
    
format(stringsizeof(string), PATHstrlower(pName));
    if(!
fexist(string)) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user does not exist.");
    
INI_ParseFile(string"LoadBan_%s", .bExtra true, .extra playerid);
    if(!
OfflineuserbanningBanned[playerid] && !OfflineuserbanningTempBanned[playerid]) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user is not banned.");
    new 
INI:File INI_Open(string);
    
INI_SetTag(File"data");
    
INI_WriteBool(File"Banned"false);
    
INI_WriteString(File"Banningdate""-");
    
INI_WriteInt(File"Bandays"0);
    
INI_WriteInt(File"Unbandate"gettime());
    
INI_Close(File);
    
format(stringsizeof(string), "User %s has been unbanned."pName);
    
SendClientMessage(playeridCOLOR_ADMINBLUEstring);
    return 
1;
}
// //opermban
dcmd_opermban(playeridparams[])
{
    new 
reason[32], playername[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], string[128], ip[MAX_IP_SIZE], yearmonthdayhourminutesecond;
    
GetPlayerName(playeridplayernamesizeof(playername));
    if(
PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playeridCOLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
    if(
PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This command is unavailable for your admin rank.");
    if(!
admduty[playerid]) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: You must be on duty to use this command.");
    if(
sscanf(params"s[24]s[32]"pNamereason)) return SendClientMessage(playeridCOLOR_ADMINBLUE"Correct usage: /opermban [name] [reason]");
    for(new 
i=0;i<MAX_PLAYERS;i++)
    {
        if(
IsPlayerConnected(i))
        {
            new 
iName[MAX_PLAYER_NAME];
            
GetPlayerName(iiNamesizeof(iName));
            if(
strcmp(iNamepNametrueMAX_PLAYER_NAME)==0) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This player is already connected.");
        }
    }
    if(
strcmp(playernamepNametrueMAX_PLAYER_NAME)==0) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: You cannot ban yourself.");
    
format(stringsizeof(string), PATHstrlower(pName));
    if(!
fexist(string)) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user does not exist.");
    new 
INI:File INI_Open(string);
    
getdate(yearmonthday);
    
gettime(hourminutesecond);
    
INI_ParseFile(string"LoadBan_%s", .bExtra true, .extra playerid);
    if(
OfflineuserbanningBanned[playerid]) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user is already banned.");
    if(
OfflineuserbanningTempBanned[playerid]) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user is already under a temporary ban. If you wish to permanently ban this player, use /unban first and then /opermban.");
    if(
OfflineuserbanningAdminLevel[playerid] > PlayerInfo[playerid][pAdmin] && PlayerInfo[playerid][pAdmin]!=10) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: You cannot ban another admin.");
    
INI_SetTag(File,"data");
    
INI_WriteBool(File,"Banned",true);
    
INI_WriteString(File,"Banreason"reason);
    if(
PlayerInfo[playerid][pAdmin]==10INI_WriteString(File,"Adminwhobanned""AmalM");
    else 
INI_WriteString(File,"Adminwhobanned"playername);
    
INI_Close(File);
    new 
File:banlist=fopen("/Logs/OfflineBanlog.log"io_append);
    
GetPlayerIp(playeridipsizeof(ip));
    
format(stringsizeof(string), "%s, %s, %d:%d:%d,%d:%d:%d (%s)\r\n"pNameipdaymonthyearhourminutesecondplayername);
    
fwrite(banliststring);
    
fclose(banlist);
    
format(stringsizeof(string), "Admin-ban: %s has been banned from the server by %s (%d) (Reason: %s)."pNameplayernameplayeridreason);
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
PlayerInfo[i][pAdmin]>0)
            {
                
SendClientMessage(iCOLOR_ADMINBLUEstring);
            }
        }
    }
    return 
1;
}
// //otempban
dcmd_otempban(playeridparams[])
{
    new 
reason[32], playername[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], daysstring[128], ip[MAX_IP_SIZE], yearmonthdayhourminutesecond;
    
GetPlayerName(playeridplayernamesizeof(playername));
    if(
PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playeridCOLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
    if(
PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This command is unavailable for your admin rank.");
    if(!
admduty[playerid]) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: You must be on duty to use this command.");
    if(
sscanf(params"s[24]is[32]"pNamedaysreason)) return SendClientMessage(playeridCOLOR_ADMINBLUE"Correct usage: /otempban [name] [days] [reason]");
    for(new 
i=0;i<MAX_PLAYERS;i++)
    {
        if(
IsPlayerConnected(i))
        {
            new 
iName[MAX_PLAYER_NAME];
            
GetPlayerName(iiNamesizeof(iName));
            if(
strcmp(iNamepNametrueMAX_PLAYER_NAME)==0) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This player is already connected.");
        }
    }
    if(
strcmp(playernamepNametrueMAX_PLAYER_NAME)==0) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: You cannot ban yourself.");
    
format(stringsizeof(string), PATHstrlower(pName));
    if(!
fexist(string)) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user does not exist.");
    new 
INI:File INI_Open(string);
    
getdate(yearmonthday);
    
gettime(hourminutesecond);
    
INI_ParseFile(string"LoadBan_%s", .bExtra true, .extra playerid);
    if(
OfflineuserbanningBanned[playerid] || OfflineuserbanningTempBanned[playerid]) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user is already under a ban. If you wish to change the ban details, use /unban first and then /otempban.");
    if(
OfflineuserbanningAdminLevel[playerid] > PlayerInfo[playerid][pAdmin] && PlayerInfo[playerid][pAdmin]!=10) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: You cannot ban another admin.");
    
INI_SetTag(File,"data");
    
INI_WriteString(File,"Banreason"reason);
    
format(stringsizeof(string), "%d/%d/%d"daymonthyear);
       
INI_WriteString(File,"Banningdate"string);
    
INI_WriteInt(File,"Bandays"days);
    
INI_WriteInt(File,"Unbandate"gettime()+(days*86400));
    if(
PlayerInfo[playerid][pAdmin]==10INI_WriteString(File,"Adminwhobanned""AmalM");
    else 
INI_WriteString(File,"Adminwhobanned"playername);
    
INI_Close(File);
    new 
File:banlist=fopen("/Logs/OfflineBanlog.log"io_append);
    
GetPlayerIp(playeridipsizeof(ip));
    
format(stringsizeof(string), "%s, %s, %d:%d:%d,%d:%d:%d (%s)\r\n"pNameipdaymonthyearhourminutesecondplayername);
    
fwrite(banliststring);
    
fclose(banlist);
    
format(stringsizeof(string), "Admin-ban: %s has been banned from the server for %d days by %s (%d) (Reason: %s)."pNamedaysplayernameplayeridreason);
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
PlayerInfo[i][pAdmin]>0)
            {
                
SendClientMessage(iCOLOR_ADMINBLUEstring);
            }
        }
    }
    return 
1;
}
    
forward LoadBan_data(playeridname[], value[]);
public 
LoadBan_data(playeridname[], value[])
{
    new 
tempbandate;
    
INI_Bool("Banned"OfflineuserbanningBanned[playerid]);
    
INI_Int("Unbandate"tempbandate);
    if(
gettime()<tempbandateOfflineuserbanningTempBanned[playerid]=true;
    
INI_Int("Admin"OfflineuserbanningAdminLevel[playerid]);
    return 
1;

It's kinda weird because it works only one time but no more. Whenever I performs this command after once, it says "SERVER: Unknown command.". It even crashed once. All the checks (if) are working but it returns this unknown command error when the writing part comes. I used to crashdetect to get all runtime errors and crash log.
This is what I got:
pawn Код:
[03:32:13] [debug] Run time error 6: "Invalid instruction"
[03:32:13] [debug]  Unknown opcode 0x74000000 at address 0x00000035
[03:32:13] [debug] AMX backtrace:
[03:32:13] [debug] #0 00000035 in public OnPlayerCommandText () at <unknown file>:0
[03:32:15] [debug] Run time error 6: "Invalid instruction"
[03:32:15] [debug]  Unknown opcode 0x74000000 at address 0x00000035
[03:32:15] [debug] AMX backtrace:
[03:32:15] [debug] #0 00000035 in public OnPlayerCommandText () at <unknown file>:0
[03:33:04] [debug] Run time error 6: "Invalid instruction"
[03:33:04] [debug]  Unknown opcode 0x74000000 at address 0x00000035
[03:33:04] [debug] AMX backtrace:
[03:33:04] [debug] #0 00000035 in public OnPlayerCommandText () at <unknown file>:0
[03:33:43] [debug] Server crashed while executing SARCR.amx
[03:33:43] [debug] AMX backtrace:
[03:33:43] [debug] #0 00000034 in INI_AddToBuffer (INI:file=51, name[]=@00000000 "", data[]=@01683df8 "0000001429567423") at <unknown file>:0
[03:33:43] [debug] #1 00018634 in ?? (str[]=@00000033 "", ... <11 arguments>) at E:\San Andreas Roleplay Cops And Robbers\pawno\include\YSI\y_ini.inc:1076
[03:33:43] [debug] #2 00000034 in public OnPlayerCommandText () at <unknown file>:0
[03:33:43] [debug] Native backtrace:
[03:33:43] [debug] #0 59407e3f in ?? () from plugins\crashdetect.dll
[03:33:43] [debug] #1 594009c7 in ?? () from plugins\crashdetect.dll
[03:33:43] [debug] #2 5940631a in ?? () from plugins\crashdetect.dll
[03:33:43] [debug] #3 59844885 in ?? () from plugins\streamer.dll
[03:33:43] [debug] #4 0046cfd0 in ?? () from samp-server.exe
[03:33:43] [debug] #5 00452970 in ?? () from samp-server.exe
[03:33:43] [debug] #6 00499cd9 in ?? () from samp-server.exe
[03:33:43] [debug] #7 004a50fe in ?? () from samp-server.exe
[03:33:43] [debug] Server crashed while executing SARCR.amx
[03:33:43] [debug] AMX backtrace:
[03:33:43] [debug] #0 00000034 in INI_AddToBuffer (INI:file=51, name[]=@00000000 "", data[]=@01683df8 "0000001429567423") at <unknown file>:0
[03:33:43] [debug] #1 00018634 in ?? (str[]=@00000033 "", ... <11 arguments>) at E:\San Andreas Roleplay Cops And Robbers\pawno\include\YSI\y_ini.inc:1076
[03:33:43] [debug] #2 00000034 in public OnPlayerCommandText () at <unknown file>:0
[03:33:43] [debug] Native backtrace:
[03:33:43] [debug] #0 76f61f70 in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[03:33:43] [debug] #1 765af1ac in ?? () from C:\Windows\system32\kernel32.dll
[03:33:43] [debug] #2 00493bf1 in ?? () from samp-server.exe
[03:33:43] [debug] #3 0044e129 in ?? () from samp-server.exe
[03:33:43] [debug] #4 00458bcc in ?? () from samp-server.exe
[03:33:43] [debug] #5 00010100 in ?? ()
[03:33:43] [debug] #6 0045a3b0 in ?? () from samp-server.exe
[03:33:43] [debug] #7 0045a650 in ?? () from samp-server.exe
[03:33:43] [debug] #8 0045b040 in ?? () from samp-server.exe
[03:33:43] [debug] #9 00450660 in ?? () from samp-server.exe
[03:33:43] [debug] #10 00450670 in ?? () from samp-server.exe
[03:33:43] [debug] #11 00450680 in ?? () from samp-server.exe
[03:33:43] [debug] #12 004506d0 in ?? () from samp-server.exe
[03:33:43] [debug] #13 00458160 in ?? () from samp-server.exe
[03:33:43] [debug] #14 0045b050 in ?? () from samp-server.exe
[03:33:43] [debug] #15 0045b060 in ?? () from samp-server.exe
[03:33:43] [debug] #16 00450720 in ?? () from samp-server.exe
[03:33:43] [debug] #17 0045b070 in ?? () from samp-server.exe
[03:33:43] [debug] #18 0045b080 in ?? () from samp-server.exe
[03:33:43] [debug] #19 0045b630 in ?? () from samp-server.exe
[03:33:43] [debug] #20 0045b090 in ?? () from samp-server.exe
[03:33:43] [debug] #21 00450830 in ?? () from samp-server.exe
[03:33:43] [debug] #22 0045b0a0 in ?? () from samp-server.exe
[03:33:43] [debug] #23 0045b0b0 in ?? () from samp-server.exe
[03:33:43] [debug] #24 0045b0c0 in ?? () from samp-server.exe
[03:33:43] [debug] #25 0045b0d0 in ?? () from samp-server.exe
[03:33:43] [debug] #26 0045b0e0 in ?? () from samp-server.exe
[03:33:43] [debug] #27 00458610 in ?? () from samp-server.exe
[03:33:43] [debug] #28 0045b0f0 in ?? () from samp-server.exe
[03:33:43] [debug] #29 0045b100 in ?? () from samp-server.exe
[03:33:43] [debug] #30 00452210 in ?? () from samp-server.exe
[03:33:43] [debug] #31 0045b110 in ?? () from samp-server.exe
[03:33:43] [debug] #32 0045b120 in ?? () from samp-server.exe
[03:33:43] [debug] #33 0045b130 in ?? () from samp-server.exe
[03:33:43] [debug] #34 00452410 in ?? () from samp-server.exe
[03:33:43] [debug] #35 00458640 in ?? () from samp-server.exe
[03:33:43] [debug] #36 0045b140 in ?? () from samp-server.exe
[03:33:43] [debug] #37 00455d60 in ?? () from samp-server.exe
[03:33:43] [debug] #38 00455db0 in ?? () from samp-server.exe
[03:33:43] [debug] #39 00450910 in ?? () from samp-server.exe
[03:33:43] [debug] #40 00455df0 in ?? () from samp-server.exe
[03:33:43] [debug] #41 00455e40 in ?? () from samp-server.exe
[03:33:43] [debug] #42 00458660 in ?? () from samp-server.exe
[03:33:43] [debug] #43 0045b150 in ?? () from samp-server.exe
[03:33:43] [debug] #44 0045b160 in ?? () from samp-server.exe
[03:33:43] [debug] #45 00450990 in ?? () from samp-server.exe
[03:33:43] [debug] #46 0045b170 in ?? () from samp-server.exe
[03:33:43] [debug] #47 0045b180 in ?? () from samp-server.exe
[03:33:43] [debug] #48 0045b190 in ?? () from samp-server.exe
[03:33:43] [debug] #49 0045b1a0 in ?? () from samp-server.exe
[03:33:43] [debug] #50 0045b1b0 in ?? () from samp-server.exe
[03:33:43] [debug] #51 00450b00 in ?? () from samp-server.exe
[03:33:43] [debug] #52 00450e80 in ?? () from samp-server.exe
[03:33:43] [debug] #53 00450b50 in ?? () from samp-server.exe
[03:33:43] [debug] #54 0045b1c0 in ?? () from samp-server.exe
[03:33:43] [debug] #55 00450b60 in ?? () from samp-server.exe
[03:33:43] [debug] #56 00450bb0 in ?? () from samp-server.exe
[03:33:43] [debug] #57 00450c00 in ?? () from samp-server.exe
[03:33:43] [debug] #58 00450c10 in ?? () from samp-server.exe
[03:33:43] [debug] #59 0045b1d0 in ?? () from samp-server.exe
[03:33:43] [debug] #60 0045b1e0 in ?? () from samp-server.exe
[03:33:43] [debug] #61 0045b1f0 in ?? () from samp-server.exe
[03:33:43] [debug] #62 0045b200 in ?? () from samp-server.exe
[03:33:43] [debug] #63 0045b210 in ?? () from samp-server.exe
[03:33:43] [debug] #64 0045b220 in ?? () from samp-server.exe
[03:33:43] [debug] #65 0045b230 in ?? () from samp-server.exe
[03:33:43] [debug] #66 0045b240 in ?? () from samp-server.exe
[03:33:43] [debug] #67 0045b250 in ?? () from samp-server.exe
[03:33:43] [debug] #68 0045b260 in ?? () from samp-server.exe
[03:33:43] [debug] #69 0045b270 in ?? () from samp-server.exe
[03:33:43] [debug] #70 0045b280 in ?? () from samp-server.exe
[03:33:43] [debug] #71 00455f10 in ?? () from samp-server.exe
I can't figure out what's wrong, please help me.
Rep++;
Reply
#2

I'd personally go comment out each line of code individually or print debug messages and keep trying to re-produce the problem... see if u can find which part is causing it?

just loads of debugging and testing :S
Reply
#3

I tried everything from my part. I think it's related with y_ini because in log, the amx backtrace is from y_ini.inc
Reply
#4

I accept with ATGOggy, you have to figure out that y_ini
Reply
#5

Jorda: It's fine if you want to increase your post count, but please do so only if you can actually contribute to the issue.

@OP: Seems to me, you issue is related to this part:
Код:
INI_ParseFile(string, "LoadBan_%s", .bExtra = true, .extra = playerid);
Could you show us the PATH variable?
Reply
#6

PHP код:
#define PATH "/Users/%s.ini" 
Reply
#7

I'd go with a check if loadban_%s exists. Does INI parse it automatically to the right part? Just a %s seems really weird there.
Reply
#8

It works perfectly the first time. I don't exactly know how to use INI_ParseFile. I think it's written correctly.
Reply
#9

Yep. Found this on the wiki:
Код:
INI_AddToBuffer(INI:file, name[], data[])
The three INI_Write(Int|String|Float) functions are all wrappers for this function. This actually finds an empty slot in the buffer and adds the data as string data to it. If the buffer is full it first calls INI_WriteBuffer
Seeing your server crashes on the AddToBuffer function, something is wrong with the write methods. It almost looks like it can't find the file anymore after the Read or something like that.
Reply
#10

So..what should I do now?
I PM'd ****** about this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)