Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * -=HOMEHOST.NET =-
- * Larceny Radar Veícular
- *
- * Autor: Larceny
- * Postador: Viitor_Souza
- *
- */
- #include "a_samp"
- #define MAX_Radar 100
- #define LR_TEMPO_CHECAGEM 1500 // Tempo em milisegundos.
- /*Lista de funções do sistema LR -----------------------------------------------------------------------------||
- native lr_CriarRadar(Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, virtualword = -1);
- native lr_DestruirRadar(lrid);
- native lr_RadarExiste(lrid);
- native lr_MudarPosRadar(lrid, Float:x, Float:y, Float:z);
- native lr_MudarVWRadar(lrid, virtualworld);
- native lr_PegarPosRadar(lrid, &Float:x, &Float:y, &Float:z);
- native lr_PegarVWRadar(lrid);
- /------------------------------------------------------------------------------------------------------------||*/
- enum lrdef
- {
- lr_VW,
- lr_OID,
- Float:lr_X,
- Float:lr_Y,
- Float:lr_Z,
- lr_speedmax,
- };
- static lr_Timer, lr_Total, lr_Radar[MAX_Radar][lrdef];
- #define lr_ChecarTimerAd() if(!lr_Timer) lr_Timer = SetTimer("lr_ChecarRadar", LR_TEMPO_CHECAGEM, 1)
- #define lr_ChecarTimerRe() if(!lr_Total){KillTimer(lr_Timer); lr_Timer = 0;}
- forward lr_ChecarRadar();
- forward OcultarRadar(playerid);
- forward JogadorNoPonto(Float:radi, playerid, Float:x, Float:y, Float:z);
- forward OnPlayerEnterRadar(playerid);
- forward CreateRadar();
- new Text:Radar;
- stock lr_CriarRadar(Float:x, Float:y, Float:z, speedmax, virtualword = -1)
- {
- new bid = lr_ProcurarIDLivre();
- if(bid == -1)
- {
- printf("[lr]: Limite de Radar (MAX_Radar = %d) foi excedido! Aumente o valor ou apague algum...", MAX_Radar);
- return 0;
- }
- lr_Radar[bid][lr_OID] = CreatePickup(1318,1,x,y,z+2,-1);
- lr_Radar[bid][lr_X] = x;
- lr_Radar[bid][lr_Y] = y;
- lr_Radar[bid][lr_Z] = z;
- lr_Radar[bid][lr_speedmax] = speedmax;
- lr_Radar[bid][lr_VW] = virtualword;
- lr_ChecarTimerAd();
- lr_Total++;
- return bid;
- }
- stock lr_DestruirRadar(lrid)
- {
- if(!lr_Radar[lrid][lr_OID]) return 0;
- lr_Total--;
- pso_RemoverObjeto(lr_Radar[lrid][lr_OID]);
- lr_Radar[lrid][lr_OID] = 0;
- lr_ChecarTimerRe()
- return 1;
- }
- stock lr_RadarExiste(lrid) return (!lr_Radar[lrid][lr_OID]) ? 0 : 1;
- stock lr_MudarPosRadar(lrid, Float:x, Float:y, Float:z)
- {
- if(!lr_Radar[lrid][lr_OID]) return 0;
- lr_Radar[lrid][lr_X] = x;
- lr_Radar[lrid][lr_Y] = y;
- lr_Radar[lrid][lr_Z] = z;
- return pso_MudarPosObjeto(lr_Radar[lrid][lr_OID], x, y, z);
- }
- stock lr_MudarVWRadar(lrid, virtualworld)
- {
- if(!lr_Radar[lrid][lr_OID]) return 0;
- lr_Radar[lrid][lr_VW] = virtualworld;
- return pso_MudarVirtualWorldObjeto(lr_Radar[lrid][lr_OID], virtualworld);
- }
- stock lr_PegarPosRadar(lrid, &Float:x, &Float:y, &Float:z)
- {
- if(!lr_Radar[lrid][lr_OID])
- {
- x = 0.0;
- y = 0.0;
- z = 0.0;
- }
- x = lr_Radar[lrid][lr_X];
- y = lr_Radar[lrid][lr_Y];
- z = lr_Radar[lrid][lr_Z];
- }
- stock lr_PegarVWRadar(lrid)
- {
- if(!lr_Radar[lrid][lr_OID]) return 0;
- return lr_Radar[lrid][lr_VW];
- }
- public JogadorNoPonto(Float:radi, playerid, Float:x, Float:y, Float:z)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- tempposx = (oldposx -x);
- tempposy = (oldposy -y);
- tempposz = (oldposz -z);
- if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- return 1;
- }
- }
- return 0;
- }
- public lr_ChecarRadar()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- for(new b = 1; b <= lr_Total; b++)
- {
- if(lr_Radar[b][lr_OID])
- {
- if(lr_Radar[b][lr_VW] == -1 || GetPlayerVirtualWorld(i) == lr_Radar[b][lr_VW])
- {
- if(JogadorNoPonto(20.0, i, lr_Radar[b][lr_X], lr_Radar[b][lr_Y], lr_Radar[b][lr_Z]))
- {
- RadarForPlayer(i, lr_Radar[b][lr_speedmax]);
- }
- }
- }
- }
- }
- }
- stock lr_ProcurarIDLivre()
- {
- for(new b = 1; b < MAX_Radar; b++) if(!lr_Radar[b][lr_OID]) return b;
- return -1;
- }
- stock ObterVelocidade(playerid, bool:velo)
- {
- new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
- if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
- rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
- return velo?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
- }
- stock RadarForPlayer(playerid, velocidademax)
- {
- new velocidadeatual = ObterVelocidade(playerid, true);
- if(velocidadeatual >= velocidademax)
- {
- TextDrawShowForPlayer(playerid, Radar);
- PlayerPlaySound(playerid,1132,0.0,0.0,0.0);
- SetTimerEx("OcultarRadar", 1500, 0, "d", playerid);
- OnPlayerEnterRadar(playerid);
- }
- return 1;
- }
- public OcultarRadar(playerid)
- {
- TextDrawHideForPlayer(playerid, Radar);
- PlayerPlaySound(playerid,1132,0.0,0.0,0.0);
- return 1;
- }
- public CreateRadar()
- {
- Radar = TextDrawCreate(635.000000, 432.000000, "__");
- TextDrawBackgroundColor(Radar, 255);
- TextDrawFont(Radar, 1);
- TextDrawLetterSize(Radar, 0.500000, -45.900001);
- TextDrawColor(Radar, -256);
- TextDrawSetOutline(Radar, 0);
- TextDrawSetProportional(Radar, 1);
- TextDrawSetShadow(Radar, 1);
- TextDrawUseBox(Radar, 1);
- TextDrawBoxColor(Radar, -86);
- TextDrawTextSize(Radar, 6.000000, 35.000000);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement