roaddog Posted August 10, 2014 Posted August 10, 2014 Heya, so why if i run this script, server will be frozen and shutting down automaticly ? exports [ "scoreboard" ]:addScoreboardColumn ( "Gang",getRootElement() ,40,80, "Gang" ) function getgang() local group = exports.groupsystem:getPlayerGroup(source) if group then ---outputChatBox(group) setElementData(source, "Gang", group) end setTimer ( getgang, 2500, 0 ) end addCommandHandler("gang", getgang) addEventHandler( "onPlayerLogin", getRootElement(), getgang ) You gone learn today. I work my ass off, but I still can't pay tho.
xXMADEXx Posted August 10, 2014 Posted August 10, 2014 There's nothing that I see in the script that would cause the server to lag (unless it's the getPlayerGroup function), but the timer on line 9 is totally pointless, you should remove it. The Ultimate Lua Tutorial! | MTA PHP SDK
Et-win Posted August 10, 2014 Posted August 10, 2014 Why is the setTimer pointless? The element data doesn't refresh on his own mhm... ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Mr_Moose Posted August 10, 2014 Posted August 10, 2014 You're getting a stack overflow there. The timer will do it's work forever due to argument three which you set to '0' and each time the function is called you're starting a new timer that continues forever, the result is an infinite amount of timers that spam this function. Most compilers or frameworks has protection against this, i.e know already from the start that everything will fail, the shutdown is a security process to prevent more serious issues like a full system crash like BSOD on Windows. MTA Community | GitHub | 99Stack Forum
xXMADEXx Posted August 10, 2014 Posted August 10, 2014 Why is the setTimer pointless? The element data doesn't refresh on his own mhm... There wouldn't be a source. Not only that but everytime the function is called it makes a new timer therefore there could be like 1000 timers -> Lag The Ultimate Lua Tutorial! | MTA PHP SDK
Et-win Posted August 10, 2014 Posted August 10, 2014 Oops, didn't see that both things ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
roaddog Posted August 10, 2014 Author Posted August 10, 2014 OMG, Thank you guys your info has saved my life. I didn't know 'bout stack overflow, useful info. You gone learn today. I work my ass off, but I still can't pay tho.
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