Potato_Tomato420 Posted August 31, 2019 Share Posted August 31, 2019 What does C stack overflow mean? I get this error when running this code: addEventHandler ("onVehicleExit", getRootElement (), function (thePlayer) if (getElementModel(source) == 596 or 523) then local passenger = getVehicleOccupant (source, 1) if passenger then removePedFromVehicle(passenger) end end end ) Link to comment
Dzsozi (h03) Posted August 31, 2019 Share Posted August 31, 2019 (edited) I think the problem is the way you are trying to get the matching model id. In my opinion this would be a much simpler solution for this problem: local vehicleModelIDs = { [596] = true, [523] = true, } addEventHandler ("onVehicleExit", getRootElement (), function (thePlayer) if vehicleModelIDs[getElementModel(source)] then local passenger = getVehicleOccupant (source, 1) if passenger then removePedFromVehicle(passenger) end end end ) This way adding and removing vehicle ids in the future will be easier. Let me know if it works or not. Edited August 31, 2019 by Dzsozi (h03) Link to comment
Moderators IIYAMA Posted September 1, 2019 Moderators Share Posted September 1, 2019 if passenger and passenger ~= thePlayer then Stack overflows are mostly happening when you created an infinity loop of function calls. A player leaves the vehicle triggering the event, which will remove a player, which will trigger the event, which will remove a player, which will trigger the event, which will remove a player, which will trigger the event, which will remove a player... Note: The player is still inside of the vehicle when the event is triggered. 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