Admin Chat Problem
#1

Код:
	if(strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "/a", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[96];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/a)dmin [admin chat]");
				return 1;
			}
			new atext[60];
			if(PlayerInfo[playerid][pAdmin] == 1){ atext = "Trial Admin"; }
			if(PlayerInfo[playerid][pAdmin] == 2){ atext = "Administrator"; }
			if(PlayerInfo[playerid][pAdmin] == 3){ atext = "Senior Admin"; }
			if(PlayerInfo[playerid][pAdmin] == 1337){ atext = "Head Admin"; }
			if(PlayerInfo[playerid][pAdmin] == 1338){ atext = "Server Owner"; }
		    format(string, sizeof(string), "%s %s:"COL_WHITE "%s", atext, RemoveUnderScore(playerid), playerid, result);
			if(PlayerInfo[playerid][pAdmin] >= 1)
			{
				SendAdminMessage(COLOR_ORANGE, string);
			}
		}
		return 1;
	}
Here is the code for my administrator chat, although I'm having an issue with the text appearing. It appears as either a comma or just not appearing t all. So it would be like 'Server Owner Josh:'. I don't get any errors, anyone know the problem?
Reply
#2

Well, i can't spot any typing mistakes, but maybe it would help to put a TAB infront of Format(string , since it might lose identity that way, not sure if it helps. I think the error is in the string for sure, but can't seem to find it.
Also, why dont you use stocks for Atext's? You'll be able to use it in different scripts to, for example stats etc.
Reply
#3

Its just the code, its got the correct format in my script, I'm not exactly sure what you mean.
Reply
#4

I dont understand wheeres the problem ? :/
Reply
#5

Change [CODE] [//CODE] To [PAWN] [//PAWN] but remove the extra "/" so we can see the code properly please.
Reply
#6

that's mine, easy I guess
pawn Код:
forward SendAdminMessage(color, string[]);
public SendAdminMessage(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            //if(PlayerInfo[i][pAdmin] >= 7) //Your admin defining line, you can make this
            if(IsPlayerAdmin(i) //This will make it send to all RCON admins, better to define it to your admins
            {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
    }
}

CMD:ac(playerid,params[])
{
    new string[128];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    if(!strlen(params))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /ac (Message)");
        return 1;
    }
    format(string,sizeof(string),"[AC] %s(%d): %s",pname,playerid,params);
    SendAdminMessage(COLOR_YELLOW,string);
    return 1;
}
Reply
#7

Oy Josh ya got a lil' problem in the formatting there.
Let me demonstrate;
pawn Код:
format(string, sizeof(string), "%s %s:"COL_WHITE "%s", atext, RemoveUnderScore(playerid), playerid, result);
that ain' no good, you got 3 format characters yet ya got 4 values, that ain't matching up.
so how about you do it like this:
pawn Код:
format(string, sizeof(string), "%s %s(%d):"COL_WHITE "%s", atext, RemoveUnderScore(playerid),playerid, result);
I'm assuming RemoveUnderScore returns the player's name without underscores.

Kind regards,
Mike Peterson
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)