xerox8521 Posted May 11, 2015 Share Posted May 11, 2015 So im experienting with MTA and Lua and noticed that setRadioChannel(0) didnt work for me at first so i added it in the onClientPlayerRadioSwitch event which works but causes a C Stack Overflow. addEventHandler("onClientPlayerRadioSwitch",getRootElement(),function() local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle) then if(getElementModel(vehicle) == 432) then setRadioChannel(0) cancelEvent() end end end) Edit it seems it doesnt matter which radio number you enter and it doesnt matter if you cancel the event or not Link to comment
rtx Posted May 11, 2015 Share Posted May 11, 2015 setRadioChannel may be triggering 'onClientPlayerRadioSwitch'! Actually from the looks of it, I would say it definitely triggers that event. Link to comment
Administrators 0xCiBeR Posted May 12, 2015 Administrators Share Posted May 12, 2015 In effect, it does trigger that event, so it's cycling the same function over and over causing a stack overflow. Link to comment
TAPL Posted May 12, 2015 Share Posted May 12, 2015 addEventHandler("onClientPlayerRadioSwitch", root, function() local vehicle = getPedOccupiedVehicle(localPlayer) if (vehicle) then if (getElementModel(vehicle) == 432) then if getRadioChannel() ~= 0 then setRadioChannel(0) cancelEvent() end end end end) 1 Link to comment
darhal Posted May 12, 2015 Share Posted May 12, 2015 Well stack overflow is a function that call another function which call the first function this called a trail function You should visit lua user wiki to see how to fix it ! Link to comment
Administrators 0xCiBeR Posted May 12, 2015 Administrators Share Posted May 12, 2015 addEventHandler("onClientPlayerRadioSwitch", root, function() local vehicle = getPedOccupiedVehicle(localPlayer) if (vehicle) then if (getElementModel(vehicle) == 432) then if getRadioChannel() ~= 0 then setRadioChannel(0) cancelEvent() end end end end) Should fix it perfectly. Link to comment
ixjf Posted May 14, 2015 Share Posted May 14, 2015 Well stack overflow is a function that call another function which call the first function this called a trail function You should visit lua user wiki to see how to fix it ! Not necessarily caused by infinite recursion, but in this case that's more or less it indeed. 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