Advertisement
Guest User

Vehicle Control System 1.5 [Jack_Leslie]

a guest
Aug 1st, 2011
2,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.99 KB | None | 0 0
  1. /*
  2.  
  3. Vehicle Control System by Jack Leslie
  4. Released on http://forum.sa-mp.com
  5. Used at "Real Life Roleplay" www.real-rp.com
  6. Editing of this script and then re-releasing without original credits is prohibited
  7.  
  8. Current Version: 1.5
  9.  
  10. What's new?
  11.  
  12. Objective (/objective)
  13. /trunk and /hood from the outside
  14.  
  15. Upcoming Version: 2.0
  16.  
  17. What's included?
  18.  
  19. Storing armour and money into the trunk
  20.  
  21.  
  22. Upcoming Version: 3.0
  23.  
  24. What's included?
  25.  
  26. Storing weapons inside the trunk
  27. Post suggestions on the thread @ http://forum.sa-mp.com
  28.  
  29. */
  30.  
  31. #define FILTERSCRIPT
  32. #include <a_samp>
  33. #include <zcmd>
  34. #define red 0xAA3333AA //Change this to the error color you want.
  35. #define COLOR_PURPLE 0xC2A2DAAA //prox detector color
  36. new gLastCar[MAX_PLAYERS];
  37.  
  38.  
  39.  
  40.  
  41. stock IsABoat(vehicleid)
  42. {
  43.     switch(GetVehicleModel(vehicleid))
  44.     {
  45.         case 430,446,452,453,454,472,473,484,493,595: return 1;
  46.     }
  47.     return 0;
  48. }
  49.  
  50. stock IsAPlane(vehicleid)
  51. {
  52.     switch(GetVehicleModel(vehicleid))
  53.     {
  54.         case 460,464,476,511,512,513,519,520,553,577,592,593: return 1;
  55.     }
  56.     return 0;
  57. }
  58.  
  59. stock IsAHelicopter(vehicleid)
  60. {
  61.     switch(GetVehicleModel(vehicleid))
  62.     {
  63.         case 417,425,447,465,469,487,488,497,501,548,563: return 1;
  64.     }
  65.     return 0;
  66. }
  67.  
  68. stock IsATrain(vehicleid)
  69. {
  70.     switch(GetVehicleModel(vehicleid))
  71.     {
  72.         case 449,537,538,569,570,590: return 1;
  73.     }
  74.     return 0;
  75. }
  76.  
  77. stock IsABike(vehicleid)
  78. {
  79.     switch(GetVehicleModel(vehicleid))
  80.     {
  81.         case 448,461,462,463,468,521,522,523,581,586,481,409,510: return 1;
  82.     }
  83.     return 0;
  84. }
  85.  
  86. stock IsPlayerDriver(playerid)
  87. {
  88.     if(IsPlayerConnected(playerid) && GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
  89.     {
  90.         return 1;
  91.     }
  92.     return 0;
  93. }
  94.  
  95. stock ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  96. {
  97.     if(IsPlayerConnected(playerid))
  98.     {
  99.         new Float:posx, Float:posy, Float:posz;
  100.         new Float:oldposx, Float:oldposy, Float:oldposz;
  101.         new Float:tempposx, Float:tempposy, Float:tempposz;
  102.         new invehicle[MAX_PLAYERS];
  103.         new virtualworld = GetPlayerVirtualWorld(playerid);
  104.         new interior = GetPlayerInterior(playerid);
  105.         new vehicleid = GetPlayerVehicleID(playerid);
  106.         new ivehicleid;
  107.         if(vehicleid)
  108.         {
  109.             GetVehiclePos(vehicleid,oldposx,oldposy,oldposz);
  110.         }
  111.         else
  112.         {
  113.             GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  114.             vehicleid = GetPlayerVehicleID(playerid);
  115.         }
  116.         for(new i; i<MAX_PLAYERS; i++)
  117.         {
  118.             if(IsPlayerConnected(i))
  119.             {
  120.                     if(GetPlayerVirtualWorld(i) == virtualworld)
  121.                     {
  122.                         if((GetPlayerInterior(i) == interior))
  123.                         {
  124.                             if(vehicleid)
  125.                             {
  126.                                 if(IsPlayerInVehicle(i,vehicleid))
  127.                                 {
  128.                                     invehicle[i] = 1;
  129.                                 }
  130.                             }
  131.                             if(!invehicle[i])
  132.                             {
  133.                                 if(IsPlayerInAnyVehicle(i))
  134.                                 {
  135.                                     ivehicleid = GetPlayerVehicleID(i);
  136.                                     GetVehiclePos(ivehicleid,posx,posy,posz);
  137.                                 } else {
  138.                                     GetPlayerPos(i,posx,posy,posz);
  139.                                 }
  140.                                 tempposx = (oldposx -posx);
  141.                                 tempposy = (oldposy -posy);
  142.                                 tempposz = (oldposz -posz);
  143.                                 if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  144.                                 {
  145.                                     SendClientMessage(i, col1, string);
  146.                                 }
  147.                                 else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  148.                                 {
  149.                                     SendClientMessage(i, col2, string);
  150.                                 }
  151.                                 else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  152.                                 {
  153.                                     SendClientMessage(i, col3, string);
  154.                                 }
  155.                                 else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  156.                                 {
  157.                                     SendClientMessage(i, col4, string);
  158.                                 }
  159.                                 else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  160.                                 {
  161.                                     SendClientMessage(i, col5, string);
  162.                                 }
  163.                             }
  164.                             else
  165.                             {
  166.                                 SendClientMessage(i, col1, string);
  167.                             }
  168.                         }
  169.                     }
  170.                 } else {
  171.                     SendClientMessage(i, col1, string);
  172.                 }
  173.             }
  174.     }
  175.     return 1;
  176. }
  177.  
  178. public OnFilterScriptInit()
  179. {
  180.     print("\n--------------------------------------------");
  181.     print("| Vehicle Control System - By Jack_Leslie |");
  182.     print("--------------------------------------------\n");
  183.     ManualVehicleEngineAndLights();
  184.     return 1;
  185. }
  186.  
  187. public OnFilterScriptExit()
  188. {
  189.     return 1;
  190. }
  191.  
  192. public OnPlayerStateChange(playerid, newstate, oldstate)
  193. {
  194. if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
  195.     {
  196.     new newcar = GetPlayerVehicleID(playerid);
  197.     gLastCar[playerid] = newcar;
  198.     SendClientMessage(playerid, -1, "Type /engine to start your vehicle!"); //Remove if you don't have manual control
  199.     }
  200. return 1;
  201. }
  202.  
  203. CMD:engine(playerid, params[])
  204. {
  205.     new string[128];
  206.     new sendername[MAX_PLAYER_NAME];
  207.     GetPlayerName(playerid, sendername, sizeof(sendername));
  208.     new engine,lights,alarm,doors,bonnet,boot,objective;
  209.     GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
  210.     if(!IsPlayerDriver(playerid))
  211.     {
  212.         SendClientMessage(playerid,red,"[Vehicle Control] You're not in a Vehicle with an engine!");
  213.         return 1;
  214.     }
  215.         else if(IsPlayerDriver(playerid))
  216.             {
  217.                 if(engine != 1)
  218.                 {
  219.                     engine = 1;
  220.                     SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
  221.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's engine {2F991A}on!");
  222.                     format(string, sizeof(string), "* %s puts a key into their ignition and turns on their engine.", sendername);
  223.                     ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  224.                     return 1;
  225.                 }
  226.                 else
  227.                 {
  228.                     engine = 0;
  229.                     SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
  230.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's engine {E31919}off!");
  231.                     format(string, sizeof(string), "* %s switches the key in their engine turning it off.", sendername);
  232.                     ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  233.                     return 1;
  234.                 }
  235.         }
  236.     return engine;
  237. }
  238.  
  239. /*CMD:objective(playerid, params[])
  240. {
  241.     new engine,lights,alarm,doors,bonnet,boot,objective;
  242.     GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
  243.     if(!IsPlayerDriver(playerid))
  244.     {
  245.         SendClientMessage(playerid,red,"[Vehicle Control] You're not in a Vehicle to control the lights!");
  246.         return 1;
  247.     }
  248.         else if(IsPlayerDriver(playerid))
  249.             {
  250.                 if(objective != 1)
  251.                 {
  252.                     objective = 1;
  253.                     SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,VEHICLE_PARAMS_ON);
  254.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's objective {2F991A}on!");
  255.                     return 1;
  256.                 }
  257.                 else
  258.                 {
  259.                     objective = 0;
  260.                     SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,VEHICLE_PARAMS_OFF);
  261.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's objective {E31919}off!");
  262.                     return 1;
  263.                 }
  264.         }
  265.     return objective;
  266. }*/ // Commented due to Non-RP on Roleplay Servers, feel free to un-comment if you wish to use it.
  267.  
  268. CMD:lights(playerid, params[])
  269. {
  270.     new string[128];
  271.     new sendername[MAX_PLAYER_NAME];
  272.     GetPlayerName(playerid, sendername, sizeof(sendername));
  273.     new engine,lights,alarm,doors,bonnet,boot,objective;
  274.     GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
  275.     if(!IsPlayerDriver(playerid))
  276.     {
  277.         SendClientMessage(playerid,red,"[Vehicle Control] You're not in a Vehicle to control the lights!");
  278.         return 1;
  279.     }
  280.         else if(IsPlayerDriver(playerid))
  281.             {
  282.                 if(lights != 1)
  283.                 {
  284.                     lights = 1;
  285.                     SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
  286.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's lights {2F991A}on!");
  287.                     format(string, sizeof(string), "* %s flicks a switch on the dashboard, switching on their lights.", sendername);
  288.                     ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  289.                     return 1;
  290.                 }
  291.                 else
  292.                 {
  293.                     lights = 0;
  294.                     SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
  295.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's lights {E31919}off!");
  296.                     format(string, sizeof(string), "* %s flicks a switch on the dashboard, switching off their lights.", sendername);
  297.                     ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  298.                     return 1;
  299.                 }
  300.         }
  301.     return lights;
  302. }
  303.  
  304. CMD:hood(playerid, params[])
  305. {
  306.     new string[128];
  307.     new sendername[MAX_PLAYER_NAME];
  308.     GetPlayerName(playerid, sendername, sizeof(sendername));
  309.     new engine,lights,alarm,doors,bonnet,boot,objective;
  310.     new oldcar = gLastCar[playerid];
  311.     new Float:cX, Float:cY, Float:cZ;
  312.     GetVehicleParamsEx(oldcar, engine, lights, alarm, doors, bonnet, boot, objective);
  313.     GetVehiclePos(oldcar, cX, cY, cZ);
  314.     new vehicleid = GetPlayerVehicleID(playerid);
  315.     if(!IsAPlane(vehicleid) || !IsAHelicopter(vehicleid) || !IsABike(vehicleid) || !IsATrain(vehicleid) || !IsABoat(vehicleid))
  316.     {
  317.         if(IsPlayerDriver(playerid) || IsPlayerInRangeOfPoint(playerid, 5, cX-2, cY, cZ))
  318.             {
  319.                 if(bonnet != 1)
  320.                 {
  321.                     bonnet = 1;
  322.                     SetVehicleParamsEx(oldcar,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
  323.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've opened the hood!");
  324.                     format(string, sizeof(string), "* %s opens up the hood of the car.", sendername);
  325.                     ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  326.                     return 1;
  327.                 }
  328.                 else
  329.                 {
  330.                     bonnet = 0;
  331.                     SetVehicleParamsEx(oldcar,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
  332.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've shut the hood!");
  333.                     format(string, sizeof(string), "* %s closes the hood of the car.", sendername);
  334.                     ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  335.                     return 1;
  336.                 }
  337.         }
  338.     }
  339.     return bonnet;
  340. }
  341.  
  342. CMD:trunk(playerid, params[])
  343. {
  344.     new string[128];
  345.     new sendername[MAX_PLAYER_NAME];
  346.     GetPlayerName(playerid, sendername, sizeof(sendername));
  347.     new engine,lights,alarm,doors,bonnet,boot,objective;
  348.     new oldcar = gLastCar[playerid];
  349.     new Float:cX, Float:cY, Float:cZ;
  350.     GetVehicleParamsEx(oldcar, engine, lights, alarm, doors, bonnet, boot, objective);
  351.     GetVehiclePos(oldcar, cX, cY, cZ);
  352.     new vehicleid = GetPlayerVehicleID(playerid);
  353.     if(!IsAPlane(vehicleid) || !IsAHelicopter(vehicleid) || !IsABike(vehicleid) || !IsATrain(vehicleid) || !IsABoat(vehicleid))
  354.     {
  355.         if(IsPlayerDriver(playerid) || IsPlayerInRangeOfPoint(playerid, 5, cX+2, cY, cZ))
  356.                 {
  357.                     if(boot != 1)
  358.                     {
  359.                         boot = 1;
  360.                         SetVehicleParamsEx(oldcar,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
  361.                         SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've opened the trunk!");
  362.                         format(string, sizeof(string), "* %s opens up the trunk of the car.", sendername);
  363.                         ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  364.                         return 1;
  365.                     }
  366.                     else
  367.                     {
  368.                         boot = 0;
  369.                         SetVehicleParamsEx(oldcar,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
  370.                         SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've shut the trunk!");
  371.                         format(string, sizeof(string), "* %s closes the trunk of the car.", sendername);
  372.                         ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  373.                         return 1;
  374.                     }
  375.             }
  376.         }
  377.     return boot;
  378. }
  379.  
  380. /*CMD:lockv(playerid, params[])
  381. {
  382.     new oldcar = gLastCar[playerid];
  383.     new Float:cX, Float:cY, Float:cZ;
  384.     GetVehiclePos(oldcar, cX, cY, cZ);
  385.     new string[128];
  386.     new sendername[MAX_PLAYER_NAME];
  387.     GetPlayerName(playerid, sendername, sizeof(sendername));
  388.     new engine,lights,alarm,doors,bonnet,boot,objective;
  389.     GetVehicleParamsEx(oldcar, engine, lights, alarm, doors, bonnet, boot, objective);
  390.     if(!IsPlayerInRangeOfPoint(playerid, 4, cX, cY, cZ))
  391.     {
  392.         SendClientMessage(playerid,red,"[Vehicle Control] You're not in range/in the Vehicle you last drove!");
  393.         return 1;
  394.     }
  395.         else if(IsPlayerInRangeOfPoint(playerid, 4, cX, cY, cZ))
  396.             {
  397.                 if(doors != 1)
  398.                 {
  399.                     doors = 1;
  400.                     SetVehicleParamsEx(oldcar,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
  401.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've locked the vehicle!");
  402.                     format(string, sizeof(string), "* %s locks their vehicle.", sendername);
  403.                     ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  404.                     return 1;
  405.                 }
  406.                 else
  407.                 {
  408.                     doors = 0;
  409.                     SetVehicleParamsEx(oldcar,engine,lights,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
  410.                     SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've unlocked the vehicle!");
  411.                     format(string, sizeof(string), "* %s unlocks his vehicle.", sendername);
  412.                     ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  413.                     return 1;
  414.                 }
  415.         }
  416.     return doors;
  417. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement