Advertisement
Julian90

Freno de Mano ( vehículos )

Aug 1st, 2011
1,784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.07 KB | None | 0 0
  1. /*
  2.         - Sistema de Freno de Mano - ( RolePlay Script )
  3.         - Tipo: Base.
  4.         - Autor: [J]ulian.
  5.         - Para: sa-mp.com
  6. */
  7.  
  8. #include <a_samp>
  9. #define COLOR_PURPLE 0xC2A2DAAA
  10. new idioma; // 0 - Spanish. 1 - English.
  11.  
  12. new FrenodeMano[MAX_VEHICLES] = 0;
  13. new Float:VehFrenoPOS[MAX_VEHICLES][4];
  14. new Float:VehComprobar[MAX_VEHICLES][4];
  15.  
  16. public OnPlayerCommandText(playerid, cmdtext[])
  17. {
  18.     if(!strcmp(cmdtext, "/frenodemano", true) || !strcmp(cmdtext, "/handbrake", true))
  19.     {
  20.         if(IsPlayerInAnyVehicle(playerid))
  21.         {
  22.             new coche = GetPlayerVehicleID(playerid);
  23.             new nombre[MAX_PLAYER_NAME], string_freno[128], partes[7];
  24.             GetPlayerName(playerid, nombre, sizeof(nombre));
  25.             if(FrenodeMano[coche] == 1)
  26.             {
  27.                 FrenodeMano[coche] = 0;
  28.                 if(idioma == 0) format(string_freno, sizeof(string_freno), "* %s quitó el freno de mano al vehículo.", nombre);
  29.                 if(idioma == 1) format(string_freno, sizeof(string_freno), "* %s took the hand brake the vehicle.", nombre);
  30.                 ProxDetector(30.0, playerid, string_freno, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  31.                 GetVehicleParamsEx(coche, partes[0], partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
  32.                 SetVehicleParamsEx(coche,VEHICLE_PARAMS_ON, partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
  33.                 return 1;
  34.             }
  35.             if(FrenodeMano[coche] == 0)
  36.             {
  37.                 FrenodeMano[coche] = 1;
  38.                 GetVehiclePos(coche, VehFrenoPOS[coche][0], VehFrenoPOS[coche][1], VehFrenoPOS[coche][2]);
  39.                 GetVehicleZAngle(coche, VehFrenoPOS[coche][3]);
  40.                 SetVehicleVelocity(coche, 0, 0, 0);
  41.                 if(idioma == 0) format(string_freno, sizeof(string_freno), "* %s colocó el freno de mano al vehículo.", nombre);
  42.                 if(idioma == 1) format(string_freno, sizeof(string_freno), "* %s put the hand brake the vehicle.", nombre);
  43.                 ProxDetector(30.0, playerid, string_freno, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  44.                 GetVehicleParamsEx(coche, partes[0], partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
  45.                 SetVehicleParamsEx(coche,VEHICLE_PARAMS_OFF, partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
  46.                 return 1;
  47.             }
  48.         }
  49.         else
  50.         {
  51.             if(idioma == 0) return SendClientMessage(playerid, -1, "* Debés estar en un vehículo.");
  52.             if(idioma == 1) return SendClientMessage(playerid, -1, "* You must be in a vehicle.");
  53.         }
  54.         return 1;
  55.     }
  56.     return 0;
  57. }
  58.  
  59. public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat)
  60. {
  61.     if(FrenodeMano[vehicleid] == 1)
  62.     {
  63.         GetVehiclePos(playerid, VehComprobar[vehicleid][0], VehComprobar[vehicleid][1], VehComprobar[vehicleid][2]);
  64.         GetVehicleZAngle(playerid, VehComprobar[playerid][3]);
  65.         if(VehComprobar[vehicleid][0] == VehFrenoPOS[vehicleid][0] || VehComprobar[vehicleid][1] == VehFrenoPOS[vehicleid][1] || VehComprobar[vehicleid][2] == VehFrenoPOS[vehicleid][2]|| VehComprobar[vehicleid][3] == VehFrenoPOS[vehicleid][3]) return 1;
  66.         SetVehiclePos(vehicleid, VehFrenoPOS[vehicleid][0], VehFrenoPOS[vehicleid][1], VehFrenoPOS[vehicleid][2]);
  67.         SetVehicleZAngle(vehicleid, VehComprobar[playerid][3]);
  68.     }
  69.     return 1;
  70. }
  71.  
  72. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  73. {
  74.     if((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
  75.     {
  76.         if (IsPlayerInAnyVehicle(playerid))
  77.         {
  78.             new coche = GetPlayerVehicleID(playerid);
  79.             new nombre[MAX_PLAYER_NAME], string_freno[128], partes[7];
  80.             GetPlayerName(playerid, nombre, sizeof(nombre));
  81.             if(FrenodeMano[coche] == 1)
  82.             {
  83.                 FrenodeMano[coche] = 0;
  84.                 if(idioma == 0) format(string_freno, sizeof(string_freno), "* %s quitó el freno de mano al vehículo.", nombre);
  85.                 if(idioma == 1) format(string_freno, sizeof(string_freno), "* %s took the hand brake the vehicle.", nombre);
  86.                 ProxDetector(30.0, playerid, string_freno, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  87.                 GetVehicleParamsEx(coche, partes[0], partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
  88.                 SetVehicleParamsEx(coche,VEHICLE_PARAMS_ON, partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
  89.                 return 1;
  90.             }
  91.             if(FrenodeMano[coche] == 0)
  92.             {
  93.                 FrenodeMano[coche] = 1;
  94.                 GetVehiclePos(coche, VehFrenoPOS[coche][0], VehFrenoPOS[coche][1], VehFrenoPOS[coche][2]);
  95.                 GetVehicleZAngle(coche, VehFrenoPOS[coche][3]);
  96.                 SetVehicleVelocity(coche, 0, 0, 0);
  97.                 if(idioma == 0) format(string_freno, sizeof(string_freno), "* %s colocó el freno de mano al vehículo.", nombre);
  98.                 if(idioma == 1) format(string_freno, sizeof(string_freno), "* %s put the hand brake the vehicle.", nombre);
  99.                 ProxDetector(30.0, playerid, string_freno, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  100.                 GetVehicleParamsEx(coche, partes[0], partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
  101.                 SetVehicleParamsEx(coche,VEHICLE_PARAMS_OFF, partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
  102.                 return 1;
  103.             }
  104.         }
  105.     }
  106.     return 1;
  107. }
  108.  
  109. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  110. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  111. {
  112.    if(IsPlayerConnected(playerid))
  113.    {
  114.       new Float:posx, Float:posy, Float:posz;
  115.       new Float:oldposx, Float:oldposy, Float:oldposz;
  116.       new Float:tempposx, Float:tempposy, Float:tempposz;
  117.       GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  118.       for(new i = 0; i < MAX_PLAYERS; i++)
  119.       {
  120.          if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  121.          {
  122.                GetPlayerPos(i, posx, posy, posz);
  123.                tempposx = (oldposx -posx);
  124.                tempposy = (oldposy -posy);
  125.                tempposz = (oldposz -posz);
  126.                //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  127.                if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  128.                {
  129.                   SendClientMessage(i, col1, string);
  130.                }
  131.                else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  132.                {
  133.                   SendClientMessage(i, col2, string);
  134.                }
  135.                else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  136.                {
  137.                   SendClientMessage(i, col3, string);
  138.                }
  139.                else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  140.                {
  141.                   SendClientMessage(i, col4, string);
  142.                }
  143.                else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  144.                {
  145.                   SendClientMessage(i, col5, string);
  146.                }
  147.          }
  148.       }
  149.    }
  150.    return 1;
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement