[Include] [INC] Easy Local Chat!
#1

Easy Local Chat
By Goudewup

What is it?
Easy Local Chat is a include that makes it easy to make a local chat like in most RP servers.
Feel free to use it, but don't remove the credits!
It ads the following functions:
GetDistanceBetweenPlayers(playerid, playerid2)
SendLocalMessage(playerid, color, radius ,string[]);

Examples:
Code:
public OnPlayerText(playerid,text[])
{
	new name[MAX_PLAYER_NAME], string[128];
	GetPlayerName(playerid, name, sizeof(name));
	format(string, sizeof(string), "%s: %s", name, text);
	SendLocalMessage(playerid, COLOR_WHITE, 7,string);// Send the message
	return 0; // Makes sure the original message isn't send
}
This code will make all chat messages send local.

Code:
	if(strcmp(cmdtext, "/me", true, 3) == 0)
    {
    if(!cmdtext[3])return SendClientMessage(playerid, COLOR_RED, "USAGE: /me [text]");
    new str[128];
    GetPlayerName(playerid, str, sizeof(str));
    format(str, sizeof(str), "*%s %s", str, cmdtext[4]);
    SendLocalMessage(playerid, COLOR_PURPLE, 7, str);
    return 1;
    }
This is a working /me command.

Installation:
All you have to do is put this under #include <a_samp>:
Code:
#include <LocalChat>
Changelog
Quote:
Version 2
Added a paramater to declare the radius of the chat.

Download:
V2
Pastebin (save as LocalChat.inc)
Updo (Hotlink)


V1
Pastebin (save as LocalChat.inc)
Updo (Hotlink)
2Shared
Reply
#2

Hmm, good idea for the next version.
Reply
#3

I get this error when I try to use your local snippet for my RP server.
Code:
C:\Users\Sarin\Desktop\GM From Scratch\gamemodes\GM.pwn(370) : error 035: argument type mismatch (argument 3)
Code:
	SetPlayerChatBubble(playerid, text, WHITE, 10.0, 5000);
	new lname[MAX_PLAYER_NAME], lstring[128];
	GetPlayerName(playerid, lname, sizeof(lname));
	format(lstring, sizeof(lstring), "%s says: %s", lname, text);
	SendLocalMessage(playerid, WHITE, 7,lstring);
	return 0;
This is fake. It doesn't have anything about a radius in the second version. I checked.
Reply
#4

Ty for this include
Reply
#5

You do not get the radius value using the Float: tag...

pawn Code:
#include <a_samp>
#include <foreach>
stock HexToStr(color)
{
    new colorstr[7];
    for(new i = 5; i >= 0; i--)
    {
        new number = (color&(0xF<<(i*4+8)))>>>(i*4+8);
        switch(number)
        {
            case 0..9: colorstr[5-i] = number+'0';
            case 10..15: colorstr[5-i] = number+'A'-10;
            default: printf("HexToStr: Unknown parameter %d at %d.", number, i);
        }
    }
    return colorstr;
}

stock SendLocalMessage(playerid, color, Float:radius, msg[])
{
    new Float:p_pos[3], p_name[MAX_PLAYER_NAME], chatstr[256], count = 0;
    GetPlayerPos(playerid, p_pos[0], p_pos[1], p_pos[2]);
    GetPlayerName(playerid, p_name, sizeof p_name);
    format(chatstr, sizeof chatstr, "{%s}[%d] %s: {FFFFFF}%s", HexToStr(GetPlayerColor(playerid)), playerid, p_name, msg);
    foreach(Player, toplayerid)
    {
        if(!IsPlayerInRangeOfPoint(toplayerid, radius, p_pos[0], p_pos[1], p_pos[2])) continue;
        SendClientMessage(toplayerid, color, chatstr);
        if(playerid != toplayerid) count++;
    }
    return count;
}
Take a look at this example above.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)