Advertisement
Guest User

Joe Torran C

a guest
May 24th, 2010
6,090
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.92 KB | None | 0 0
  1. // [FS] Engine System v3
  2. // Made by Joe Torran C
  3. // Credits to JeNkStA for helping me fix some stuff
  4. // DO NOT REMOVE THESE CREDITS
  5.  
  6. #include <a_samp>
  7. #include <zcmd>
  8.  
  9. #define colorRed        0xFF0000FF
  10. #define colorYellow     0xFFFF00FF
  11.  
  12. forward StartEngine(playerid);
  13. forward DamagedEngine(playerid);
  14.  
  15. new vehEngine[MAX_VEHICLES];
  16.  
  17. public OnPlayerStateChange(playerid, newstate, oldstate)
  18. {
  19.     new vehicleid = GetPlayerVehicleID(playerid);
  20.    
  21.     if(newstate == PLAYER_STATE_DRIVER)
  22.     {
  23.         if(vehEngine[vehicleid] == 0)
  24.         {
  25.             TogglePlayerControllable(playerid, 0);
  26.             SendClientMessage(playerid, colorYellow, "Vehicle engine NOT started");
  27.             SendClientMessage(playerid, colorYellow, "To start the vehicle's engine press \"Shift\" or type \"/engine\"");
  28.         }
  29.         else if(vehEngine[vehicleid] == 1)
  30.         {
  31.             TogglePlayerControllable(playerid, 1);
  32.             SendClientMessage(playerid, colorYellow, "Vehicle engine running");
  33.         }
  34.     }
  35.     return 1;
  36. }
  37.  
  38. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  39. {
  40.     new vehicleid = GetPlayerVehicleID(playerid);
  41.    
  42.     if(IsPlayerInAnyVehicle(playerid))
  43.     {
  44.         if(vehEngine[vehicleid] == 0)
  45.         {
  46.             if(newkeys == KEY_JUMP)
  47.             {
  48.                 vehEngine[vehicleid] = 2;
  49.                 SetTimerEx("StartEngine", 3000, 0, "i", playerid);
  50.                 SendClientMessage(playerid, colorYellow, "Vehicle engine starting");
  51.             }
  52.         }
  53.         if(newkeys == KEY_SECONDARY_ATTACK)
  54.         {
  55.             RemovePlayerFromVehicle(playerid);
  56.             TogglePlayerControllable(playerid, 1);
  57.         }
  58.     }
  59.     return 1;
  60. }
  61.  
  62. public StartEngine(playerid)
  63. {
  64.     new vehicleid = GetPlayerVehicleID(playerid);
  65.     new Float:health;
  66.     new rand = random(2);
  67.    
  68.     GetVehicleHealth(vehicleid, health);
  69.    
  70.     if(IsPlayerInAnyVehicle(playerid))
  71.     {
  72.         if(vehEngine[vehicleid] == 2)
  73.         {
  74.             if(health > 300)
  75.             {
  76.                 if(rand == 0)
  77.                 {
  78.                     vehEngine[vehicleid] = 1;
  79.                     TogglePlayerControllable(playerid, 1);
  80.                     SetTimerEx("DamagedEngine", 1000, 1, "i", playerid);
  81.                     SendClientMessage(playerid, colorYellow, "Vehicle engine started");
  82.                 }
  83.                 if(rand == 1)
  84.                 {
  85.                     vehEngine[vehicleid] = 0;
  86.                     TogglePlayerControllable(playerid, 0);
  87.                     SendClientMessage(playerid, colorYellow, "Vehicle engine failed to start");
  88.                 }
  89.             }
  90.             else
  91.             {
  92.                 vehEngine[vehicleid] = 0;
  93.                 TogglePlayerControllable(playerid, 0);
  94.                 SendClientMessage(playerid, colorYellow, "Vehicle engine failed to start due to damage");
  95.             }
  96.         }
  97.     }
  98.     return 1;
  99. }
  100.  
  101. public DamagedEngine(playerid)
  102. {
  103.     new vehicleid = GetPlayerVehicleID(playerid);
  104.     new Float:health;
  105.    
  106.     GetVehicleHealth(vehicleid, health);
  107.  
  108.     if(IsPlayerInAnyVehicle(playerid))
  109.     {
  110.         if(vehEngine[vehicleid] == 1)
  111.         {
  112.             if(health < 300)
  113.             {
  114.                 vehEngine[vehicleid] = 0;
  115.                 TogglePlayerControllable(playerid, 0);
  116.                 SendClientMessage(playerid, colorYellow, "Vehicle engine stopped due to damage");
  117.             }
  118.         }
  119.     }
  120.     return 1;
  121. }
  122.  
  123. public OnPlayerExitVehicle(playerid, vehicleid)
  124. {
  125.     TogglePlayerControllable(playerid, 1);
  126.     return 1;
  127. }
  128.                
  129. CMD:engine(playerid, params[])
  130. {
  131.     new vehicleid = GetPlayerVehicleID(playerid);
  132.  
  133.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, colorRed, "You need to be in a vehicle to use this command");
  134.    
  135.     if(vehEngine[vehicleid] == 0)
  136.     {
  137.         vehEngine[vehicleid] = 2;
  138.         SetTimerEx("StartEngine", 3000, 0, "i", playerid);
  139.         SendClientMessage(playerid, colorYellow, "Vehicle engine starting");
  140.     }
  141.     else if(vehEngine[vehicleid] == 1)
  142.     {
  143.         vehEngine[vehicleid] = 0;
  144.         TogglePlayerControllable(playerid, 0);
  145.         SendClientMessage(playerid, colorYellow, "Vehicle engine stopped");
  146.         SendClientMessage(playerid, colorYellow, "To re-start the vehicle's engine press \"Shift\" or type \"/engine\"");
  147.     }
  148.     return 1;
  149. }
  150.  
  151. public OnFilterScriptInit()
  152. {
  153.     print("\n  [FS] Engine System v3 by Joe Torran C \n");
  154.     return 1;
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement