Server Crashing | Please Help
#1

My Server Crashes when i /setadmin a Player. Why ?
Here is my /setadmin Code !
Код:
dcmd_setadmin(playerid,params[])
{
	new string[128];
	new string2[128];
	new ID;
	new cmdreason;
	if(sscanf(params,"ui",ID,cmdreason))
	{
	    SendClientMessage(playerid,COLOR_ERROR,"{CACA00}[INFO]{FFFFFF}: /setadmin (Player Name/ID) (Level)");
	    return 1;
	}
	if(IsSpawned[playerid] != 1)
	{
		SendClientMessage(playerid,COLOR_ERROR,"You must be spawned to use any command.");
		return 1;
	}
	if(ID == INVALID_PLAYER_ID)
	{
	    format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot set their administrator level.",ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(PLAYERLIST_authed[ID] != 1)
	{
        format(string,sizeof(string),"%s(%d) is not logged into to the server. You must wait till they login before you set their administrator level.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(AdminLevel[playerid] == 4 && cmdreason >= 5)
	{
		SendClientMessage(playerid,COLOR_ERROR,"You can set from 1-4 levels.");
		return 1;
	}
	if(AdminLevel[playerid] == 5 && cmdreason >= 6)
	{
		SendClientMessage(playerid,COLOR_ERROR,"You can set from 1-5 levels.");
		return 1;
	}
	if(AdminLevel[ID] > AdminLevel[playerid])
	{
        format(string,sizeof(string),"%s(%d) Level's is more than your Level you can't Set His admin Level",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
    }
	if(AdminLevel[ID] == cmdreason)
	{
	    format(string,sizeof(string),"%s(%d) is already at the Administrator level: %d",PlayerName(ID),ID,cmdreason);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	format(string,sizeof(string),"Administrator %s(%d) have given you Admin Level : %d.",PlayerName(playerid),playerid,cmdreason);

    SendClientMessage(ID,COLOR_ADMIN,string);
	AdminLevel[ID] =cmdreason;

	format(string,sizeof(string),"You have given %s(%d) Admin Level : %d.",PlayerName(ID),ID,cmdreason);
    SendClientMessage(playerid,COLOR_ADMIN,string);

	format(string,sizeof(string),"9[ADMIN LEVEL CHANGE] %s(%d) has given %s(%d) the administrator level %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
	IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
	format(string,sizeof(string),"[ADMIN-COMMAND] %s(%d) has used /setadmin on %s(%d)",PlayerName(playerid),playerid,PlayerName(ID),ID);
    SendClientMessageToAllAdmins(string);
    format(string2,sizeof(string2),"%s(%d) has given %s(%d) the administrator level %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
    AdminLog(string2);
	return 1;
}
Reply
#2

Try this. (using zcmd)

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new targetid, level, string[128];
    [Change this to your admin system] && !IsPlayerAdmin(playerid)) return SendClientMessageEx(playerid, -1, "You are not authourized to use this command.");
    else if(sscanf(params, "ui", targetid, level)) return SendClientMessageEx(playerid, -1, "Usage: /makeadmin [playerid] [0-5]");
    else if(!IsPlayerConnectedEx(targetid) || !IsPlayerLogged(targetid)) return SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
    else if(level < 0 || level > 5) return SendClientMessageEx(playerid, -1, "You have enter an invalid administrator level.");
    PlayerInfo[targetid][pAdminLevel] = level;
    format(string, sizeof(string), "* You have been made a %s by %s %s.", GetAdminRank(targetid), GetAdminRank(playerid), GetPlayerNameEx(playerid));
    SendClientMessageEx(targetid, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "You have made %s a %s.", GetPlayerNameEx(targetid), GetAdminRank(targetid));
    SendClientMessageEx(playerid, -1, string);
    return 1;
}
Just change the colors (if you want to) and make it into your admin system - I told you where to put it.
Rep if I helped
Reply
#3

First off, don't even try mkmk's cmd... Thanks mkmk for trying though...

pawn Код:
dcmd_setadmin(playerid,params[])
{
    new string[128], string2[128], ID, cmdreason;
   
    if(sscanf(params,"ui",ID,cmdreason))
        return SendClientMessage(playerid,COLOR_ERROR,"{CACA00}[INFO]{FFFFFF}: /setadmin (Player Name/ID) (Level)");
    else if(IsSpawned[playerid] != 1)
        return SendClientMessage(playerid,COLOR_ERROR,"You must be spawned to use any command.");
    else if(ID == INVALID_PLAYER_ID)
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot set their administrator level.",ID);
        return SendClientMessage(playerid,COLOR_ERROR,string);
    }
    else if(PLAYERLIST_authed[ID] != 1)
    {
        format(string,sizeof(string),"%s(%d) is not logged into to the server. You must wait till they login before you set their administrator level.",PlayerName(ID),ID);
        return SendClientMessage(playerid,COLOR_ERROR,string);
    }
    else if(AdminLevel[playerid] == 4 && cmdreason >= 5)
        return SendClientMessage(playerid,COLOR_ERROR,"You can set from 1-4 levels.");
    else if(AdminLevel[playerid] == 5 && cmdreason >= 6)
        return SendClientMessage(playerid,COLOR_ERROR,"You can set from 1-5 levels.");
    else if(AdminLevel[ID] > AdminLevel[playerid])
    {
        format(string,sizeof(string),"%s(%d) Level's is more than your Level you can't Set His admin Level",PlayerName(ID),ID);
        return SendClientMessage(playerid,COLOR_ERROR,string);
    }
    else if(AdminLevel[ID] == cmdreason)
    {
        format(string,sizeof(string),"%s(%d) is already at the Administrator level: %d",PlayerName(ID),ID,cmdreason);
        return SendClientMessage(playerid,COLOR_ERROR,string);
    }
    format(string,sizeof(string),"Administrator %s(%d) have given you Admin Level : %d.",PlayerName(playerid),playerid,cmdreason);
    SendClientMessage(ID,COLOR_ADMIN,string);
    AdminLevel[ID] = cmdreason;

    format(string,sizeof(string),"You have given %s(%d) Admin Level : %d.",PlayerName(ID),ID,cmdreason);
    SendClientMessage(playerid,COLOR_ADMIN,string);

    format(string,sizeof(string),"9[ADMIN LEVEL CHANGE] %s(%d) has given %s(%d) the administrator level %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
    IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
    format(string,sizeof(string),"[ADMIN-COMMAND] %s(%d) has used /setadmin on %s(%d)",PlayerName(playerid),playerid,PlayerName(ID),ID);
    SendClientMessageToAllAdmins(string);
    format(string2,sizeof(string2),"%s(%d) has given %s(%d) the administrator level %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
    AdminLog(string2);
    return 1;
}
Try this, I cleaned it up a bit too, it was pretty messy. I think the problem was this string.
Quote:

format(string,sizeof(string),"9[ADMIN LEVEL CHANGE] %s(%d) has given %s(%d) the administrator level %d.",PlayerName(playerid),playerid,PlayerName(ID) ,ID,cmdreason);
IRC_GroupSay(gGroupID,IRC_CHANNEL,string);

It contained a few characters that shouldn't be there. (They are the "End of Text" and "Start of Text" characters. The ETX character is the one that killed your script. Read more about these characters here, scroll down to ETX to see why this happened. CLICK ME)
Reply
#4

Crash detect plugin
https://sampforum.blast.hk/showthread.php?tid=262796
Reply
#5

Read below:
Quote:

End-of-text character
From Wikipedia, the free encyclopedia
The End Of Text character (ETX) (hex value of 0x03, often displayed as ^C) is an ASCII control character used to inform the receiving computer that the end of the data stream has been reached. This may or may not be an indication that all of the data has been received.

It is often used as a "break" character (Control-C) to interrupt a program or process. In TOPS-20, it was used to gain the system's attention before logging in.

It is often used in conjunction with Start of text (STX) and Data Link Escape (DLE) e.g. to distinguish frames in the Data link layer.

mIRC uses ETX as the color character escape character.

I'd like to see what crashdetect says, if you end up using crashdetect instead of my cmd, I want to see the log for future reference... :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)