DouglaS666 Posted June 5, 2018 Share Posted June 5, 2018 local ping = getPlayerPing(getLocalPlayer()) local x, y = guiGetScreenSize ( ) r,g,b=0,0,0 alpha=150 local root = getRootElement() local player = 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(player,"FPS",counter) counter = 0 starttick = false end end ) function drawStates () addEventHandler ( "onClientRender", root, pingState ) addEventHandler ( "onClientRender", root, fpsState ) end addEventHandler ( "onClientResourceStart", resourceRoot, drawStates ) function pingState() posx= x-30 posy= 20 dxDrawRectangle ( posx, posy, 4, 4, tocolor ( r, g, b, alpha ) ) dxDrawRectangle ( posx+5, posy-4, 4,8, tocolor ( r, g, b, alpha ) ) dxDrawRectangle ( posx+10, posy-8, 4,12, tocolor ( r, g, b, alpha ) ) dxDrawRectangle ( posx+15, posy-12, 4,16, tocolor ( r, g, b, alpha ) ) dxDrawRectangle ( posx+20, posy-16, 4,20, tocolor ( r, g, b, alpha ) ) r2,g2,b2=255,255,255 alpha2=255 if ping <= 180 then dxDrawRectangle ( posx, posy, 4, 4, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+5, posy-4, 4,8, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+10, posy-8, 4,12, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+15, posy-12, 4,16, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+20, posy-16, 4,20, tocolor ( r2, g2, b2, alpha2 ) ) elseif ping >=101 and ping <= 200 then dxDrawRectangle ( posx, posy, 4, 4, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+5, posy-4, 4,8, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+10, posy-8, 4,12, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+15, posy-12, 4,16, tocolor ( r2, g2, b2, alpha2 ) ) elseif ping >=201 and ping <= 300 then dxDrawRectangle ( posx, posy, 4, 4, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+5, posy-4, 4,8, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+10, posy-8, 4,12, tocolor ( r2, g2, b2, alpha2 ) ) elseif ping >=301 and ping <= 400 then dxDrawRectangle ( posx, posy, 4, 4, tocolor ( r2, g2, b2, alpha2 ) ) dxDrawRectangle ( posx+5, posy-4, 4,8, tocolor ( r2, g2, b2, alpha2 ) ) elseif ping >=401 and ping <= 500 then dxDrawRectangle ( posx, posy, 4, 4, tocolor ( r2, g2, b2, alpha2 ) ) end end function fpsState() posx2= x-55 posy2= 13 dxDrawText ( getElementData(getLocalPlayer(),"FPS"), posx2-12, posy2-6, x, y, tocolor ( 255, 255, 255, 255 ), 1.4, "default-bold" ) dxDrawText ( "FPS", posx2-13, posy2+10, x, y, tocolor ( 255, 255, 255, 255 ), 1.0, "default-bold" ) dxDrawText ( "PING", posx2+23, posy2+10, x, y, tocolor ( 255, 255, 255, 255 ), 1.0, "default-bold" ) end Link to comment
Other Languages Moderators Lord Henry Posted June 5, 2018 Other Languages Moderators Share Posted June 5, 2018 (edited) Não coloque títulos muito grandes no seu post. Seja breve com uma pequena frase. No texto do post dai vc explica com mais detalhes o seu problema. Se continuar postando os tópicos dessa forma, irei ignorar da próxima vez. ------------------------------ Na linha 87. Sempre vai gerar erro se o jogador não tiver a data "FPS". Use um tostring ( ) antes para converter o valor booleano em string. dxDrawText (tostring (getElementData(getLocalPlayer(),"FPS")), posx2-12, posy2-6, x, y, tocolor ( 255, 255, 255, 255 ), 1.4, "default-bold") Você não deveria armazenar o FPS nem o PING como playerData, pois são valores que se alteram a cada frame. Sua performance será prejudicada se ficar usando setElementData e getElementData a cada frame. Em vez disso, use getCurrentFPS e getPlayerPing, armazene-os em variáveis locais e use no dxDrawText, usando sempre um tostring para caso os valores sejam false. Edited June 5, 2018 by Lord Henry 1 Link to comment
DouglaS666 Posted June 5, 2018 Author Share Posted June 5, 2018 Agora o erro está no server.lua. Não entendo nada de script! Agradecendo toda compreensão desde Já. PingFps\server.lua:3: Bad argument @ 'call' [Expected resource-data at argument 1, got boolean] addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() call(getResourceFromName(""),"addScoreboardColumn","FPS") end ) Link to comment
Other Languages Moderators Lord Henry Posted June 6, 2018 Other Languages Moderators Share Posted June 6, 2018 (edited) Estude lógica de programação no YouTube. Você precisa saber lógica de programação para entender algo de programação. Entre aquelas aspas vazias ali (" "), coloque scoreboard, assim: call(getResourceFromName("scoreboard"),"addScoreboardColumn","FPS") Edited June 6, 2018 by Lord Henry 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