30.06.2013, 11:54
(
Последний раз редактировалось Nines; 10.07.2013 в 21:32.
)
fixed
Originally Posted by https://sampforum.blast.hk/showthread.php?tid=336052
ProxDetector (proximity detector)
For those who don't know, the famous ProxDetector function was introduced in The Godfather Roleplay. Every time a player would type something into the main chat, it would send the message to the nearby players only, and according to their distance from a player, the message would appear darker or lighter. For instance, if I was 30 feet from a player and they typed in the normal chat, the message would come to me dark. If I were to move closer, the message would become lighter. This function was responsible for making the server chat 'realistic' by sending the message to only the players nearby. Note: Using the easier-to-understand version, the changing in color in light of the player distance will not be featured. PHP код:
This line defines floats that will hold the position of the player. It is important you use the "Float:" tag, because coordinates are decimal numbers. PHP код:
PHP код:
PHP код:
PHP код:
PHP код:
|
CMD:b(playerid, params[]) { new string[128]; if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /b [text] (Local OOC Chat)"); if(AntiAdv(playerid, params)) return 1; format(string, sizeof(string), "(( Local OOC: %s: %s ))", NAMEGET(playerid), params); NearMessageSender(playerid, 12, string, COLOR_FADE2,COLOR_FADE2,COLOR_FADE2,COLOR_FADE2,CO LOR_FADE2); return 1; } |
public OnPlayerText(playerid, text[])
{
if (realchat)
{
if (IsDead[playerid] == 1)
{
SCM(playerid,-1,"You can't do that this time");
}
else
{
new string[128];
format(string, sizeof(string), "%s says: %s", GetName(playerid), text);
ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
format(string, sizeof(string), "says: %s", text);
SetPlayerChatBubble(playerid,string,COLOR_WHITE,5.0,5000);
ApplyAnimation(playerid,"PED","IDLE_CHAT",2.0,1,0,0,1,1);
}
return 0;
}
return 1;
}
CMD:b(playerid,params[])
{
new string[128];
if(isnull(params)) return SCM(playerid, -1,"USAGE: /b [local ooc]");
format(string, sizeof(string), "%s: (( %s ))", GetName(playerid), params);
ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
return 1;
}
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerPos(i, posx, posy, posz);
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
new playerworld, player2world;
playerworld = GetPlayerVirtualWorld(playerid);
player2world = GetPlayerVirtualWorld(i);
if(playerworld == player2world)
{
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
SCM(i, col1, string);
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
SCM(i, col2, string);
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
SCM(i, col3, string);
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
SCM(i, col4, string);
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
SCM(i, col5, string);
}
}
else
{
SCM(i, col1, string);
}
}
}
}
return 1;
}
public OnPlayerText(playerid, text[])
{
new string[128];
format(string, sizeof(string), "%s says: %s", GetName(playerid), text);
ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
format(string, sizeof(string), "says: %s", text);
SetPlayerChatBubble(playerid,string,COLOR_WHITE,5.0,5000);
ApplyAnimation(playerid,"PED","IDLE_CHAT",2.0,1,0,0,1,1);
return 1;
}