07.06.2016, 09:27
Could anybody script a /w TEXT command for me which stands for whisper,and only people in close proximity can hear the message?
CMD:w(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_SEAGREEN, "Usage: /w(hisper) [message]");
new string[150], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof string, "'%s whispers' %s %s", pName, string, params);
SendRangeMessage(playerid, -1, string, 20.0);
return 1;
}
stock SendRangeMessage(playerid, COLOR, const text[], Float:range)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
for(new i = GetPlayerPoolSize()+1; --i!=-1;)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i) || !IsPlayerInRangeOfPoint(i, range, X, Y, Z)) continue;
SendClientMessage(i, COLOR, text);
}
return 1;
}
PHP код:
PHP код:
|
Well you can easily use the /w cmd without a stock but, I don't see the big problem init. Maybe if you tell me the problem or something which could cause a problem, I might use it without a stock.
|
COMMAND:w(playerid, params[])
{
new iPlayer, iText[ 128 ];
if( sscanf ( params, "us", iPlayer, iText)) return SCP(playerid, "[PlayerID/PartOfName] [message]");
if(!IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);
if(PlayerTemp[iPlayer][wlock]==1 && !PlayerInfo[playerid][power])
return SendClientMessage(playerid,COLOR_RED,"The given player has locked their whispers.");
new iDistance = GetDistanceBetweenPlayers(playerid, iPlayer);
if(iDistance < 6 || PlayerInfo[playerid][power] || PlayerInfo[playerid][helper])
{
if(iDistance > 6) format(iStr, sizeof(iStr), "(( [%s] %s: %s ))", AdminLevelName(playerid), AnonAdmin(playerid), iText);
else format(iStr, sizeof(iStr), "** %s[%d] whispers: %s", MaskedName(playerid), playerid, iText);
SendClientMessage(iPlayer, COLOR_YELLOW, iStr);
if(iDistance > 6) format(iStr, sizeof(iStr), "(( PM sent to %s: %s ))", RPName(iPlayer), iText);
else format(iStr, sizeof(iStr), "** Whisper sent to %s[%d]: %s", MaskedName(iPlayer), iPlayer, iText);
SendClientMessage(playerid, COLOR_YELLOW, iStr);
format(iStr,sizeof(iStr),"%s whispers to %s:%s",PlayerName(playerid),PlayerName(iPlayer),iText);
PlayerLoop(i)
}
}
else SendClientError(playerid, "Player is too far away!");
return 1;
}