Turbe$Z Posted March 1, 2017 Share Posted March 1, 2017 i want to add afk check to my nametag, but i dont know how i tried this, but doesn't working --server function checkAFKPlayers() for index, thePlayer in ipairs(getElementsByType("player")) do if (getPlayerIdleTime(thePlayer) > 300000) then AFKCheck = "AFK" end end end setTimer(checkAFKPlayers, 30000, 0) --client (only the two line) local AFKCheck = {} dxDrawColorText ("#00BAFF" .. getPlayerName(player) .. " (" .. AFKState .. ")", sx-w, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), player ~= g_Me and textscale*NAMETAG_TEXTSIZE or (textscale*NAMETAG_TEXTSIZE)/1.5, srfont, "center", "bottom", false, false, false ) how to make this working? /sorry for my bad english:c/ Link to comment
NeXuS™ Posted March 1, 2017 Share Posted March 1, 2017 I think you should do a custom made idle timer, and not the in-built function for it. Link to comment
Turbe$Z Posted March 1, 2017 Author Share Posted March 1, 2017 17 minutes ago, Patrik91 said: I think you should do a custom made idle timer, and not the in-built function for it. How? Link to comment
NeXuS™ Posted March 1, 2017 Share Posted March 1, 2017 Do it on client-side, so it doesn't effect your server at all. local nextCheckTime = 10000 local oX, oY, oZ = nil, nil, nil function isAFK() local pX, pY, pZ = getElementPosition(localPlayer) if oX then if pX == oX and pY == oY and pZ == oZ then setElementData(localPlayer, "isAFK", true) elseif getElementData(localPlayer, "isAFK") then setElementData(localPlayer, "isAFK", false) end end oX, oY, oZ = pX, pY, pZ end setTimer(isAFK, nextCheckTime, 0) Now you just have to add the clientRender to do the drawings for everyone. 1 Link to comment
Turbe$Z Posted March 1, 2017 Author Share Posted March 1, 2017 4 minutes ago, Patrik91 said: Do it on client-side, so it doesn't effect your server at all. local nextCheckTime = 10000 local oX, oY, oZ = nil, nil, nil function isAFK() local pX, pY, pZ = getElementPosition(localPlayer) if oX then if pX == oX and pY == oY and pZ == oZ then setElementData(localPlayer, "isAFK", true) elseif getElementData(localPlayer, "isAFK") then setElementData(localPlayer, "isAFK", false) end end oX, oY, oZ = pX, pY, pZ end setTimer(isAFK, nextCheckTime, 0) Now you just have to add the clientRender to do the drawings for everyone. i added dxDrawColorText ("#00BAFF" .. getPlayerName(player) .. " (" .. isAFK .. ")", sx-w, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), player ~= g_Me and textscale*NAMETAG_TEXTSIZE or (textscale*NAMETAG_TEXTSIZE)/1.5, srfont, "center", "bottom", false, false, false ) but i got this error: attempt to concatenate global 'isAFK' a function value 1 Link to comment
Turbe$Z Posted March 1, 2017 Author Share Posted March 1, 2017 1 minute ago, Patrik91 said: Do you have a nametag system? Yes Link to comment
NeXuS™ Posted March 1, 2017 Share Posted March 1, 2017 Can you send me a 10 line look into from before? dxDrawColorText ("#00BAFF" .. getPlayerName(player) .. " (" .. isAFK .. ")", sx-w, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), player ~= g_Me and textscale*NAMETAG_TEXTSIZE or (textscale*NAMETAG_TEXTSIZE)/1.5, srfont, "center", "bottom", false, false, false ) Link to comment
Mr.Loki Posted March 1, 2017 Share Posted March 1, 2017 Try this: local state = getElementData(player,"isAFK") and "AFK" or "Active" dxDrawColorText ("#00BAFF" .. getPlayerName(player) .. " (" .. state .. ")", sx-w, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), player ~= g_Me and textscale*NAMETAG_TEXTSIZE or (textscale*NAMETAG_TEXTSIZE)/1.5, srfont, "center", "bottom", false, false, false ) 1 Link to comment
Turbe$Z Posted March 1, 2017 Author Share Posted March 1, 2017 3 minutes ago, Mr.Loki said: Try this: local state = getElementData(player,"isAFK") and "AFK" or "Active" dxDrawColorText ("#00BAFF" .. getPlayerName(player) .. " (" .. state .. ")", sx-w, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), player ~= g_Me and textscale*NAMETAG_TEXTSIZE or (textscale*NAMETAG_TEXTSIZE)/1.5, srfont, "center", "bottom", false, false, false ) Thanks 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