Global / Local chat problems
#1

Need something like this
so if player color Yellow in game in chat look like this
[ThC]Mr.Satna: Hello guys
Just with GetPlayerColor(playerid);
pawn Код:
public OnPlayerText(playerid, text[])
{
    new str[128], name[20];
    if(text[0] == '@')//when player @ he is using global chat
    {
        GetPlayerName(playerid, name, sizeof(name));
        format(str, sizeof(str), "((%s: %s))", name, text[1]);
        SendClientMessageToAll(-1, str);
        return 0;
    }
    return 1;
}
And if is @ global chat
how can i make when he type normal chat he is using that chat for local only for players in range of him .
and Bubble chat on local ..
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    new str[128], name[20];
    if(text[0] == '@')
    {
        GetPlayerName(playerid, name, sizeof(name));
        format(str, sizeof(str), "(({%06x}%s: %s))",GetPlayerColor(playerid) >>> 8, name, text[1]);// added {%06x} -GetPlayerColor(playerid) >>> 8
        SendClientMessageToAll(-1, str);
        return 0;
    }
    return 1;
}
Reply
#3

what about local chat can you help me ?
Reply
#4

Search for a stock in the forum called Proxdetector, it will be useful in making the local chat
Reply
#5

In order to create a local chat, you need to find out the distance between the player speaking and the player you want to see the text, and then confirm how far you want it to be seen. Since the only variables you have is the player that is typing, I would do a for loop to detect the players that are close to you.

Код:
public OnPlayerText(playerid, text[])
{
    new str[128], name[20];
    if(text[0] == '@')
    {
        GetPlayerName(playerid, name, sizeof(name));
        format(str, sizeof(str), "(({%06x}%s: %s))",GetPlayerColor(playerid) >>> 8, name, text[1]);// added {%06x} -GetPlayerColor(playerid) >>> 8
        SendClientMessageToAll(-1, str);
        return 0;
    } else { // if doesn't start with @
	   	new Float:x,Float:y,Float:z,Float:fDistance;
		GetPlayerPos(playerid,x,y,z);
		new FormatBuffer[255];
		new NameBuffer[255];
		GetPlayerName(playerid,NameBuffer,sizeof(NameBuffer));
		format(FormatBuffer,sizeof(FormatBuffer),"%s : %s",NameBuffer,text);
		for(new i = 0; i < MAX_PLAYERS; i++) {
		    if(!IsPlayerConnected(i)) continue;
			fDistance = GetPlayerDistanceFromPoint(i, x, y, z);
		    if(fDistance == 2) {
				SendClientMessage(i,0xFFFFFFFF, FormatBuffer);
		    }
		    else if(fDistance == 3) {

			}
		}
    }
    return 1;
}
That's a way that you can accomplish this. All you have to do is adjust the distance to your liking. You can also add more else if statements and make it so if the player gets further the color can begin to fade. if you just want one solid color for anyone that is in a certain range then negate the else if statement. I hope this helps answer your question.
Reply
#6

thanks man gonna try it out
Reply
#7

You just need to add this under the distance if statement.

https://sampwiki.blast.hk/wiki/SetPlayerChatBubble

SetPlayerChatBubble(playerid, text, 0xFFFFFFFF, 2, 5000);

It should work, but I don't have anything to test it, so if you have any problems just let me know.

EDIT: Also if your chat returns double it means that OnPlayerText, it needs to return 0.

EDIT: Lol,

Код:
if(fDistance == 2) {
Should be

Код:
if(fDistance <= 5) {
Because it would be kind of hard to call that it is exactly 2
Reply
#8

the @ Chat its okay work fine but the other one Local dont work fine cuz was test it with friend he in LS me in LV and he saw the local chat
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)