K4stic Posted March 22, 2013 Posted March 22, 2013 Problem then i type /myfps it show then i again type /myfps it's hide it but if i again type /myfps then is not show it me again No Error's in Debugscript local FPSLimit = 100 local FPSMax = 1 function onClientResourceStart ( resource ) if ( guiFPSLabel == nil ) then FPSLimit = 255 / FPSLimit guiFPSLabel = guiCreateLabel ( 0.03, 0.97, 0.1, 0.1, "FPS: 0", true ) FPSCalc = 0 FPSTime = getTickCount() + 1000 addEventHandler ( "onClientRender", root, onClientRender ) else guiSetText ( guiFPSLabel, nil ) end end addCommandHandler("myfps", onClientResourceStart) function onClientRender ( ) if ( getTickCount() < FPSTime ) then FPSCalc = FPSCalc + 1 else if ( FPSCalc > FPSMax ) then FPSLimit = 255 / FPSCalc FPSMax = FPSCalc end guiSetText ( guiFPSLabel, "FPS: "..FPSCalc.." Max: "..FPSMax ) guiLabelSetColor ( guiFPSLabel, 255 - math.ceil ( FPSCalc * FPSLimit ), math.ceil ( FPSCalc * FPSLimit ), 0 ) FPSCalc = 0 FPSTime = getTickCount() + 1000 end end Giving a Fuck? Nope, That isn't in My Skill Set
Moderators IIYAMA Posted March 22, 2013 Moderators Posted March 22, 2013 (edited) function onClientResourceStart ( resource ) if ( guiFPSLabel == nil ) then FPSLimit = 255 / FPSLimit guiFPSLabel = guiCreateLabel ( 0.03, 0.97, 0.1, 0.1, "FPS: 0", true ) FPSCalc = 0 FPSTime = getTickCount() + 1000 addEventHandler ( "onClientRender", root, onClientRender ) else guiSetText ( guiFPSLabel, nil ) destroyElement(guiFPSLabel) guiFPSLabel = nil --? removeEventHandler ( "onClientRender", root, onClientRender ) -- you have to remove it before you can handle it again. end end addCommandHandler("myfps", onClientResourceStart) Edited March 22, 2013 by Guest Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
K4stic Posted March 22, 2013 Author Posted March 22, 2013 same problem Giving a Fuck? Nope, That isn't in My Skill Set
Moderators IIYAMA Posted March 22, 2013 Moderators Posted March 22, 2013 I don't see the error or what might go wrong. Probably something in the calculation. You should start debug your script. outputDebugString() Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
K4stic Posted March 22, 2013 Author Posted March 22, 2013 explain more pls Giving a Fuck? Nope, That isn't in My Skill Set
K4stic Posted March 22, 2013 Author Posted March 22, 2013 someone help me pls Giving a Fuck? Nope, That isn't in My Skill Set
Moderators IIYAMA Posted March 22, 2013 Moderators Posted March 22, 2013 1: login as admin 2: /debugscript 3 local A = 1 if A == 1 then outputDebugString ("A is 1") else outputDebugString ("A isn't 1") end This kind of string has been designed to output information, so your chat won't be spammed with debug information. This is how I check my scripts when they don't work and I can't find the problem. A == 1000 if A > 10 then outputDebugString ("A is higher then 10") if A > 100 then outputDebugString ("A is higher then 100") if A > 300 then outputDebugString ("A is higher then 300") if A > 1000 then outputDebugString ("A is higher then 1000") end end end end outputDebugString ("A is this value:" .. A ) -- check how big a value is. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
K4stic Posted March 22, 2013 Author Posted March 22, 2013 ok now work but it's output me to debugscript that line 14:RemoveEventHandler(a nil value) local FPSLimit = 100 local FPSMax = 1 function onClientResourceStart ( resource ) if ( guiFPSLabel == nil ) then FPSLimit = 255 / FPSLimit guiFPSLabel = guiCreateLabel ( 0.03, 0.97, 0.1, 0.1, "FPS: 0", true ) FPSCalc = 0 FPSTime = getTickCount() + 1000 addEventHandler ( "onClientRender", root, onClientRender ) else guiSetText ( guiFPSLabel, "" ) destroyElement(guiFPSLabel) RemoveEventHandler ( "onClientRender", root, onClientRender ) end end addCommandHandler("myfps", onClientResourceStart) function onClientRender ( ) if ( getTickCount() < FPSTime ) then FPSCalc = FPSCalc + 1 else if ( FPSCalc > FPSMax ) then FPSLimit = 255 / FPSCalc FPSMax = FPSCalc end guiSetText ( guiFPSLabel, "FPS: "..FPSCalc.." Max: "..FPSMax ) guiLabelSetColor ( guiFPSLabel, 255 - math.ceil ( FPSCalc * FPSLimit ), math.ceil ( FPSCalc * FPSLimit ), 0 ) FPSCalc = 0 FPSTime = getTickCount() + 1000 end end Giving a Fuck? Nope, That isn't in My Skill Set
Moderators IIYAMA Posted March 22, 2013 Moderators Posted March 22, 2013 whops sorry, removeEventHandler ( "onClientRender", root, onClientRender ) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
K4stic Posted March 22, 2013 Author Posted March 22, 2013 LOL IIYAMA but on 3rd type /myfps is not show me fps Giving a Fuck? Nope, That isn't in My Skill Set
Moderators IIYAMA Posted March 22, 2013 Moderators Posted March 22, 2013 as I said I don't know what is wrong with it, I can't test it at the moment... Tell me what the string out puts by the 3e time. local FPSLimit = 100 local FPSMax = 1 addCommandHandler("myfps", function ( ) if not guiFPSLabel then FPSLimit = 255 / FPSLimit guiFPSLabel = guiCreateLabel ( 0.03, 0.97, 0.1, 0.1, "FPS: 0", true ) FPSCalc = 0 FPSTime = getTickCount() + 1000 addEventHandler ( "onClientRender", root, onClientRender ) outputDebugString ("label created") else guiSetText ( guiFPSLabel, "" ) destroyElement(guiFPSLabel) guiFPSLabel = nil removeEventHandler ( "onClientRender", root, onClientRender ) outputDebugString ("label destroyed") end end) function onClientRender ( ) if ( getTickCount() < FPSTime ) then FPSCalc = FPSCalc + 1 else if ( FPSCalc > FPSMax ) then FPSLimit = 255 / FPSCalc FPSMax = FPSCalc end guiSetText ( guiFPSLabel, "FPS: "..FPSCalc.." Max: "..FPSMax ) guiLabelSetColor ( guiFPSLabel, 255 - math.ceil ( FPSCalc * FPSLimit ), math.ceil ( FPSCalc * FPSLimit ), 0 ) FPSCalc = 0 FPSTime = getTickCount() + 1000 end end Updated at 14:25. (germany/Netherlands timezone) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
K4stic Posted March 22, 2013 Author Posted March 22, 2013 now all work perfect thanks i only must be add guiFPSLabel = nil Giving a Fuck? Nope, That isn't in My Skill Set
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