Cronoss Posted February 18, 2022 Share Posted February 18, 2022 Hello, this is a quick question (I guess), first of all, I started making this script because the previous one that I used (free script avaible in "resources") was too "hard" to understand for me, so I decided starting my own script, that way I learn and I know how my script works at the same time, (so this is NOT a repost, just in case). Now, my problem, I made a toggle engine function, it works perfectly, BUT I'm not sure if this is the right way... I'm using the "plate" of the vehicle as a "key", so the player that doesn't have the same plate text of the vehicle he is in, CAN'T toggle engine: function toggleEngine(thePlayer, cmd) local vehicle = getPedOccupiedVehicle(thePlayer) local identify = getVehiclePlateText(vehicle) local owner = getPlayerName(thePlayer) local check = exports.mysql:_Query("SELECT * FROM vehicles WHERE owner=?", owner) ---Gets the info of the player inside the vehicle (plate and engine) if (check) then if(#check > 0) then -----------else, doesn't allow the player toggle for _,column in ipairs(check) do vehicleOwned = tostring(column["plate"]) ----------Gets the plate enginestate = tonumber(column["engine"]) if (identify==vehicleOwned) then -------compares the plate of the vehicle, if it's the same, allows to toggle engine, if not, the player can't if (enginestate==1) then setVehicleEngineState(vehicle, false) enginestate = 0 iprint("B1") elseif(enginestate==0) then setVehicleEngineState(vehicle, true) enginestate = 1 iprint("B2") end local sendinfo = exports.mysql:_Query("UPDATE vehicles SET motor=? WHERE owner=?", enginestate, owner) ----sends the info ------blablabla Now, if this works perfectly as I say why I consider it's not the right way? Because I realized that the player who buys more than 1 car would generate a bug inside this function, because the plates would be the same, but at same time not the same (?) I tested it with a friend and this happened, it spams the "you don't have the keys" message ^^^^ I don't need a code, just asking if there is a better way to detect this kind of stuff, thanks for reading Link to comment
Cronoss Posted February 19, 2022 Author Share Posted February 19, 2022 [SOLVED] figured out by myself 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