20.04.2015, 16:29
This is my code for banning and unbanning players offline:
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:
I can't figure out what's wrong, please help me.
Rep++;
PHP код:
new bool:OfflineuserbanningBanned[MAX_PLAYERS];
new bool:OfflineuserbanningTempBanned[MAX_PLAYERS];
new OfflineuserbanningAdminLevel[MAX_PLAYERS];
// /unban
dcmd_unban(playerid, params[])
{
new pName[MAX_PLAYER_NAME], string[64];
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
if(PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
if(!admduty[playerid]) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You must be on duty to use this command.");
if(sscanf(params, "s[24]", pName)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /unban [username]");
format(string, sizeof(string), PATH, strlower(pName));
if(!fexist(string)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user does not exist.");
INI_ParseFile(string, "LoadBan_%s", .bExtra = true, .extra = playerid);
if(!OfflineuserbanningBanned[playerid] && !OfflineuserbanningTempBanned[playerid]) return SendClientMessage(playerid, COLOR_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(string, sizeof(string), "User %s has been unbanned.", pName);
SendClientMessage(playerid, COLOR_ADMINBLUE, string);
return 1;
}
// //opermban
dcmd_opermban(playerid, params[])
{
new reason[32], playername[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], string[128], ip[MAX_IP_SIZE], year, month, day, hour, minute, second;
GetPlayerName(playerid, playername, sizeof(playername));
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
if(PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
if(!admduty[playerid]) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You must be on duty to use this command.");
if(sscanf(params, "s[24]s[32]", pName, reason)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /opermban [name] [reason]");
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
new iName[MAX_PLAYER_NAME];
GetPlayerName(i, iName, sizeof(iName));
if(strcmp(iName, pName, true, MAX_PLAYER_NAME)==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This player is already connected.");
}
}
if(strcmp(playername, pName, true, MAX_PLAYER_NAME)==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You cannot ban yourself.");
format(string, sizeof(string), PATH, strlower(pName));
if(!fexist(string)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user does not exist.");
new INI:File = INI_Open(string);
getdate(year, month, day);
gettime(hour, minute, second);
INI_ParseFile(string, "LoadBan_%s", .bExtra = true, .extra = playerid);
if(OfflineuserbanningBanned[playerid]) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user is already banned.");
if(OfflineuserbanningTempBanned[playerid]) return SendClientMessage(playerid, COLOR_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(playerid, COLOR_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]==10) INI_WriteString(File,"Adminwhobanned", "AmalM");
else INI_WriteString(File,"Adminwhobanned", playername);
INI_Close(File);
new File:banlist=fopen("/Logs/OfflineBanlog.log", io_append);
GetPlayerIp(playerid, ip, sizeof(ip));
format(string, sizeof(string), "%s, %s, %d:%d:%d,%d:%d:%d (%s)\r\n", pName, ip, day, month, year, hour, minute, second, playername);
fwrite(banlist, string);
fclose(banlist);
format(string, sizeof(string), "Admin-ban: %s has been banned from the server by %s (%d) (Reason: %s).", pName, playername, playerid, reason);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin]>0)
{
SendClientMessage(i, COLOR_ADMINBLUE, string);
}
}
}
return 1;
}
// //otempban
dcmd_otempban(playerid, params[])
{
new reason[32], playername[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], days, string[128], ip[MAX_IP_SIZE], year, month, day, hour, minute, second;
GetPlayerName(playerid, playername, sizeof(playername));
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
if(PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
if(!admduty[playerid]) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You must be on duty to use this command.");
if(sscanf(params, "s[24]is[32]", pName, days, reason)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /otempban [name] [days] [reason]");
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
new iName[MAX_PLAYER_NAME];
GetPlayerName(i, iName, sizeof(iName));
if(strcmp(iName, pName, true, MAX_PLAYER_NAME)==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This player is already connected.");
}
}
if(strcmp(playername, pName, true, MAX_PLAYER_NAME)==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You cannot ban yourself.");
format(string, sizeof(string), PATH, strlower(pName));
if(!fexist(string)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user does not exist.");
new INI:File = INI_Open(string);
getdate(year, month, day);
gettime(hour, minute, second);
INI_ParseFile(string, "LoadBan_%s", .bExtra = true, .extra = playerid);
if(OfflineuserbanningBanned[playerid] || OfflineuserbanningTempBanned[playerid]) return SendClientMessage(playerid, COLOR_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(playerid, COLOR_ADMINBLUE, "ERROR: You cannot ban another admin.");
INI_SetTag(File,"data");
INI_WriteString(File,"Banreason", reason);
format(string, sizeof(string), "%d/%d/%d", day, month, year);
INI_WriteString(File,"Banningdate", string);
INI_WriteInt(File,"Bandays", days);
INI_WriteInt(File,"Unbandate", gettime()+(days*86400));
if(PlayerInfo[playerid][pAdmin]==10) INI_WriteString(File,"Adminwhobanned", "AmalM");
else INI_WriteString(File,"Adminwhobanned", playername);
INI_Close(File);
new File:banlist=fopen("/Logs/OfflineBanlog.log", io_append);
GetPlayerIp(playerid, ip, sizeof(ip));
format(string, sizeof(string), "%s, %s, %d:%d:%d,%d:%d:%d (%s)\r\n", pName, ip, day, month, year, hour, minute, second, playername);
fwrite(banlist, string);
fclose(banlist);
format(string, sizeof(string), "Admin-ban: %s has been banned from the server for %d days by %s (%d) (Reason: %s).", pName, days, playername, playerid, reason);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin]>0)
{
SendClientMessage(i, COLOR_ADMINBLUE, string);
}
}
}
return 1;
}
forward LoadBan_data(playerid, name[], value[]);
public LoadBan_data(playerid, name[], value[])
{
new tempbandate;
INI_Bool("Banned", OfflineuserbanningBanned[playerid]);
INI_Int("Unbandate", tempbandate);
if(gettime()<tempbandate) OfflineuserbanningTempBanned[playerid]=true;
INI_Int("Admin", OfflineuserbanningAdminLevel[playerid]);
return 1;
}
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
Rep++;