Need help with chat
#1

I need some scripting help and before someone has a go at me for "not looking", i have spent a good 30 mins searching everywhere and everything for something thats even remotely close to this.

My problem is to do with the main chat, at the moment i have a main chat that works through normal chat, no need for /o or anything. This is what i want changed, when players talk normally in main chat it was say what they said with the color of the faction they are in on there name, (so for example if someone is in the Police, and police is blue, when they say something in main chat there name will come up as blue and there chat) but /o doesn't, it is just white. So i wanted to change it so that /o will show there name in the color of what faction they are in.
Thank you for taking the time to read this as i would like to know as soon as possible.
Reply
#2

At the moment it is:

Код:
SendClientMessageToAll(COLOR_WHITE, string);
What do i need to change the _WHITE to get the players team color.

P.S, sorry for double post
Reply
#3

Quote:
Originally Posted by sexybeast
At the moment it is:

Код:
SendClientMessageToAll(COLOR_WHITE, string);
What do i need to change the _WHITE to get the players team color.

P.S, sorry for double post
I'm not sure but i bet you have #DEFINED every single color you use, so why don't you use adjust it with that?
I'm not good at that i can't really help :/ Good luck
Reply
#4

Quote:
Originally Posted by sexybeast
At the moment it is:

Код:
SendClientMessageToAll(COLOR_WHITE, string);
What do i need to change the _WHITE to get the players team color.

P.S, sorry for double post
You need to run either a SWITCH-statement or a IF-statement to check to which teams a person belongs and then set their color to that.

eg:
pawn Код:
if(gTeam[playerid] == Team_COPS)
{
  SendClientMessageToAll(COLOR_COP, string);
  return 1;
}
else if(gTeam[playerid]== Team_MEDIC)
{
  SendClientMessageToAll(COLOR_MEDIC, string);
  return 1;
} .. etc
Reply
#5

I tried to do it that way, but i had a few problems when IG, my code is:

Код:
if (PlayerInfo[playerid][pTeam]== 1)
{
  SendClientMessageToAll(TEAM_CYAN_COLOR, string);
  return 1;
}
else if (PlayerInfo[playerid][pTeam]== 2)
{
  SendClientMessageToAll(TEAM_BLUE_COLOR, string);
  return 1;
It compiles but when i do /o [chat] it comes up with both my name and the chat in that color, i just want to have the name in that color. At the start i have
Код:
format(string, sizeof(string), "%s: %s", sendername, result);
printf("%s", string);
which doesn't do anything. Is there anything that i have missed that could fix this?
Reply
#6

Only normal chat that can do like this:

iAmPoliCE: Hello!

If u use SendClientMessage thing, it's IMPOSSIBLE to make part of it White and another part of it other color except if they are in different line.

So, nothing that you can do. What you can do is let all the colors the same in 1 line...
Reply
#7

Well without trying to advertise any servers, there is a server i have played in where the normal chat is local IC chat, and /o is the OOC main chat, and with the /o command they have the players name as the color of there faction and the chat white. Thats all im trying to do.
Reply
#8

You could SetPlayerColor but that will just set the player's color and another option is some kind of fake message. It is somewhere on the forum but I cannot remember the name of it.
Reply
#9

Quote:
Originally Posted by virspector
Only normal chat that can do like this:

iAmPoliCE: Hello!

If u use SendClientMessage thing, it's IMPOSSIBLE to make part of it White and another part of it other color except if they are in different line.

So, nothing that you can do. What you can do is let all the colors the same in 1 line...
Put your mind to it, nothings impossible.

A little thing I made a little while ago:

pawn Код:
public SendCustomMessage(playerid,color,string[],string2[])
{
    new pNames[MAX_PLAYER_NAME],color2;
    GetPlayerName(playerid,pNames,sizeof(pNames));
    color2 = GetPlayerColor(playerid);
    SetPlayerColor(playerid,color);
    SetPlayerName(playerid,string);
    SendPlayerMessageToAll(playerid,string2);
    SetPlayerName(playerid,pNames);
    SetPlayerColor(playerid,color2);
}
The color you put in is the color of What you want the name to come up as, Then the First String part is where you put the players name, then the second part is whatever Like the text string use make from the format.

Reply
#10

I have tried all these ideas, none seem to be producing any luck, if it makes it any easier for some i have put the entire code here so hopefully you might know what the problem is.

pawn Код:
if(strcmp(cmd, "/o", true) == 0 && noooc == 0)
{
if(Mute[playerid] == 1)
{
SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced, /pm an admin and request an un-mute");
return 0;
}
if (gPlayerLogged[playerid] != 1)
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must be logged in to talk.");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /o [ooc chat]");
return 1;
}
format(string, sizeof(string), "%s: %s", sendername, result);
SendClientMessageToAll(COLOR_WHITE, string);
printf("%s", string);
return 1;
}
if(strcmp(cmd, "/o", true) == 0 && noooc == 1)
{
SendClientMessage(playerid, COLOR_RED, "OOC chat channel is currently out of use!");
return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)