Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.33 KB | None | 0 0
  1. stock ProxDetector(playerid, Float:max_range, color, string[], Float:max_ratio = 1.6)
  2. { // by ziggi
  3.     new
  4.         Float:pos_x,
  5.         Float:pos_y,
  6.         Float:pos_z,
  7.         Float:range,
  8.         Float:range_ratio,
  9.         Float:range_with_ratio,
  10.         clr_r, clr_g, clr_b,
  11.         Float:color_r, Float:color_g, Float:color_b;
  12.  
  13.     if (!GetPlayerPos(playerid, pos_x, pos_y, pos_z)) {
  14.         return 0;
  15.     }
  16.  
  17.     color_r = float(color >> 24 & 0xFF);
  18.     color_g = float(color >> 16 & 0xFF);
  19.     color_b = float(color >> 8 & 0xFF);
  20.     range_with_ratio = max_range * max_ratio;
  21.  
  22. #if defined foreach
  23.     foreach (new i : Player) {
  24. #else
  25.     for (new i = GetPlayerPoolSize(); i != -1; i--) {
  26. #endif
  27.         if (!IsPlayerStreamedIn(playerid, i)) {
  28.             continue;
  29.         }
  30.  
  31.         range = GetPlayerDistanceFromPoint(i, pos_x, pos_y, pos_z);
  32.         if (range > max_range) {
  33.             continue;
  34.         }
  35.  
  36.         range_ratio = (range_with_ratio - range) / range_with_ratio;
  37.         clr_r = floatround(range_ratio * color_r);
  38.         clr_g = floatround(range_ratio * color_g);
  39.         clr_b = floatround(range_ratio * color_b);
  40.  
  41.         SendClientMessage(i, (color & 0xFF) | (clr_b << 8) | (clr_g << 16) | (clr_r << 24), string);
  42.     }
  43.  
  44.     SendClientMessage(playerid, color, string);
  45.     return 1;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement