[HELP] Admin Duty Color in main chat.
#1

Hi. I have this /aduty script where you go on/off duty. But i want to make it so when you go on duty, your name becomes red in playerlist(tab) and in main chat, and when you go off duty it becomes white again/normal.


Here the is current code:
Code:
CMD:aduty(playerid, params[])
{
    new status[4];
    new name[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_WHITE,"You are not authorized to use that command.");
    if(sscanf(params,"s[4]",status))return SendClientMessage(playerid, COLOR_WHITE, "Usage: /aduty [On/Off]");
    if(strcmp(status, "on", true) == 0)
	{
        if(PlayerInfo[playerid][pAdminDuty] == 0)
		{
            PlayerInfo[playerid][pAdminDuty] = 1;
            SetPlayerColor(playerid, COLOR_BAN);
            GetPlayerName(playerid, name, sizeof(name));
            return SendClientMessage(playerid, COLOR_GREEN, "You are now administrator duty {29EB17} On.");
        }
        else return SendClientMessage(playerid, COLOR_OTHER, "You are not off duty administrator.");
    }
    if(strcmp(status, "off", true) == 0)
	{
        if(PlayerInfo[playerid][pAdminDuty] == 1)
		{
            PlayerInfo[playerid][pAdminDuty] = 0;
            SetPlayerColor(playerid, COLOR_WHITE);
            GetPlayerName(playerid, name, sizeof(name));

            return SendClientMessage(playerid, COLOR_GREEN, "You are now administrator duty {EB4C17} Off");
        }
        else return SendClientMessage(playerid, COLOR_OTHER, "You are not a on duty administrator.");
    }

    return 1;
}
Reply
#2

What's actually wrong with your current script?
Reply
#3

Well when i go on duty, my name doesnt turn red, as you can see SetPlayerColor - COLOR_BAN is red but its not applying
Reply
#4

im still looking for a solution to why my name wont turn red when i go on duty
Reply
#5

This command auto detects if the player is on/off admin duty and set their status based off that so no need to /aduty on/off now its just /aduty

post your define for COLOR_BAN

pawn Code:
CMD:aduty(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_WHITE,"You are not authorized to use that command.");
    else
    {
        if(PlayerInfo[playerid][pAdminDuty] == 0)
        {
            PlayerInfo[playerid][pAdminDuty] = 1;
            SetPlayerColor(playerid, COLOR_BAN);
            return SendClientMessage(playerid, COLOR_GREEN, "You are now administrator duty {29EB17} On.");
        }
        if(PlayerInfo[playerid][pAdminDuty] == 1)
        {
            PlayerInfo[playerid][pAdminDuty] = 0;
            SetPlayerColor(playerid, COLOR_WHITE);
            return SendClientMessage(playerid, COLOR_GREEN, "You are now administrator duty {EB4C17} Off");
        }
    }
    return 1;
}
Reply
#6

Okay aldo, I am using a different public chat than pressing T and typing. so this might be the problem why i cant see red, and i see white when i type in main chat because i use a command to type in main chat using /p (/public)

Here is my public command, it sends message in COLOR_WHITE if you look at the bottom of the script.

Code:
	if(strcmp(cmd, "/public", true) == 0 || strcmp(cmd, "/p", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			GetPlayerName(playerid, pName, sizeof(pName));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[256];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_USAGE, "USAGE: /p [text]");
				return 1;
			}

			format(string, sizeof(string), "%s (%d): %s", RemoveUnderScore(playerid),playerid, result);
			for(new i = 0; i < MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					SendCustomPlayerMessage(i, COLOR_WHITE, string);
				}
			}

		}
		return 1;
	}
Reply
#7

Use this not SendCustomPlayerMessage
pawn Code:
SendPlayerMessageToAll(playerid, string);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)