04.06.2011, 04:54
For example, i want to limit the /me command to 20 feet away. How is this possible?
stock GetDistanceBetweenPlayers(playerid,playerid2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}
if(GetDistanceBetweenPlayers(playerid ,id) > 2.0)return SendClientMessage(playerid,Grey,"You are to far from that player");
forward ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5); public ProxDetector(Float:radi, playerid, str[],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); //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz); if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16))) { SendClientMessage(i, col1, str); } else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8))) { SendClientMessage(i, col2, str); } else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4))) { SendClientMessage(i, col3, str); } else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2))) { SendClientMessage(i, col4, str); } else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { SendClientMessage(i, col5, str); } } } }//not connected return 1; }
Wait, will this allow me to just do /me and everyone in 10 meters or w/e will hear it? Im confused...
Show me an example of a local connection, where when the player connects, only the few people in 10 meters will see it. |
COMMAND:w(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, Grey, "Usage: /w [message]");
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
format(String, sizeof(String), "[Whisper] %s: %s.",Name,params);
foreach(Player,i)
{
if(GetDistanceBetweenPlayers(playerid,i) < 5.0)//Only player within 5.0 meters will see it.
SendClientMessage(i,0xE3FFBBFF,String);
}
return 1;
}