rusztamas Posted May 11, 2017 Share Posted May 11, 2017 local allapot = "bekapcsolva" while allapot == "bekapcsolva" do function pajzsLekerdezes() pajzs = getElementArmor (source) if pajzs >= 1 then setElementData (source, "lehetPajzsa", true) else setElementData (source "lehetPajzsa", false) end end end pajzsobject = createObject (1242, 0, 0, 1000) function pajzsMegjelenitese() if getElementData (source, "lehetPajzsa") == true then setElementData (pajzsobject, "rogzitve", true) attachElements (pajzsobject, source) elseif getElementData (source, "lehetPajzsa") == false and getElementData (pajzsobject, "rogzitve") == true then destroyElement (pajzsobject) end end addEventHandler("", getRootElement()) I'd like to make a script, in which you have armor, an armor object would attach on you, else it would be destroyed or not shown. Aborts infinite loop? Link to comment
Moderators IIYAMA Posted May 11, 2017 Moderators Share Posted May 11, 2017 Loops are not meant to check if something has changed, they will keep running and delay all other processes until the system stops it. Loops are for processing multiple pieces of data during one action. How about you use a timer instead? (if serverside) https://wiki.multitheftauto.com/wiki/SetTimer Or 'onClientRender' (if clientside) https://wiki.multitheftauto.com/wiki/OnClientRender 1 Link to comment
rusztamas Posted May 11, 2017 Author Share Posted May 11, 2017 I have no idea how to make it with set timer. I'd rather do it on serverside, so people could see each other's armor. Link to comment
Moderators IIYAMA Posted May 11, 2017 Moderators Share Posted May 11, 2017 Why don't you start with learning how to create an infinity timer? Just create it for fun and let it say something in the chat! https://wiki.multitheftauto.com/wiki/SetTimer https://wiki.multitheftauto.com/wiki/OutputChatBox 1 Link to comment
keymetaphore Posted May 12, 2017 Share Posted May 12, 2017 6 hours ago, IIYAMA said: Why don't you start with learning how to create an infinity timer? Just create it for fun and let it say something in the chat! https://wiki.multitheftauto.com/wiki/SetTimer https://wiki.multitheftauto.com/wiki/OutputChatBox yes make sure u set it to 50ms so your server gets lagged it would be like setTimer(function() do what you wanted to do end, 250, 0) the 250 is delay, it will check that every 250ms, you probably can make it longer so that's less performance impact, and 0 means that it's infinite. 1 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