SA-MP Forums Archive
Chat Help - 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: Chat Help (/showthread.php?tid=378316)



Chat Help - KiiD - 17.09.2012

I'm sure this is something really simple, but I was wondering if I could have some help with the script below for the vip chat.

Код:
command(v, playerid, params[])
{
	new message[128], string[128];
	if(sscanf(params, "z", message))
	{
		SendClientMessage(playerid, WHITE, "SYNTAX: /(v)ip [message]");
	}
	else
	{
	    if(Player[playerid][VipRank] >= 1)
	    {
	        if(strlen(message) < 1)
	        {
	            SendClientMessage(playerid, WHITE, "SYNTAX: /(v)ip [message]");
	        }
	        else
	        {
	            format(string, sizeof(string), "[VIP] %s says (%d): %s", GetName(playerid), Player[playerid][VipRank], message);

				for(new i = 0; i < MAX_PLAYERS; i++)
		        {
		            if(IsPlayerConnectedEx(i) && Player[i][VipRank] >= 1 && Player[i][ToggedVIP] == 0)
		            {
		                SendClientMessage(i, 0xF2C200FF, string);
		            }
		        }
	        }
	    }
	}
	return 1;
}
Now, I want to make it so for admin just their name is red, here is the defined admin thing I have for the newbie chat:
Код:
if(Player[playerid][AdminLevel] >= 1)
Although, I want it to be from levels 1 through to 6.
-Thanks in advance.


Re: Chat Help - clarencecuzz - 17.09.2012

pawn Код:
CMD:n(player, params[]) //You can replace n with anything you want, newbiechat etc.
{
    new message[80];
    if(sscanf(params, "s", message)) return SendClientMessage(playerid, WHITE, "SYNTAX: /(n) [message]");
    if(strlen(message) > 80) return SendClientMessage(playerid, WHITE, "SYNTAX: /(n) [message]");
    if(Player[playerid][AdminLevel] < 1)
    {
        format(string,sizeof(string),"[NEWBIE] %s says: %s",GetName(playerid), message);
    }
    else
    {
        format(string,sizeof(string),"[NEWBIE] {FF0000}%s {F2C200}says: %s",GetName(playerid),message);
    }
    SendClientMessageToAll(0xF2C200FF, string); //You can replace the colour with whatever you desire.
    return 1;
}
NOTE: Untested


Re: Chat Help - [ABK]Antonio - 17.09.2012

pawn Код:
command(v, playerid, params[])
{
    if(!Player[playerid][VipRank]) return 0; //or 1, a message, whatever you want
    if(!isnull(params))
    {
        new string[128], color[9];
       
        if(Player[playerid][AdminLevel]) format(color, sizeof(color), "{CC0000}");
        else format(color, sizeof(color), "{}");
        format(string, sizeof(string), "[VIP] %s%s{999999} says (%d): %s", color, GetName(playerid), Player[playerid][VipRank], params);

        for(new i=0; i < MAX_PLAYERS; i++)
            if(IsPlayerConnected(i) && Player[i][VipRank] && !Player[i][ToggedVIP])
                SendClientMessage(i, 0xF2C200FF, string);
    }
    else return SendClientMessage(playerid, WHITE, "SYNTAX: /(v)ip [message]");
    return 1;
}
Here's one way to do it (note, {} should be invisible for non admins but you can change it to any color you want regular players to have). That 99,99,99 is just a gray


Re: Chat Help - KiiD - 17.09.2012

http://gyazo.com/a1be0096a004390cafecf03219a98202
the {} is visable for the normal players and invis for admin. is there a way to just remove the {}? Will it break the command?


Re: Chat Help - [ABK]Antonio - 17.09.2012

yeah just change it to the 999999 (inside the brackets in the else statement) or whatever you want


Re: Chat Help - KiiD - 17.09.2012

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
yeah just change it to the 999999 (inside the brackets in the else statement) or whatever you want
Do you mind doing it for me? I'm terrible with scripting chats =I


Re: Chat Help - clarencecuzz - 17.09.2012

Oh lol I thought you were asking for a newbie chat command :S oops.
but no, that isn't the best way :S
You can just reformat the string if they aren't admins... just like in the 'n' command, just replace the variables with admin variables.


Re: Chat Help - [ABK]Antonio - 17.09.2012

pawn Код:
else format(color, sizeof(color), "{}");
to
pawn Код:
else format(color, sizeof(color), "{999999}");
or some other color


Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Oh lol I thought you were asking for a newbie chat command :S oops.
but no, that isn't the best way :S
You can just reformat the string if they aren't admins... just like in the 'n' command, just replace the variables with admin variables.
There's no need - it's gonna be faster if he ever wants to add more colors or something into it without reformatting it multiple times. It's only 9 cells lol


Re: Chat Help - clarencecuzz - 17.09.2012

pawn Код:
CMD:v(playerid, params[])
{
    new message[80];
    if(Player[playerid][VipRank] < 1 && Player[playerid][AdminLevel] < 1) return SendClientMessage(playerid, WHITE, "Only VIP Members/Administrators Can Use This Command!");
    if(sscanf(params, "s", message)) return SendClientMessage(playerid, WHITE, "SYNTAX: /(v)ip [message]");
    if(strlen(message) > 80) return SendClientMessage(playerid, WHITE, "SYNTAX: /(v)ip [message]");
    new string[150];
    if(Player[playerid][AdminLevel] > 0)
    {
        format(string,sizeof(string),"[VIP] {FF0000}%s {F2C200}says (%d): %s",GetName(playerid),Player[playerid][VipRank],message);
    }
    else
    {
        format(string,sizeof(string),"[VIP] %s says (%d): %s",GetName(playerid),Player[playerid][VipRank],message);
    }
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(Player[i][VipRank] > 0)
            {
                if(Player[i][ToggedVIP] == 0)
                {
                    SendClientMessage(i, 0xF2C200FF, string);
                }
            }
        }
    }
    return 1;
}