Fella Posted April 3, 2015 Share Posted April 3, 2015 Hi, my problem is that a server sided script sometimes causes stack overflow and crashes my server. this happens rarely, but it does happen and i don't really understand why sometimes it happens and why most of the time it doesn't. here're the script itself: Dangerouscars = {} local isMarkerid = 1 Dangerouscars[425] = true Dangerouscars[520] = true Dangerouscars[476] = true Dangerouscars[447] = true Dangerouscars[432] = true Dangerouscars[464] = true disallowedVehicle = {[511] = true, [594] = true, [441] = true, [501] = true, [465] = true, [564] = true, [449] = true, [537] = true, [460] = true, [538] = true, [570] = true, [569] = true, [590] = true, [472] = true, [473] = true, [493] = true, [595] = true, [484] = true, [430] = true, [453] = true, [452] = true, [446] = true, [454] = true, [592] = true, [577] = true, [606] = true, [607] = true, [610] = true, [611] = true, [584] = true, [608] = true, [435] = true, [450] = true, [591] = true, [539] = true, [553] = true} function generateZufallCarID () vehicleID = math.random(399, 609) if disallowedVehicle[vehicleID] then return 451 else return vehicleID end end function mapISStarting () createMarkerToMap() end addEventHandler("onResourceStart",getResourceRootElement(),mapISStarting) function createMarkerToMap () if isMarkerid == 1 then createMarker(3883.6000976563,-1852.0999755859,139,"cylinder",5) elseif isMarkerid == 2 then createMarker(3861.8000488281,-1904.3000488281,139,"cylinder",5) elseif isMarkerid == 3 then createMarker(3800.6999511719,-1845.5999755859,139,"cylinder",5) elseif isMarkerid == 4 then createMarker(3867.5,-1798.5999755859,139,"cylinder",5) elseif isMarkerid == 5 then createMarker(3883.5,-1752.9000244141,139,"cylinder",5) elseif isMarkerid == 6 then createMarker(3946.3999023438,-1823,139,"cylinder",5) elseif isMarkerid == 7 then createMarker(3881.3000488281,-1853.5,139,"cylinder",5) elseif isMarkerid == 8 then createMarker(3869,-1919.3000488281,139,"cylinder",5) else isMarkerid = 1 createMarkerToMap() end end function onMarkerHit_S ( hit ) if getElementType(hit ) == "vehicle" then local carid = generateZufallCarID() local x, y, z = getElementPosition(hit) fixVehicle(hit) setElementModel(hit, carid) setElementPosition(hit, x, y, z + 1) if Dangerouscars[carid] then outputChatBox("#ff0000Warning #ff0000 a " .. getVehicleNameFromModel(carid), getRootElement(), 255, 0, 0, true) end destroyElement(source) isMarkerid = isMarkerid + 1 createMarkerToMap() end end addEventHandler("onMarkerHit",getRootElement(),onMarkerHit_S) here's an error message from the server's log: [2015-04-03 19:30:54] ERROR: [gamemodes]/[race]/[maps]/[dd]fivetowers-FT/fivetowers.lua:33: C stack overflow [2015-04-03 19:30:54] ERROR: [gamemodes]/[race]/[maps]/[dd]fivetowers-FT/fivetowers.lua:33: C stack overflow [2015-04-03 19:30:54] ERROR: [gamemodes]/[race]/[maps]/[dd]fivetowers-FT/fivetowers.lua:33: C stack overflow [2015-04-03 19:30:54] ERROR: [gamemodes]/[race]/[maps]/[dd]fivetowers-FT/fivetowers.lua:47: C stack overflow [2015-04-03 19:30:54] ERROR: [gamemodes]/[race]/[maps]/[dd]fivetowers-FT/fivetowers.lua:47: C stack overflow [2015-04-03 19:30:54] ERROR: [gamemodes]/[race]/[maps]/[dd]fivetowers-FT/fivetowers.lua:47: C stack overflow could you guys advice me something to solve the issue? Link to comment
TAPL Posted April 3, 2015 Share Posted April 3, 2015 You've attached the event onMarkerHit to root element which means it will get triggered for EVERY MARKERS IN YOUR SERVER. Link to comment
Fella Posted April 3, 2015 Author Share Posted April 3, 2015 i am not the author actually, i hardly can code myself. so, how to fix it? Link to comment
Fella Posted April 4, 2015 Author Share Posted April 4, 2015 bump. maybe someone knows like specific functions or something? i tried onClientMarkerHit but it didn't work at all. Link to comment
Dimos7 Posted April 5, 2015 Share Posted April 5, 2015 for server side is onMarketHit 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