Chat range
#1

How do I make when you type in chat, on T just players around you can hear, not global..

And also how to make a global chat command and make it to take money from you.
Reply
#2

For imposing a specific range, use ProxDetector funtion (see example here).
For the global chat, use the GivePlayerMoney function, by adding a negative value at the "money" parameter, inside the command you're using (I assume it's /o).
eg.
PHP код:
GivePlayerMoney(playerid, -500); //Take 500 bucks from player's cashl. 
Reply
#3

Return 0 in OnPlayerText so the default message is gone then use IsPlayerInRangeOfPoint to get the players that should see the messages and send it to them using SendClientMessage. You can download a roleplay gamemode and see how they do stuff.
Reply
#4

Bump
Reply
#5

Put it below #include <a_samp>
pawn Код:
#define RANGE_CHAT 10
put the code in ---> public OnPlayerText(playerid, text[])
pawn Код:
new str[256], pName[MAX_PLAYER_NAME], pColor = GetPlayerColor(playerid), Float:pPos[3];
    GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
    GetPlayerName(playerid, pName, sizeof(pName));
    format(str, sizeof(str), "%s{FFFFFF}: %s", pName, text);
    SendClientMessageToAllInRange(RANGE_CHAT, pPos[0], pPos[1], pPos[2], pColor, str);
   
    if(strlen(text) > 128)
    {
        format(str, sizeof(str), "%s{FFFFFF}: %s", pName, text);
        SendClientMessageToAllInRange(RANGE_CHAT, pPos[0], pPos[1], pPos[2], pColor, str[129]);
    }
    return 0;
Put where you want... I usally put forwards at the ends of my Gamemode
pawn Код:
forward SendClientMessageToAllInRange(range, Float:X, Float:Y, Float:Z, color, text[]);
public SendClientMessageToAllInRange(range, Float:X, Float:Y, Float:Z, color, text[])
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(playerid) && IsPlayerInRangeOfPoint(playerid, range, X, Y, Z)) SendClientMessage(playerid, color, text);
    }
}
Done in 5 minutes
Reply
#6

Quote:
Originally Posted by DarK_FeneR
Посмотреть сообщение
Put it below #include <a_samp>
pawn Код:
#define RANGE_CHAT 10
put the code in ---> public OnPlayerText(playerid, text[])
pawn Код:
new str[256], pName[MAX_PLAYER_NAME], pColor = GetPlayerColor(playerid), Float:pPos[3];
    GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
    GetPlayerName(playerid, pName, sizeof(pName));
    format(str, sizeof(str), "%s{FFFFFF}: %s", pName, text);
    for(new p; p < MAX_PLAYERS; p++) if(IsPlayerConnected(p)) SendClientMessageToAllInRange(RANGE_CHAT, pPos[0], pPos[1], pPos[2], pColor, str);
   
    if(strlen(text) > 128)
    {
        format(str, sizeof(str), "%s{FFFFFF}: %s", pName, text);
        for(new p; p < MAX_PLAYERS; p++) if(IsPlayerConnected(p)) SendClientMessageToAllInRange(RANGE_CHAT, pPos[0], pPos[1], pPos[2], pColor, str[129]);
    }
    return 0;
Put where you want... I usally put forwards at the ends of my Gamemode
pawn Код:
forward SendClientMessageToAllInRange(range, Float:X, Float:Y, Float:Z, color, text[]);
public SendClientMessageToAllInRange(range, Float:X, Float:Y, Float:Z, color, text[])
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(playerid) && IsPlayerInRangeOfPoint(playerid, range, X, Y, Z)) SendClientMessage(playerid, color, text);
    }
}
Done in 5 minutes
Код:
for(new p; p < MAX_PLAYERS; p++) if(IsPlayerConnected(p)) SendClientMessageToAllInRange(RANGE_CHAT, pPos[0], pPos[1], pPos[2], pColor, str);

public SendClientMessageToAllInRange(range, Float:X, Float:Y, Float:Z, color, text[])
{
	for(new playerid; playerid < MAX_PLAYERS; playerid++)
	{
		if(IsPlayerConnected(playerid) && IsPlayerInRangeOfPoint(playerid, range, X, Y, Z)) SendClientMessage(playerid, color, text);
	}
}
Why are you repeatedly in the cycle?
You have the function itself does. So you have time to chase it!

Код:
for (...) {
    for (...) {
       ...
   }
}
Reply
#7

Yep sorry, it was a fail
Edited, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)