How to make Nearby OnPlayerText -
dakata994 - 24.12.2013
SLOVED
Re: How to make Nearby OnPlayerText - Patrick - 24.12.2013
Created this simple function for you, this will send a message to the players who's in range, that you have set.
Code
pawn Код:
stock SendNearByMessage(playerid, color, Float:radius, const message[])
{
new
Float:Position[ 3 ], i = 0
;
GetPlayerPos( playerid, Position[ 0 ], Position[ 1 ], Position[ 2 ]);
while(i < MAX_PLAYERS)
{
if(!IsPlayerConnected(playerid)) continue;
if(IsPlayerInRangeOfPoint(i, radius, Position[ 0 ], Position[ 1 ], Position[ 2 ]))
{
SendClientMessage(i, color, message); return true;
}
i++;
}
return false;
}
Example of Usage
pawn Код:
public OnPlayerConnect(playerid)
{
return SendNearByMessage(playerid, -1, 20.0, "Message Here");
}
Re: How to make Nearby OnPlayerText -
dakata994 - 24.12.2013
No... i want to make IC Chat for Roleplay server... Example:
"PRESSING "T"" And im typing: Hello!
I want to show it like that:
Firstname_Lastname says: Hello!
How can i make it ...
Re: How to make Nearby OnPlayerText - Patrick - 24.12.2013
I think this is what you want, explanation inside.
pawn Код:
public OnPlayerText(playerid, text[])
{
new
string[ 128 ], PlayerName[ MAX_PLAYER_NAME ]; // variable, so we wouldn't get undefined ....
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME); //this function gets the name of the player.
format(string, sizeof(string), "%s: %s", PlayerName, text);
SendNearByMessage(playerid, -1, 20.0, string); // will send the message who's in range of 20.0
return false; //return false, because if it's true, the message will be sent twice.
}
stock SendNearByMessage(playerid, color, Float:radius, const message[])
{
new
Float:Position[ 3 ], i = 0
;
GetPlayerPos( playerid, Position[ 0 ], Position[ 1 ], Position[ 2 ]);
while(i < MAX_PLAYERS)
{
if(!IsPlayerConnected(playerid)) continue;
if(IsPlayerInRangeOfPoint(i, radius, Position[ 0 ], Position[ 1 ], Position[ 2 ]))
{
SendClientMessage(i, color, message);
}
i++;
}
}
Re: How to make Nearby OnPlayerText -
Konstantinos - 24.12.2013
A note on the above code, that using "return true;" will break the loop. It doesn't actually need to return any value (that function).
Re: How to make Nearby OnPlayerText -
dakata994 - 24.12.2013
Thanks guys! Its Okay now!