SA-MP Forums Archive
This admin command crashes the server. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: This admin command crashes the server. (/showthread.php?tid=650089)



This admin command crashes the server. - GamezCEO - 20.02.2018

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;
}




Re: This admin command crashes the server. - iKarim - 20.02.2018

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


Re: This admin command crashes the server. - GamezCEO - 20.02.2018

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


Re: This admin command crashes the server. - Mugala - 20.02.2018

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


Re: This admin command crashes the server. - Logic_ - 21.02.2018

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


Re: This admin command crashes the server. - RogueDrifter - 21.02.2018

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...