Advertisement
Ewolutions

ProxDetector

Apr 7th, 2012
1,421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.38 KB | None | 0 0
  1. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  2. //==============================================================================
  3. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  4. {
  5.     if(IsPlayerConnected(playerid))
  6.     {
  7.         new Float:posx, Float:posy, Float:posz;
  8.         new Float:oldposx, Float:oldposy, Float:oldposz;
  9.         new Float:tempposx, Float:tempposy, Float:tempposz;
  10.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  11.         for(new i = 0; i < MAX_PLAYERS; i++)
  12.         {
  13.             if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  14.             {
  15.                 GetPlayerPos(i, posx, posy, posz);
  16.                 tempposx = (oldposx -posx);
  17.                 tempposy = (oldposy -posy);
  18.                 tempposz = (oldposz -posz);
  19.                 if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16))) // If the player is within 16 meters
  20.                 {
  21.                     SendClientMessage(i, col1, string);
  22.                 }
  23.                 else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8))) // within 8 meters
  24.                 {
  25.                     SendClientMessage(i, col2, string);
  26.                 }
  27.                 else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4))) //4 meters
  28.                 {
  29.                     SendClientMessage(i, col3, string);
  30.                 }
  31.                 else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2))) //2 meters
  32.                 {
  33.                     SendClientMessage(i, col4, string);
  34.                 }
  35.                 else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) //1 meter
  36.                 {
  37.                     SendClientMessage(i, col5, string);
  38.                 }
  39.             }
  40.             else
  41.             {
  42.                 SendClientMessage(i, col1, string);
  43.             }
  44.         }
  45.     }
  46.     return 1;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement