This admin command crashes the server.
#1

Can anyone find what's wrong with this cmd? It's a command from our server.

Quote:

CMD:tempban(playerid,parmas[])
{
if (PInfo[playerid][Admin] < 3) return SendClientMessage(playerid, RED,"[ERROR]: {FFFFFF}You do not have the privilleges to perform this command.");
new tid,du,res[150],ppp[50];
if(sscanf(parmas,"uis",tid,du,res) || isnull(parmas))return SendClientMessage(playerid,TOMATO,"[USAGE]: {FFFFFF}/tempban (OkayerID) (Days) (Reason)");
if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
new 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);
new string[500];
SendClientMessage(playerid, TOMATO,"[TEMPBAN]: {FFFFFF}The selected account has been temp banned from the database.");
format(string,sizeof(string),"[ADMIN ACTION]: {FFFFFF}Administrator %s has banned %s(%d) from the server for %i days. Reason: %s.",GetName(playerid), GetName(tid),tid,du,res);
SendClientMessageToAll(COLOR_ADMIN,string);
SetTimerEx("KickPlayer",100,false,"i",tid);
return 1;
}

Reply
#2

Indent it properly if you wish to get help, I can barely read the code.
Reply
#3

Quote:
Originally Posted by iKarim
Посмотреть сообщение
Indent it properly if you wish to get help, I can barely read the code.
There: https://pastebin.com/Tfy0bxne
Reply
#4

which part exactly crashes server? use debugs to get info about this.
Reply
#5

Compile the script with -d3 tag and run crash detect plugin. It will also tell the exact line where the crash occurs and might also report other script bugs!

http://forum.sa-mp.com/showthread.ph...ht=Crashdetect
Reply
#6

Maybe that opened file doesnt exist? Check if the file exists first before opening it.

And indent your code it was a pain reading this mess...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)