SoiiNoob Posted March 9, 2012 Share Posted March 9, 2012 local root = getRootElement() localPlayer = getLocalPlayer() local counter = 0 local starttick local currenttick function addColumns() exports.scoreboard:scoreboardAddColumn("FPS") setElementData(localPlayer,"FPS",0) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), addColumns) addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(player, "fps", counter) counter = 0 starttick = false end end ) fpstable = {} function averageFPS() avgseconds = 10 for i = 0, avgseconds do if i+1 <= avgseconds then fpstable[i+1] = fpstable[i] end fpstable[0] = getElementData(player, "fps") end totalframes = 0 for k, v in pairs(fpstable) do if v ~= false then totalframes = totalframes + v end end avgfps = math.round(totalframes / avgseconds, 0) setElementData(player, "avgfps", avgfps) end setTimer(averageFPS, 1000, 0) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end WARNING: scoreboard\fps.lua:21: Bad Argument @ 'setElementData' [Expected element at argument 1, got nil] WARNING: scoreboard\fps.lua:36: Bad Argument @ 'getElementData' [Expected element at argument 1, got nil] WARNING: scoreboard\fps.lua:45: Bad Argument @ 'setElementData' [Expected element at argument 1, got nil] Link to comment
Thelastride Posted March 9, 2012 Share Posted March 9, 2012 local root = getRootElement() localPlayer = getLocalPlayer() local counter = 0 local starttick local currenttick function addColumns() exports.scoreboard:scoreboardAddColumn("FPS") setElementData(localPlayer,"FPS",0) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), addColumns) addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(localPlayer, "fps", counter) counter = 0 starttick = false end end ) fpstable = {} function averageFPS() avgseconds = 10 for i = 0, avgseconds do if i+1 <= avgseconds then fpstable[i+1] = fpstable[i] end fpstable[0] = getElementData(localPlayer, "fps") end totalframes = 0 for k, v in pairs(fpstable) do if v ~= false then totalframes = totalframes + v end end avgfps = math.round(totalframes / avgseconds, 0) setElementData(localPlayer, "avgfps", avgfps) end setTimer(averageFPS, 1000, 0) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end player was nothing. Link to comment
X-SHADOW Posted March 9, 2012 Share Posted March 9, 2012 --serverSide---- exports.scoreboard:scoreboardAddColumn("FPS") ----clientSide---- local root = getRootElement() localPlayer = getLocalPlayer() local counter = 0 local starttick local currenttick addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(localPlayer, "FPS", counter) counter = 0 starttick = false end end ) fpstable = {} function averageFPS() avgseconds = 10 for i = 0, avgseconds do if i+1 <= avgseconds then fpstable[i+1] = fpstable[i] end fpstable[0] = getElementData(localPlayer, "FPS") end totalframes = 0 for k, v in pairs(fpstable) do if v ~= false then totalframes = totalframes + v end end avgfps = math.round(totalframes / avgseconds, 0) setElementData(localPlayer, "avgfps", avgfps) end setTimer(averageFPS, 1000, 0) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end Link to comment
SoiiNoob Posted March 10, 2012 Author Share Posted March 10, 2012 It works a little , it says ever 38 or 39 fps, but i get an error meta.xml <script src="fps_c.lua" type="client" /> <script src="fps_s.lua" type="server" /> fps_c.lua local root = getRootElement() localPlayer = getLocalPlayer() local counter = 0 local starttick local currenttick addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(localPlayer, "FPS", counter) counter = 0 starttick = false end end ) fpstable = {} function averageFPS() avgseconds = 10 for i = 0, avgseconds do if i+1 <= avgseconds then fpstable[i+1] = fpstable[i] end fpstable[0] = getElementData(localPlayer, "FPS") end totalframes = 0 for k, v in pairs(fpstable) do if v ~= false then totalframes = totalframes + v end end avgfps = math.round(totalframes / avgseconds, 0) setElementData(localPlayer, "avgfps", avgfps) end setTimer(averageFPS, 1000, 0) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end fps_s.lua exports.scoreboard:scoreboardAddColumn("FPS") ------------------------------------------------------------------- ERROR: Server triggered clientside event doScoreboardRemoveColumn, but event is not added clientside ERROR: Server triggered clientside event doScoreboardRemoveColumn, but event is not added clientside ERROR: Server triggered clientside event doScoreboardAddColumn, but event is not added clientside ERROR: Server triggered clientside event doScoreboardAddColumn, but event is not added clientside WARNING: scoreboard\colorpicker\colorpicker.lua:58: Bad argument @ 'guiGetSize' [Expected gui-element at argument 1, got nil] Link to comment
Deagle Posted March 10, 2012 Share Posted March 10, 2012 Why are you losing time with fixing this script when you can download this one ? : https://community.multitheftauto.com/index.php?p= ... ils&id=450 Link to comment
GanJaRuleZ Posted March 10, 2012 Share Posted March 10, 2012 That is not for your resource... It's from the scoreboard one , i recommend you to download the dxscoreboard that you can find it here : https://community.multitheftauto.com/index.php?p=resources&s=details&id=419 Link to comment
SoiiNoob Posted March 11, 2012 Author Share Posted March 11, 2012 it still not working Link to comment
Deagle Posted March 11, 2012 Share Posted March 11, 2012 Have you seen my reply ? Have you downloaded this one ? https://community.multitheftauto.com/index.php?p= ... ils&id=450 It works 100%, everyone is using that one. Link to comment
GanJaRuleZ Posted March 11, 2012 Share Posted March 11, 2012 Maybe he wants to make his own ? Maybe he doesn't wants to copy.. @SoiiNoob , do /debugscript 3 Link to comment
Feche1320 Posted March 11, 2012 Share Posted March 11, 2012 local root = getRootElement() local Player = getLocalPlayer() local counter = 0 local starttick local currenttick function addColumns() exports.scoreboard:scoreboardAddColumn("FPS") setElementData(Player,"FPS",0) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), addColumns) addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(Player, "fps", counter) counter = 0 starttick = false end end ) fpstable = {} function averageFPS() avgseconds = 10 for i = 0, avgseconds do if i+1 <= avgseconds then fpstable[i+1] = fpstable[i] end fpstable[0] = getElementData(Player, "fps") end totalframes = 0 for k, v in pairs">pairs(fpstable) do if v ~= false then totalframes = totalframes + v end end avgfps = math.round(totalframes / avgseconds, 0) setElementData(Player, "avgfps", avgfps) end setTimer(averageFPS, 1000, 0) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber">tonumber(("%."..decimals.."f"):format(number)) end end Link to comment
drk Posted March 11, 2012 Share Posted March 11, 2012 As far as I know, the function to add a column to scoreboard is addScoreboardColumn not scoreboardAddColumn. Link to comment
SoiiNoob Posted March 11, 2012 Author Share Posted March 11, 2012 Have you seen my reply ? Have you downloaded this one ?https://community.multitheftauto.com/index.php?p= ... ils&id=450 It works 100%, everyone is using that one. ERROR: Server triggered clientside event doScoreboardRemoveColumn, but event is not added clientside ERROR: Server triggered clientside event doScoreboardAddColumn, but event is not added clientside Really I have 52 FPS and it show 38 fps in another server Link to comment
Deagle Posted March 11, 2012 Share Posted March 11, 2012 Of course that you have 38 fps if you haven't raised the fps limit of your server. Link to comment
SoiiNoob Posted March 12, 2012 Author Share Posted March 12, 2012 and how can i do that? Link to comment
Deagle Posted March 12, 2012 Share Posted March 12, 2012 Search for mtaserver.conf, there you will have a line 36. ( max. 100fps ) Link to comment
drk Posted March 12, 2012 Share Posted March 12, 2012 Open your mtaserver.conf and search for and set the limit. Link to comment
Moderators IIYAMA Posted March 12, 2012 Moderators Share Posted March 12, 2012 First shutdown your server. Go to mta folder>server>mods>deathmatch open with notepath> mtaserver.conf Do ctrl + f and look for "fpslimit" or just find the word fpslimit. Between here: (normally 36) You better change this to max 45/50. If you go high there will be some strange bugs. (100 fps = you can't walk with m4, if you is able to make that 100 fps.) Then start your server again. 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