Advertisement
Guest User

Untitled

a guest
Sep 18th, 2010
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.27 KB | None | 0 0
  1. /*
  2. *
  3. *   -=HOMEHOST.NET =-
  4. *   Larceny Radar Veícular
  5. *
  6. *   Autor: Larceny
  7. *   Postador: Viitor_Souza
  8. *
  9. */
  10. #include "a_samp"
  11.  
  12. #define MAX_Radar 100
  13. #define LR_TEMPO_CHECAGEM 1500 // Tempo em milisegundos.
  14.  
  15. /*Lista de funções do sistema LR -----------------------------------------------------------------------------||
  16.  
  17. native lr_CriarRadar(Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, virtualword = -1);
  18. native lr_DestruirRadar(lrid);
  19. native lr_RadarExiste(lrid);
  20. native lr_MudarPosRadar(lrid, Float:x, Float:y, Float:z);
  21. native lr_MudarVWRadar(lrid, virtualworld);
  22. native lr_PegarPosRadar(lrid, &Float:x, &Float:y, &Float:z);
  23. native lr_PegarVWRadar(lrid);
  24.  
  25. /------------------------------------------------------------------------------------------------------------||*/
  26.  
  27. enum lrdef
  28. {
  29.     lr_VW,
  30.     lr_OID,
  31.     Float:lr_X,
  32.     Float:lr_Y,
  33.     Float:lr_Z,
  34.     lr_speedmax,
  35. };
  36.  
  37. static  lr_Timer, lr_Total, lr_Radar[MAX_Radar][lrdef];
  38.  
  39. #define lr_ChecarTimerAd() if(!lr_Timer) lr_Timer = SetTimer("lr_ChecarRadar", LR_TEMPO_CHECAGEM, 1)
  40. #define lr_ChecarTimerRe() if(!lr_Total){KillTimer(lr_Timer); lr_Timer = 0;}
  41.  
  42. forward lr_ChecarRadar();
  43. forward OcultarRadar(playerid);
  44. forward JogadorNoPonto(Float:radi, playerid, Float:x, Float:y, Float:z);
  45. forward OnPlayerEnterRadar(playerid);
  46. forward CreateRadar();
  47.  
  48. new Text:Radar;
  49.  
  50. stock lr_CriarRadar(Float:x, Float:y, Float:z, speedmax, virtualword = -1)
  51. {
  52.     new bid = lr_ProcurarIDLivre();
  53.     if(bid == -1)
  54.     {
  55.         printf("[lr]: Limite de Radar (MAX_Radar = %d) foi excedido! Aumente o valor ou apague algum...", MAX_Radar);
  56.         return 0;
  57.     }
  58.     lr_Radar[bid][lr_OID] = CreatePickup(1318,1,x,y,z+2,-1);
  59.     lr_Radar[bid][lr_X] = x;
  60.     lr_Radar[bid][lr_Y] = y;
  61.     lr_Radar[bid][lr_Z] = z;
  62.     lr_Radar[bid][lr_speedmax] = speedmax;
  63.     lr_Radar[bid][lr_VW] = virtualword;
  64.     lr_ChecarTimerAd();
  65.     lr_Total++;
  66.     return bid;
  67. }
  68.  
  69. stock lr_DestruirRadar(lrid)
  70. {
  71.     if(!lr_Radar[lrid][lr_OID]) return 0;
  72.     lr_Total--;
  73.     pso_RemoverObjeto(lr_Radar[lrid][lr_OID]);
  74.     lr_Radar[lrid][lr_OID] = 0;
  75.     lr_ChecarTimerRe()
  76.     return 1;
  77. }
  78.  
  79. stock lr_RadarExiste(lrid)  return (!lr_Radar[lrid][lr_OID]) ? 0 : 1;
  80.  
  81. stock lr_MudarPosRadar(lrid, Float:x, Float:y, Float:z)
  82. {
  83.     if(!lr_Radar[lrid][lr_OID]) return 0;
  84.     lr_Radar[lrid][lr_X] = x;
  85.     lr_Radar[lrid][lr_Y] = y;
  86.     lr_Radar[lrid][lr_Z] = z;
  87.     return pso_MudarPosObjeto(lr_Radar[lrid][lr_OID], x, y, z);
  88. }
  89.  
  90. stock lr_MudarVWRadar(lrid, virtualworld)
  91. {
  92.     if(!lr_Radar[lrid][lr_OID]) return 0;
  93.     lr_Radar[lrid][lr_VW] = virtualworld;
  94.     return pso_MudarVirtualWorldObjeto(lr_Radar[lrid][lr_OID], virtualworld);
  95. }
  96.  
  97. stock lr_PegarPosRadar(lrid, &Float:x, &Float:y, &Float:z)
  98. {
  99.     if(!lr_Radar[lrid][lr_OID])
  100.     {
  101.         x = 0.0;
  102.         y = 0.0;
  103.         z = 0.0;
  104.     }
  105.     x = lr_Radar[lrid][lr_X];
  106.     y = lr_Radar[lrid][lr_Y];
  107.     z = lr_Radar[lrid][lr_Z];
  108. }
  109.  
  110. stock lr_PegarVWRadar(lrid)
  111. {
  112.     if(!lr_Radar[lrid][lr_OID]) return 0;
  113.     return lr_Radar[lrid][lr_VW];
  114. }
  115.  
  116. public JogadorNoPonto(Float:radi, playerid, Float:x, Float:y, Float:z)
  117. {
  118.     if(IsPlayerConnected(playerid))
  119.     {
  120.         new Float:oldposx, Float:oldposy, Float:oldposz;
  121.         new Float:tempposx, Float:tempposy, Float:tempposz;
  122.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  123.         tempposx = (oldposx -x);
  124.         tempposy = (oldposy -y);
  125.         tempposz = (oldposz -z);
  126.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  127.         {
  128.             return 1;
  129.         }
  130.     }
  131.     return 0;
  132. }
  133.  
  134. public lr_ChecarRadar()
  135. {
  136.     for(new i = 0; i < MAX_PLAYERS; i++)
  137.     {
  138.         for(new b = 1; b <= lr_Total; b++)
  139.         {
  140.             if(lr_Radar[b][lr_OID])
  141.             {
  142.                 if(lr_Radar[b][lr_VW] == -1 || GetPlayerVirtualWorld(i) == lr_Radar[b][lr_VW])
  143.                 {
  144.                     if(JogadorNoPonto(20.0, i, lr_Radar[b][lr_X], lr_Radar[b][lr_Y], lr_Radar[b][lr_Z]))
  145.                     {
  146.                         RadarForPlayer(i, lr_Radar[b][lr_speedmax]);
  147.                     }  
  148.                 }
  149.             }
  150.         }
  151.     }
  152. }
  153.  
  154. stock lr_ProcurarIDLivre()
  155. {
  156.     for(new b = 1; b < MAX_Radar; b++) if(!lr_Radar[b][lr_OID]) return b;
  157.     return -1;
  158. }
  159.  
  160. stock ObterVelocidade(playerid, bool:velo)
  161. {
  162.     new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
  163.     if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
  164.     rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
  165.     return velo?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
  166. }
  167.  
  168. stock RadarForPlayer(playerid, velocidademax)
  169. {
  170.     new velocidadeatual = ObterVelocidade(playerid, true);
  171.     if(velocidadeatual >= velocidademax)
  172.     {
  173.         TextDrawShowForPlayer(playerid, Radar);
  174.         PlayerPlaySound(playerid,1132,0.0,0.0,0.0);
  175.         SetTimerEx("OcultarRadar", 1500, 0, "d", playerid);
  176.         OnPlayerEnterRadar(playerid);
  177.     }
  178.     return 1;
  179. }
  180. public OcultarRadar(playerid)
  181. {
  182.     TextDrawHideForPlayer(playerid, Radar);
  183.     PlayerPlaySound(playerid,1132,0.0,0.0,0.0);
  184.     return 1;
  185. }
  186.  
  187. public CreateRadar()
  188. {
  189.     Radar = TextDrawCreate(635.000000, 432.000000, "__");
  190.     TextDrawBackgroundColor(Radar, 255);
  191.     TextDrawFont(Radar, 1);
  192.     TextDrawLetterSize(Radar, 0.500000, -45.900001);
  193.     TextDrawColor(Radar, -256);
  194.     TextDrawSetOutline(Radar, 0);
  195.     TextDrawSetProportional(Radar, 1);
  196.     TextDrawSetShadow(Radar, 1);
  197.     TextDrawUseBox(Radar, 1);
  198.     TextDrawBoxColor(Radar, -86);
  199.     TextDrawTextSize(Radar, 6.000000, 35.000000);
  200.     return 1;
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement