15.03.2015, 19:25
Код:
stock SendRangedMessage(sourceid, color, message[], Float:range) {
new Float:x, Float:y, Float: z; // we create 3 float variables to store the x, y, z coordinates in;
GetPlayerPos(sourceid, x, y, z); // we use the 'GetPlayerPos' function to store the sourceid's coordinates (player who sends the ranged message) into x, y and z;
for (new ii = 0; ii < MAX_PLAYERS; ii++) { // we loop through all connected players - could use foreach for faster processing
if(IsPlayerConnected(ii)) { // we check players availability (online)
if(GetPlayerVirtualWorld(sourceid) == GetPlayerVirtualWorld(ii)) { // we check if the virtual worlds of the players within the range match
if(IsPlayerInRangeOfPoint(ii, range, x, y, z)) { // we check if the player you want to send the message to is in the given range (range = the furthest distance the player can be from the point to be in range. -> distance between the farthest distance point and sourceid coordinates is practically the range )
SendClientMessage(ii, color, message); // if he meets all those "requirements", the message will be sent.
}
}
}
}
}
CMD:me(playerid, params[]) {
new string[128]; // we create an array named string that has 128 cells. on each cell, a character will be placed. in empty cells, /0 (null) is located.
if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /me [action]"); // if the params are null, a client message will be returned to the player that typed the command
format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), params); // we format the message so it can include variables and other strings to it
SendRangedMessage(playerid, -1, string, 5.0); // we call SendRangedMessage not native function.
return 1;
}

