Advertisement
Guest User

Untitled

a guest
Jan 18th, 2023
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.25 KB | None | 0 0
  1. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  2. {
  3.     if(IsPlayerConnected(playerid))
  4.     {
  5.         new Float:posx, Float:posy, Float:posz;
  6.         new Float:oldposx, Float:oldposy, Float:oldposz;
  7.         new Float:tempposx, Float:tempposy, Float:tempposz;
  8.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  9.         //radi = 2.0; //Trigger Radius
  10.         for(new i = 0; i < MAX_PLAYERS; i++)
  11.         {
  12.             if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  13.             {
  14.                 GetPlayerPos(i, posx, posy, posz);
  15.                 tempposx = (oldposx -posx);
  16.                 tempposy = (oldposy -posy);
  17.                 tempposz = (oldposz -posz);
  18.                 //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  19.                 if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  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)))
  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)))
  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)))
  32.                 {
  33.                     SendClientMessage(i, col4, string);
  34.                 }
  35.                 else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  36.                 {
  37.                     SendClientMessage(i, col5, string);
  38.                 }
  39.             }
  40.             else
  41.             {
  42.                 SendClientMessage(i, col1, string);
  43.             }
  44.         }
  45.     }//not connected
  46.     return 1;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement