#1

Hi

Can someone tell me why my server crash when I ban someone



Код:
CMD:ban(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 5 || IsPlayerAdmin(playerid))
{
new id,file1[256],str[128];
if(sscanf(params, "u", id))return SendClientMessage(playerid, COLOR_RED, "USAGE: /ban [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Player is not connected!");
new playername[MAX_PLAYER_NAME];
new adminname [MAX_PLAYER_NAME];
new ip[126];
GetPlayerIp(id, ip, sizeof(ip));
GetPlayerName(id, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
new year,month,day; getdate(year, month, day);
new hour,minuite,second; gettime(hour,minuite,second);
format(file1, sizeof(file1),BAN_LOG);
format(str,sizeof(str),"%s has been Banned by Administrator %s | [Date: %d/%d/%d] [Time: %d:%d]\r\n",playername,adminname,day,month,year,hour,minuite);
dini_Set(file1,"Ban",str);
BanIp(id);
}
else return Error(playerid, 5);
return 1;
}
Код:
stock BanIp(playerid)
{
PlayerInfo[playerid][Baned] = 1;
PlayerInfo[playerid][BanedTimes]++;
new ip[15];
new string[126];
new File:banedf = fopen("Server/Logs/BANNEDIPs.ban", io_append);
GetPlayerIp(playerid, ip, sizeof (ip));
ShowPlayerDialog(playerid,DIALOG_BAN2,DIALOG_STYLE_MSGBOX,""COL_GREEN"UGF",""COL_GREEN"You have been "COL_RED"banned "COL_GREEN"and you can request unban at "COL_WHITE"www.ugfforum.tk"COL_GREEN".\nTake a picture with "COL_WHITE"F8 "COL_GREEN"for proof.","KICK","");
format(string, sizeof string, "%s\r\n",ip);
fwrite(banedf, string);
fclose(banedf);
return 1;
}
Reply
#2

Make sure that you do have the Server/Logs folders in your scripfiles.
Reply
#3

yes I have!
Reply
#4

If you are using dini in command, remake the stock in dini too.
The server crashes probably because you are trying to open a file that does not exist.
Reply
#5

Not really sure what the problem is, but i'd just like to drop this off.
pawn Код:
if(PlayerInfo[playerid][AdminLevel] >= 5 || IsPlayerAdmin(playerid))
I guess you are trying to do this:
pawn Код:
if(PlayerInfo[playerid][AdminLevel] >= 5 && IsPlayerAdmin(playerid))
Shouldn't really be necessary to use IsPlayerAdmin though.

EDIT: Oh sorry, i forgot that IsPlayerAdmin is for RCON admins, nvm.
Reply
#6

Nope
I have it like that so...
Reply
#7

Please help!
Reply
#8

Please I really need it!
Reply
#9

anyone
Reply
#10

Get crash detect plugin from here https://sampforum.blast.hk/showthread.php?tid=262796
Compile script in debug mode as mentioned in crash detect plugin topic to get the line that is causing error.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)