public OnPlayerText(playerid, text[])
{
new stringtome[256];
new stringtoall[256];
new Float:PlayerToPlayerDistance;
GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
if(GetPVarInt(playerid, "pLogged") == 0) return 0;
format(stringtome, sizeof(stringtome), " > Вы сказали: {ff6600}%s", text);
format(stringtoall, sizeof(stringtoall), "%s говорит: {ff6600}%s", playername(playerid), text);
SetPlayerChatBubble(playerid, text, 0xff6600ff, 30.0, 6000);
SendClientMessage(playerid, -1, stringtome);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if((i != playerid) && IsPlayerStreamedIn(playerid, i))
{
PlayerToPlayerDistance = GetPlayerDistanceFromPoint(i, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
if(PlayerToPlayerDistance == 30.0)
{
SendClientMessage(i, -1, text);
}
}
}
return 0;
}
public OnPlayerText(playerid, text[])
{
new stringtome[256];
new stringtoall[256];
new Float:PlayerToPlayerDistance;
GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
if(GetPVarInt(playerid, "pLogged") == 0) return 0;
format(stringtome, sizeof(stringtome), " > Вы сказали: {ff6600}%s", text);
format(stringtoall, sizeof(stringtoall), "%s говорит: {ff6600}%s", playername(playerid), text);
SetPlayerChatBubble(playerid, text, 0xff6600ff, 30.0, 6000);
SendClientMessage(playerid, -1, stringtome);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if((i != playerid) && IsPlayerStreamedIn(playerid, i))
{
PlayerToPlayerDistance = GetPlayerDistanceFromPoint(i, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
if(PlayerToPlayerDistance <= 30.0)
{
SendClientMessage(i, -1, stringtoall);
}
}
}
return 0;
}
public OnPlayerText(playerid, text[])
{
new stringtome[256];
new stringtoall[256];
new Float:PlayerToPlayerDistance;
GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
if(GetPVarInt(playerid, "pLogged") == 0) return 0;
format(stringtome, sizeof(stringtome), " > Вы сказали: {ff6600}%s", text);
format(stringtoall, sizeof(stringtoall), "%s говорит: {ff6600}%s", playername(playerid), text);
SetPlayerChatBubble(playerid, text, 0xff6600ff, 30.0, 6000);
SendClientMessage(playerid, -1, stringtome);
for(new i=0; i<MAX_PLAYERS; i++)
{
if((i != playerid) && IsPlayerStreamedIn(playerid, i))
{
PlayerToPlayerDistance = GetPlayerDistanceFromPoint(i, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
if(PlayerToPlayerDistance <= 30.0) // не "равно 30.0" а "меньше или равно 30.0".
{
SendClientMessage(i, -1, stringtoall); // не text а stringtoall.
}
}
}
return 0;
}
public OnPlayerText(playerid, text[])
{
if(GetPVarInt(playerid, "pLogged") == 0) return 0;
new stringtoall[256];
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(stringtoall, sizeof(stringtoall), " > Вы сказали: {ff6600}%s", text);
SetPlayerChatBubble(playerid, text, 0xff6600ff, 30.0, 6000);
SendClientMessage(playerid, -1, stringtoall);
format(stringtoall, sizeof(stringtoall), "%s говорит: {ff6600}%s", playername(playerid), text);
for(new i=MAX_PLAYERS; i--;)
if(i != playerid)
if(IsPlayerStreamedIn(playerid, i))
if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z))
{
SendClientMessage(i, -1, stringtoall);
}
return 0;
}
Да и жить нужно проще.
pawn Код:
|
public OnPlayerText(playerid, text[])
{
if (GetPVarInt(playerid, "pLogged") == 0) {
return 0;
}
SetPlayerChatBubble(playerid, text, 0xff6600ff, 30.0, 6000);
new string[128];
format(string, sizeof(string), " > Вы сказали: {ff6600}%s", text);
SendClientMessage(playerid, -1, string);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(string, sizeof(string), "%s говорит: {ff6600}%s", playername(playerid), text);
for (new i = 0; i < MAX_PLAYERS; i++) {
if (i != playerid && IsPlayerStreamedIn(playerid, i) && IsPlayerInRangeOfPoint(i, 30.0, x, y, z)) {
SendClientMessage(i, -1, string);
}
}
return 0;
}
if(i != playerid) if(IsPlayerStreamedIn(playerid, i)) if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z)) |
Насчёт if-фов.
Мои эксперименты показывают, что так более эффективнее. Т.е. пока первых два условия не будут истинными, IsPlayerInRangeOfPoint не вступит в обработку, в то время, когда у вас он будет обработан. |