Advertisement
OtaconEvil

[FS] Flying car | By OTACON

Dec 3rd, 2015
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.68 KB | None | 0 0
  1. /*
  2.     * ## LEASE ATENTAMENTE PARA NO CONVERTIRSE EN LAMMER!!.: :D ##
  3.     *
  4.     * Estè Simple FILTERSCRIPT esta hecho especialmente para www.forum.sa-mp.com
  5.     * NO Publicar estè FILTERSCRIPT en Otros foros de SA-MP y hacerse pasar por el creador del CODE.
  6.     *
  7.     * Codigo Creado Por OTACON
  8.     *
  9.     * CREDITOS:
  10.     *     OTACON: Realizacion y Idea de creacion del code.
  11.     *     TÙ: Modificacion libremente respetando lo mencionado ;).
  12.     *
  13.     *    NOTA: Menos Creditos para los que me los critican.. JO'PUTAS! :D xD ;)
  14.     *
  15.     *                Prohibido TOTALMENTE el Robo de Créditos o la
  16.     *                  Publicación de este FILTERSCRIPT sin Mi Permiso.
  17. */
  18. /*
  19.     * ## READ CAREFULLY TO AVOID BECOMING LAMMER!.: :D ##
  20.     *
  21.     * This simple FILTERSCRIPT is made especially for www.forum.sa-mp.com
  22.     * DO NOT Post the FILTERSCRIPT in Other SAMP forums and impersonating the creator of the CODE.
  23.     *
  24.     * Code Created By OTACON
  25.     *
  26.     * CREDITS:
  27.     *     OTACON: Idea Making and code creation.
  28.     *     YOUR: Modification freely respecting the above ;).
  29.     *
  30.     *    NOTE: Less Credits for those who criticize me.. JO'PUTAS! :D xD ;)
  31.     *
  32.     *                        FULLY spaces Theft Credit or
  33.     *                 Publication of this FILTERSCRIPT without my permission.
  34. */
  35.  
  36. /*
  37.  
  38. www.youtube.com/watch?v=EoVesYgtqhs
  39.  
  40. */
  41.  
  42. native IsValidVehicle(vehicleid);
  43. #include <a_samp>
  44. #include <zcmd>
  45.  
  46. #define TIMER:%0(%1) forward%0(%1); public%0(%1)
  47. #define VEHICULO_VOLADOR (604)
  48. #define TIEMPO_CARGAR (170)
  49. enum vuelo {
  50.     bool:Invisibilidad,
  51.     bool:ActivarCoche,
  52.     Float:VidaCoche,
  53.     ObjetoCoche, };
  54. static CocheVolador[MAX_VEHICLES][vuelo],
  55. MatarCocheVolador[MAX_PLAYERS],
  56. CrearCocheVolador[MAX_PLAYERS];
  57.  
  58. public OnPlayerStateChange(playerid, newstate, oldstate){
  59.     new vehicleid = GetPlayerVehicleID(playerid);
  60.     switch(GetVehicleModel(vehicleid)){
  61.         case VEHICULO_VOLADOR:{
  62.             switch(CocheVolador[vehicleid][ActivarCoche]){
  63.                 case true:{
  64.                     switch(GetPlayerState(playerid)){
  65.                         case PLAYER_STATE_DRIVER:{KillTimer(MatarCocheVolador[playerid]); MatarCocheVolador[playerid]=SetTimerEx("ActualizarCocheVolador", TIEMPO_CARGAR, true, "d", playerid);}
  66.                         case PLAYER_STATE_ONFOOT:{KillTimer(MatarCocheVolador[playerid]);}
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.     } return true;
  72. }
  73.  
  74. COMMAND:car(playerid, params[]){
  75.     new Float:pos[4];
  76.     GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  77.     GetPlayerFacingAngle(playerid,pos[3]);
  78.     DestroyVehicle(CrearCocheVolador[playerid]);
  79.     CrearCocheVolador[playerid]=CreateVehicle(VEHICULO_VOLADOR,pos[0],pos[1],pos[2],pos[3],-1,-1,999999);
  80.     PutPlayerInVehicle(playerid,CrearCocheVolador[playerid],0);
  81.     return true;
  82. }
  83.  
  84. COMMAND:fly(playerid, params[]){
  85.     new vehicleid = GetPlayerVehicleID(playerid);
  86.     switch(GetPlayerState(playerid)){
  87.         case PLAYER_STATE_DRIVER:{
  88.             if(GetVehicleModel(vehicleid)!=VEHICULO_VOLADOR) return SendClientMessage(playerid,-1,"INFO: Este vehiculo no tiene sistema de vuelo!.");
  89.             switch(CocheVolador[vehicleid][ActivarCoche]){
  90.                 case false:{
  91.                     CocheVolador[vehicleid][ActivarCoche]=true;
  92.                     new Float:health;
  93.                     GetVehicleHealth(vehicleid, health);
  94.                     CocheVolador[vehicleid][VidaCoche]=health;
  95.                     SetVehicleHealth(vehicleid, (Float:0x7F800000));
  96.                     SetVehicleVelocity(vehicleid,0,0,0);
  97.                     KillTimer(MatarCocheVolador[playerid]);
  98.                     MatarCocheVolador[playerid] = SetTimerEx("ActualizarCocheVolador", TIEMPO_CARGAR, true, "d", playerid);
  99.                     DestroyObject(CocheVolador[vehicleid][ObjetoCoche]);
  100.                     CocheVolador[vehicleid][ObjetoCoche]=CreateObject(18725,0,0,0,0,0,0);
  101.                     AttachObjectToVehicle(CocheVolador[vehicleid][ObjetoCoche],vehicleid,-0.5,-1.0,1.0,0.0,180.0,0.0);
  102.                     SendClientMessage(playerid,-1,"INFO: Sistema de vuelo activado!.");
  103.                 }
  104.                 case true:{
  105.                     CocheVolador[vehicleid][ActivarCoche]=false;
  106.                     SetVehicleHealth(vehicleid, CocheVolador[vehicleid][VidaCoche]);
  107.                     CocheVolador[vehicleid][VidaCoche]=0;
  108.                     SetVehicleVelocity(vehicleid,0,0,0);
  109.                     KillTimer(MatarCocheVolador[playerid]);
  110.                     DestroyObject(CocheVolador[vehicleid][ObjetoCoche]);
  111.                     SendClientMessage(playerid,-1,"INFO: Sistema de vuelo desactivado!.");
  112.                 }
  113.             }
  114.         } default:{SendClientMessage(playerid,-1,"INFO: Usted no se encuentra a pie!.");}
  115.     } return true;
  116. }
  117.  
  118. COMMAND:invisible(playerid, params[]){
  119.     new vehicleid = GetPlayerVehicleID(playerid);
  120.     switch(GetPlayerState(playerid)){
  121.         case PLAYER_STATE_DRIVER:{
  122.             switch(GetVehicleModel(vehicleid)){
  123.                 case VEHICULO_VOLADOR:{
  124.                     switch(CocheVolador[vehicleid][ActivarCoche]){
  125.                         case true:{
  126.                             switch(CocheVolador[vehicleid][Invisibilidad]){
  127.                                 case false:{
  128.                                     LinkVehicleToInterior(vehicleid, 6);
  129.                                     CocheVolador[vehicleid][Invisibilidad]=true;}
  130.                                 case true:{
  131.                                     LinkVehicleToInterior(vehicleid, 0);
  132.                                     CocheVolador[vehicleid][Invisibilidad]=false;}
  133.                             }
  134.                         }
  135.                     }
  136.                 } default:{SendClientMessage(playerid,-1,"INFO: Este vehiculo no tiene sistema de vuelo!.");}
  137.             }
  138.         } default:{SendClientMessage(playerid,-1,"INFO: Usted no se encuentra en un vehiculo, o usted no es el conductor del vehiculo!.");}
  139.     } return true;
  140. }
  141.  
  142. TIMER: ActualizarCocheVolador(playerid){
  143.     new vehicleid = GetPlayerVehicleID(playerid);
  144.     switch(GetVehicleModel(vehicleid)){
  145.         case VEHICULO_VOLADOR:{
  146.             static TeclasCoche[3], Float:PosicionCoche[2][3];
  147.             GetPlayerKeys(playerid,TeclasCoche[0],TeclasCoche[1],TeclasCoche[2]);
  148.             if(TeclasCoche[0] & KEY_HANDBRAKE && CocheVolador[vehicleid][ActivarCoche]==true){
  149.                 GetPlayerCameraPos(playerid, PosicionCoche[1][0],PosicionCoche[1][1],PosicionCoche[1][2]);
  150.                 GetPlayerCameraFrontVector(playerid, PosicionCoche[0][0],PosicionCoche[0][1],PosicionCoche[0][2]);
  151.                 SetVehicleToFacePos(vehicleid, PosicionCoche[0][0] + PosicionCoche[1][0], PosicionCoche[0][1]+PosicionCoche[1][1]);
  152.                 SetVehicleVelocity(vehicleid, PosicionCoche[0][0]*1.0, PosicionCoche[0][1]*1.0, PosicionCoche[0][2]*1.0);
  153.             }
  154.         }
  155.     } return true;
  156. }
  157.  
  158. TIMER: Float:SetVehicleToFacePos(vehicleid, Float:X, Float:Y){
  159.     new Float:pX, Float:pY, Float:pZ, Float:ang;
  160.     if(!IsValidVehicle(vehicleid)) return 0.0;
  161.     GetVehiclePos(vehicleid, pX, pY, pZ);
  162.     if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  163.     else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  164.     else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  165.     if(X > pX) ang = (floatabs(floatabs(ang) + 180.0));
  166.     else ang = (floatabs(ang) - 180.0);
  167.     ang += 180.0;
  168.     SetVehicleZAngle(vehicleid, ang);
  169.     return ang;
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement