Cronoss Posted January 27, 2022 Share Posted January 27, 2022 It's me again. I was testing my edited vehicle script and found a error, when the player enters in the vehicle, It's doesnt matter the chair, they can turn on the engine even if they sit down behind the driver position. I was wondering, there is a recourse that could prevent this? I mean, only execute the comand "turn on the vehicle" when player is sitting in the driver's chair Link to comment
βurak Posted January 27, 2022 Share Posted January 27, 2022 Can you show the code so we can help you? 1 Link to comment
DiSaMe Posted January 27, 2022 Share Posted January 27, 2022 You can check which seat the player occupies using getPedOccupiedVehicleSeat function. Other functions involving vehicle seats are getVehicleOccupant and getVehicleOccupants. Link to comment
Cronoss Posted January 27, 2022 Author Share Posted January 27, 2022 Here is the code I'm using -------------- addCommandHandler("motor", function(player,cmd) local acc = player:getAccount() local owner = acc:getName() local vehicle = Ped.getOccupiedVehicle(player) if vehicle then if (vehicle:getData("vehicles:owner") == owner) then setPlayerVehicleEngine(player, vehicle) else player:outputChat("No tienes las llaves de este vehículo.", 255, 0, 0) end else player:outputChat("Debes estar en un vehículo para ejecutar este comando.", 255, 0, 0) end end) function setPlayerVehicleEngine(player, vehicle) if (vehicle:getData("vehicles:engine") == 1) then vehicle:setData("vehicles:engine", 0) vehicle:setEngineState(false) player:outputChat("Apagaste el motor.", 214, 37, 37) connection:exec("UPDATE vehicles SET engine=? WHERE id=? AND owner=?", 0, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) elseif (vehicle:getData("vehicles:engine") == 0) then vehicle:setData("vehicles:engine", 1) vehicle:setEngineState(true) player:outputChat("Encendiste el motor.", 141, 229, 22) connection:exec("UPDATE vehicles SET engine=? WHERE id=? AND owner=?", 1, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) end end I want to change the "Ped.getOccupiedVehicle(player)" for "Ped.getPedOccupiedVehicleSeat" and add a condition but when I try, the resource doesn't work Link to comment
βurak Posted January 27, 2022 Share Posted January 27, 2022 addCommandHandler("motor", function(player,cmd) local acc = player:getAccount() local owner = acc:getName() local vehicle = getPedOccupiedVehicle(player) if vehicle then if(getPedOccupiedVehicleSeat(player) ~= 0) then return end if (vehicle:getData("vehicles:owner") == owner) then setPlayerVehicleEngine(player, vehicle) else player:outputChat("No tienes las llaves de este vehículo.", 255, 0, 0) end else player:outputChat("Debes estar en un vehículo para ejecutar este comando.", 255, 0, 0) end end) can you try this 1 Link to comment
Shady1 Posted January 27, 2022 Share Posted January 27, 2022 (edited) Hello @CronossI prepared a code for you according to the text you sent. Español : buen día señor getPedOccupiedVehicle addCommandHandler("motor", function(player,cmd) local acc = player:getAccount() local owner = acc:getName() local vehicle = getPedOccupiedVehicle(player) --typo,i changed this if vehicle then if(getPedOccupiedVehicleSeat(player) ~= 0) then return end if (vehicle:getData("vehicles:owner") == owner) then setPlayerVehicleEngine(player, vehicle) else player:outputChat("No tienes las llaves de este vehículo.", 255, 0, 0) end else player:outputChat("Debes estar en un vehículo para ejecutar este comando.", 255, 0, 0) end end) function setPlayerVehicleEngine(player, vehicle) if (vehicle:getData("vehicles:engine") == 1) then vehicle:setData("vehicles:engine", 0) vehicle:setEngineState(false) player:outputChat("Apagaste el motor.", 214, 37, 37) connection:exec("UPDATE vehicles SET engine=? WHERE id=? AND owner=?", 0, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) elseif (vehicle:getData("vehicles:engine") == 0) then vehicle:setData("vehicles:engine", 1) vehicle:setEngineState(true) player:outputChat("Encendiste el motor.", 141, 229, 22) connection:exec("UPDATE vehicles SET engine=? WHERE id=? AND owner=?", 1, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) end end I prefer you to look at my picture I posted here, by clicking the circle button you can place your codes in your comment in Lua assembly Edited January 27, 2022 by eoL|Shady 1 Link to comment
Cronoss Posted January 27, 2022 Author Share Posted January 27, 2022 Thank you for the help!! gracias a los dos 1 Link to comment
Shady1 Posted January 27, 2022 Share Posted January 27, 2022 @Cronoss Español : si hay un problema por favor abre un nuevo hilo sin dudarlo,te podemos ayudar. have a nice day. 1 Link to comment
giosito21 Posted May 11, 2022 Share Posted May 11, 2022 On 27/01/2022 at 12:26, Reyomin said: You can check which seat the player occupies using getPedOccupiedVehicleSeat function. Other functions involving vehicle seats are getVehicleOccupant and getVehicleOccupants. I know it's not the subject of this topic but I need to talk to you! I really admire your work on the drawtag mod. if you can send me an email beacuse i can't send you messages on forum -> [email protected] Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now