Chat range -
AndreiWow - 04.09.2015
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.
Re: Chat range -
Michael B - 04.09.2015
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.
Re: Chat range -
mirou123 - 04.09.2015
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.
Re: Chat range -
AndreiWow - 05.09.2015
Bump
Re: Chat range -
DarK_FeneR - 05.09.2015
Put it below #include <a_samp>
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
Re: Chat range -
Logofero - 05.09.2015
Quote:
Originally Posted by DarK_FeneR
Put it below #include <a_samp>
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 (...) {
...
}
}
Re: Chat range -
DarK_FeneR - 05.09.2015
Yep sorry, it was a fail
Edited, thanks