nimzahed Posted January 2, 2021 Posted January 2, 2021 Hi to all friends I have a problem is that if the character is not in the fraction, it will still enter the car and cancelEvent() does not work Quote Hi to all friends I have a problem is that if the character is not in the fraction, it will still enter the car and cancelEvent() does not work function enterpdVehicle ( player, seat, jacked ) local username = getPlayerName(player) if seat == 0 then if jacked then local theVehicle = getPedOccupiedVehicle (jacked) if theVehicle then local vehid = getElementID ( theVehicle ) dbQuery(function(qh) local result = dbPoll(qh,0); if #result > 0 then for k,v in pairs(result) do if (v.isactive == 0) then local pelak = getVehiclePlateText(theVehicle):gsub("-fac","") dbQuery(function(qhs) local res = dbPoll(qhs,0); if #res > 0 then for k,x in pairs(res) do dbQuery(function(qhss) local rese = dbPoll(qhss,0); if #rese > 0 then for k,n in pairs(rese) do if (n.factionid == x.factionid) then else cancelEvent() end end end end,db,"SELECT * FROM users WHERE username=?",username) end end end,db,"SELECT * FROM factioncars WHERE vfid=?",pelak) end end end end,db,"SELECT * FROM factioncars WHERE isactive=?",0) end else local theVehicle = getPedOccupiedVehicle (player) if theVehicle then local vehid = getElementID ( theVehicle ) dbQuery(function(qh) local result = dbPoll(qh,0); if #result > 0 then for k,v in pairs(result) do if (v.isactive == 0) then local pelak = getVehiclePlateText(theVehicle):gsub("-fac","") dbQuery(function(qhs) local res = dbPoll(qhs,0); if #res > 0 then for k,x in pairs(res) do dbQuery(function(qhss) local rese = dbPoll(qhss,0); if #rese > 0 then for k,n in pairs(rese) do if (n.factionid == x.factionid) then else cancelEvent() end end end end,db,"SELECT * FROM users WHERE username=?",username) end end end,db,"SELECT * FROM factioncars WHERE vfid=?",pelak) end end end end,db,"SELECT * FROM factioncars WHERE isactive=?",0) end end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterpdVehicle ) I know it's written very badly. For bad English, if there's a problem, I'm sorry.
Moderators Patrick Posted January 2, 2021 Moderators Posted January 2, 2021 (edited) Quote I know it's written very badly. Yes, this is terribly bad. But you can't cancel the event inside dbQuery's callback because it is a different function, you can cancel in the original enterpdVehicle function only. Edited January 2, 2021 by Patrick
nimzahed Posted January 2, 2021 Author Posted January 2, 2021 (edited) 4 hours ago, Patrick said: Yes, this is terribly bad. But you can't cancel the event inside dbQuery's callback because it is a different function, you can cancel in the original enterpdVehicle function only. can you give me a healthy code . Code performance is like my code. Edited January 2, 2021 by nimzahed
nimzahed Posted January 3, 2021 Author Posted January 3, 2021 13 hours ago, nimzahed said: can you give me a healthy code . Code performance is like my code. Thanks for saying you can not cancelvent it, but I did not know there was another way to select and I looked for it and realized how wrong I was and rebuilt all my code
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