Advertisement
2ky

ProxDetector

2ky
Mar 1st, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. stock 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. new invehicle[MAX_PLAYERS];
  9. new virtualworld = GetPlayerVirtualWorld(playerid);
  10. new interior = GetPlayerInterior(playerid);
  11. new vehicleid = GetPlayerVehicleID(playerid);
  12. new ivehicleid;
  13. if(vehicleid)
  14. {
  15. GetVehiclePos(vehicleid,oldposx,oldposy,oldposz);
  16. }
  17. else
  18. {
  19. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  20. vehicleid = GetPlayerVehicleID(playerid);
  21. }
  22. for(new i; i<MAX_PLAYERS; i++)
  23. {
  24. if(IsPlayerConnected(i))
  25. {
  26. if(GetPlayerVirtualWorld(i) == virtualworld)
  27. {
  28. if((GetPlayerInterior(i) == interior))
  29. {
  30. if(vehicleid)
  31. {
  32. if(IsPlayerInVehicle(i,vehicleid))
  33. {
  34. invehicle[i] = 1;
  35. }
  36. }
  37. if(!invehicle[i])
  38. {
  39. if(IsPlayerInAnyVehicle(i))
  40. {
  41. ivehicleid = GetPlayerVehicleID(i);
  42. GetVehiclePos(ivehicleid,posx,posy,posz);
  43. } else {
  44. GetPlayerPos(i,posx,posy,posz);
  45. }
  46. tempposx = (oldposx -posx);
  47. tempposy = (oldposy -posy);
  48. tempposz = (oldposz -posz);
  49. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  50. {
  51. SendClientMessage(i, col1, string);
  52. }
  53. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  54. {
  55. SendClientMessage(i, col2, string);
  56. }
  57. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  58. {
  59. SendClientMessage(i, col3, string);
  60. }
  61. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  62. {
  63. SendClientMessage(i, col4, string);
  64. }
  65. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  66. {
  67. SendClientMessage(i, col5, string);
  68. }
  69. }
  70. else
  71. {
  72. SendClientMessage(i, col1, string);
  73. }
  74. }
  75. }
  76. } else {
  77. SendClientMessage(i, col1, string);
  78. }
  79. }
  80. }
  81. return 1;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement