[MTA]Weed Posted October 1, 2017 Share Posted October 1, 2017 (edited) Can someone kinda help me im having little trouble, my nametags its edited version or runes of magic nametag, its making clientside cpu leak when more players are in server. i tryed removing almost everything, the emblems, the tags, the team, font everything and its still the same. Clientside code below: strings = { { "_", " " }, { "-", " " }, { "^%[[%w@]+%]", " " }, { "^%a+|", " " }, { "|.+$", " " }, { "1", "" }, { "2", "" }, { "3", "" }, { "4", "" }, { "5", "" }, { "6", "" }, { "7", "" }, { "8", "" }, { "9", "" }, { "0", "" }, } myfont = dxCreateFont("DFHEIMDU_id.ttf",10) nametags_Root = getRootElement() nametags_ResRoot = getResourceRootElement(getThisResource()) nametags_Players = getElementsByType('player') nametags_Me = getLocalPlayer() nametag = {} local nametags = {} local sWidth,sHeight = guiGetScreenSize() local Nametags_Hide = false local Nametags_Scale = 0.3 local Nametags_Alpha_Distance = 30 local Nametags_Distance = 40 local Nametags_Alpha = 255 local Nametags_Text_Bar_Space = 3 local Nametags_Width = 30 local Nametags_Height = 20 local Nametags_Size = 0.3 local Nametags_Outline_Thickness = 2.4 local Nametags_Alpha_Diff = Nametags_Distance - Nametags_Alpha_Distance Nametags_Scale = 1/Nametags_Scale * 800 / sHeight local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } function nametags.Create ( player ) nametags[player] = true end function nametags.Destroy ( player ) nametags[player] = nil end addEventHandler ( "onClientRender", nametags_Root, function() if getElementData(getLocalPlayer(), "state.hud") == "disabled" then return end for i,player in ipairs(nametags_Players) do if isElement(player) then setPlayerNametagShowing ( player, false ) if not nametags[player] then nametags.Create ( player ) end end end if Nametags_Hide then return end local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(nametags_Me) then break end local px,py,pz = getElementPosition ( player ) local bx, by, bz = getPedBonePosition( player, 5 ) if processLineOfSight(x, y, z, px, py, pz, true, false, false, true, false, true) then break end local playerDistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if playerDistance <= Nametags_Distance then --Get screen position --local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) local sx,sy = getScreenFromWorldPosition( bx + 0, by, bz + 0.4 ) if not sx or not sy then break end --Calculate our components local scale = 1/(Nametags_Scale * (playerDistance / Nametags_Distance)) local alpha = ((playerDistance - Nametags_Alpha_Distance) / Nametags_Alpha_Diff) alpha = (alpha < 0) and Nametags_Alpha or Nametags_Alpha-(alpha*Nametags_Alpha) scale = math.evalCurve(maxScaleCurve,scale) local textScale = math.evalCurve(textScaleCurve,scale) local textAlpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = Nametags_Outline_Thickness*(scale) --Requirements local team = getPlayerTeam(player) local level = getElementData(player, "LV") or 0 local class = getElementData(player, "class") local r,g,b = getPlayerNametagColor(player) local offset = (scale) * Nametags_Text_Bar_Space/2 local playerName = getPlayerName(player) for k,v in ipairs (strings) do if string.find( string.lower ( playerName ),v[1]) then playerName = playerName:gsub ( v[1], v[2] ) end end local imageSize = dxGetFontHeight ( textScale*Nametags_Size, myfont ) local lp = getElementData(player, "experience.rank") or "Newbie" --Draw our text --dxDrawText ( playerName, sx, sy - offset, sx, sy - offset, tocolor(0,0,0,255), textScale*Nametags_Size, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText ( playerName.."("..level..")", sx, sy - offset + 4*scale, sx, sy - offset + 4*scale, tocolor(0,0,0,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText ( playerName.."("..level..")", sx, sy - offset + 4*scale, sx, sy - offset + 4*scale, tocolor(r,g,b,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) nameWidth = dxGetTextWidth ( playerName.."("..level..")", textScale*Nametags_Size, myfont ) teamWidth = nameWidth if team then dxDrawText (" ["..getTeamName(team).."] ", sx, sy - offset + 8*scale, sx, sy - offset + 8*scale, tocolor(0,0,0,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText (" ["..getTeamName(team).."] ", sx, sy - offset + 8*scale, sx, sy - offset + 8*scale, tocolor(r,g,b,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) teamWidth = dxGetTextWidth (" ["..getTeamName(team).."] ", textScale*Nametags_Size*0.75, myfont ) end if getElementData(player, "class") then dxDrawText (tostring(class), sx, sy - offset - 0*scale, sx, sy - offset - 0*scale, tocolor(0,0,0,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText (tostring(class), sx, sy - offset - 0*scale, sx, sy - offset - 0*scale, tocolor(r,g,b,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) typingWidth = dxGetTextWidth (tostring(class), textScale*Nametags_Size*0.75, myfont ) end if class and team then dxDrawImage ( sx + math.max(nameWidth/2, teamWidth/2) + 1*scale, sy - math.max(teamWidth/6), imageSize, imageSize, ":Nametag/class/"..class..".png" ) elseif class and not team then dxDrawImage ( sx + math.max(nameWidth/2) + 1*scale, sy - math.max(nameWidth/10), imageSize, imageSize, ":Nametag/class/"..class..".png" ) end if getElementData(player, "play.nodm") == true then dxDrawImage ( sx - math.max(nameWidth/2, teamWidth/2) - 7*scale, sy - imageSize, imageSize, imageSize, ":Nametag/class/friendly.png" ) else dxDrawImage ( sx - math.max(nameWidth/2, teamWidth/2) - 7*scale, sy - imageSize, imageSize, imageSize, ":Experience/Emblems/"..lp..".png" ) end end break end end end ) function nametagsCreate() for i,player in ipairs(getElementsByType"player") do nametags.Create ( player ) end end addEventHandler('onClientResourceStart', nametags_Root, nametagsCreate) function nametagsCreateOnJoin() if source == nametags_Me then return end setPlayerNametagShowing ( source, false ) nametags.Create ( source ) end addEventHandler('onClientPlayerJoin', nametags_Root, nametagsCreateOnJoin) function nametagsDestroy() nametags.Destroy ( source ) end addEventHandler('onClientPlayerQuit', nametags_Root, nametagsDestroy) function math.lerp(from,to,alpha) return from + (to-from) * alpha end function math.evalCurve( curve, input ) if input<curve[1][1] then return curve[1][2] end for idx=2,#curve do if input<curve[idx][1] then local x1 = curve[idx-1][1] local y1 = curve[idx-1][2] local x2 = curve[idx][1] local y2 = curve[idx][2] local alpha = (input - x1)/(x2 - x1); return math.lerp(y1,y2,alpha) end end return curve[#curve][2] end function fixSomeLoops() if (getElementData(source, "player.key") == "") or (getElementData(source, "player.key") == "") or (getElementData(source, "player.key") == "") then cancelEvent() end end addEventHandler("onClientPlayerDamage", getRootElement(), fixSomeLoops) addEventHandler("onPlayerStealthKill", getRootElement(), fixSomeLoops) Edited October 1, 2017 by [MTA]Weed Link to comment
Moderators IIYAMA Posted October 2, 2017 Moderators Share Posted October 2, 2017 Cpu leak? Don't you mean memory leak or high cpu usage? Performance speed can be tested with:(processing Speed>CPU) getTickCount() Memory leak can be checked with: http://luatut.com/collectgarbage.html Link to comment
[MTA]Weed Posted October 2, 2017 Author Share Posted October 2, 2017 (edited) its causing player fps drop high cpu usage client side, from server side there is no problem processor working normaly. https://imgur.com/a/oe1oD Edited October 2, 2017 by [MTA]Weed adding image Link to comment
Moderators IIYAMA Posted October 2, 2017 Moderators Share Posted October 2, 2017 Did you checked the images? (they can be very laggy if they are drawn from files + being large) Link to comment
[MTA]Weed Posted October 2, 2017 Author Share Posted October 2, 2017 i removed the images, the ranks, team, player name, font i removed almost everything and its still same. Link to comment
Moderators IIYAMA Posted October 2, 2017 Moderators Share Posted October 2, 2017 show me the code you are now using. Link to comment
[MTA]Weed Posted October 2, 2017 Author Share Posted October 2, 2017 Client code: strings = { { "_", " " }, { "-", " " }, { "^%[[%w@]+%]", " " }, { "^%a+|", " " }, { "|.+$", " " }, { "1", "" }, { "2", "" }, { "3", "" }, { "4", "" }, { "5", "" }, { "6", "" }, { "7", "" }, { "8", "" }, { "9", "" }, { "0", "" }, } myfont = dxCreateFont("DFHEIMDU_id.ttf",10) nametags_Root = getRootElement() nametags_ResRoot = getResourceRootElement(getThisResource()) nametags_Players = getElementsByType('player') nametags_Me = getLocalPlayer() nametag = {} local nametags = {} local sWidth,sHeight = guiGetScreenSize() local Nametags_Hide = false local Nametags_Scale = 0.25 local Nametags_Alpha_Distance = 50 local Nametags_Distance = 80 local Nametags_Alpha = 255 local Nametags_Text_Bar_Space = 2 local Nametags_Width = 50 local Nametags_Height = 20 local Nametags_Size = 0.3 local Nametags_Outline_Thickness = 2.2 local Nametags_Alpha_Diff = Nametags_Distance - Nametags_Alpha_Distance Nametags_Scale = 1/Nametags_Scale * 800 / sHeight local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } function nametags.Create ( player ) nametags[player] = true end function nametags.Destroy ( player ) nametags[player] = nil end addEventHandler ( "onClientRender", nametags_Root, function() if getElementData(getLocalPlayer(), "state.hud") == "disabled" then return end for i,player in ipairs(nametags_Players) do if isElement(player) then setPlayerNametagShowing ( player, false ) if not nametags[player] then nametags.Create ( player ) end end end if Nametags_Hide then return end local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(nametags_Me) then break end local px,py,pz = getElementPosition ( player ) local bx, by, bz = getPedBonePosition( player, 5 ) if processLineOfSight(x, y, z, px, py, pz, true, false, false, true, false, true) then break end local playerDistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if playerDistance <= Nametags_Distance then --Get screen position --local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) local sx,sy = getScreenFromWorldPosition( bx + 0, by, bz + 0.4 ) if not sx or not sy then break end --Calculate our components local scale = 1/(Nametags_Scale * (playerDistance / Nametags_Distance)) local alpha = ((playerDistance - Nametags_Alpha_Distance) / Nametags_Alpha_Diff) alpha = (alpha < 0) and Nametags_Alpha or Nametags_Alpha-(alpha*Nametags_Alpha) scale = math.evalCurve(maxScaleCurve,scale) local textScale = math.evalCurve(textScaleCurve,scale) local textAlpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = Nametags_Outline_Thickness*(scale) --Requirements local team = getPlayerTeam(player) local level = getElementData(player, "LV") or 0 local class = getElementData(player, "class") local r,g,b = getPlayerNametagColor(player) local offset = (scale) * Nametags_Text_Bar_Space/2 local playerName = getPlayerName(player) for k,v in ipairs (strings) do if string.find( string.lower ( playerName ),v[1]) then playerName = playerName:gsub ( v[1], v[2] ) end end local imageSize = dxGetFontHeight ( textScale*Nametags_Size, myfont ) local lp = getElementData(player, "experience.rank") or "Newbie" --Draw our text --dxDrawText ( playerName, sx, sy - offset, sx, sy - offset, tocolor(0,0,0,255), textScale*Nametags_Size, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText ( playerName.."("..level..")", sx, sy - offset + 4*scale, sx, sy - offset + 4*scale, tocolor(0,0,0,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText ( playerName.."("..level..")", sx, sy - offset + 4*scale, sx, sy - offset + 4*scale, tocolor(r,g,b,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) nameWidth = dxGetTextWidth ( playerName.."("..level..")", textScale*Nametags_Size, myfont ) teamWidth = nameWidth if team then dxDrawText (" ["..getTeamName(team).."] ", sx, sy - offset + 8*scale, sx, sy - offset + 8*scale, tocolor(0,0,0,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText (" ["..getTeamName(team).."] ", sx, sy - offset + 8*scale, sx, sy - offset + 8*scale, tocolor(r,g,b,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) teamWidth = dxGetTextWidth (" ["..getTeamName(team).."] ", textScale*Nametags_Size*0.75, myfont ) end if getElementData(player, "class") then dxDrawText (tostring(class), sx, sy - offset - 0*scale, sx, sy - offset - 0*scale, tocolor(0,0,0,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText (tostring(class), sx, sy - offset - 0*scale, sx, sy - offset - 0*scale, tocolor(r,g,b,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) typingWidth = dxGetTextWidth (tostring(class), textScale*Nametags_Size*0.75, myfont ) end if class and team then dxDrawImage ( sx + math.max(nameWidth/2, teamWidth/2) + 1*scale, sy - math.max(teamWidth/6), imageSize, imageSize, ":Nametag/class/"..class..".png" ) elseif class and not team then dxDrawImage ( sx + math.max(nameWidth/2) + 1*scale, sy - math.max(nameWidth/10), imageSize, imageSize, ":Nametag/class/"..class..".png" ) end if getElementData(player, "play.nodm") == true then dxDrawImage ( sx - math.max(nameWidth/2, teamWidth/2) - 7*scale, sy - imageSize, imageSize, imageSize, ":Nametag/class/friendly.png" ) else dxDrawImage ( sx - math.max(nameWidth/2, teamWidth/2) - 7*scale, sy - imageSize, imageSize, imageSize, ":Experience/Emblems/"..lp..".png" ) end end break end end end ) function nametagsCreate() for i,player in ipairs(getElementsByType"player") do nametags.Create ( player ) end end addEventHandler('onClientResourceStart', nametags_Root, nametagsCreate) function nametagsCreateOnJoin() if source == nametags_Me then return end setPlayerNametagShowing ( source, false ) nametags.Create ( source ) end addEventHandler('onClientPlayerJoin', nametags_Root, nametagsCreateOnJoin) function nametagsDestroy() nametags.Destroy ( source ) end addEventHandler('onClientPlayerQuit', nametags_Root, nametagsDestroy) function math.lerp(from,to,alpha) return from + (to-from) * alpha end function math.evalCurve( curve, input ) if input<curve[1][1] then return curve[1][2] end for idx=2,#curve do if input<curve[idx][1] then local x1 = curve[idx-1][1] local y1 = curve[idx-1][2] local x2 = curve[idx][1] local y2 = curve[idx][2] local alpha = (input - x1)/(x2 - x1); return math.lerp(y1,y2,alpha) end end return curve[#curve][2] end function fixSomeLoops() if (getElementData(source, "player.key") == "") or (getElementData(source, "player.key") == "") or (getElementData(source, "player.key") == "") then cancelEvent() end end addEventHandler("onClientPlayerDamage", getRootElement(), fixSomeLoops) addEventHandler("onPlayerStealthKill", getRootElement(), fixSomeLoops) Server: addEventHandler( 'onPlayerLogout', root, function ( ) local class = getElementData(source, "class") if class then setElementData(source, "class", "player") else setElementData(source, "class", "player") end end ) addEventHandler( 'onPlayerLogin', root, function ( ) local account = getPlayerAccount( source ) if account and not isGuestAccount( account ) then local accountName = getAccountName( account ); if isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Marijuana" ) ) then setElementData(source, "class", "Marijuana") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Admin" ) ) then setElementData(source, "class", "Admin") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Moderator" ) ) then setElementData(source, "class", "Moderator") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "SuperModerator" ) ) then setElementData(source, "class", "SuperModerator") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Warden" ) ) then setElementData(source, "class", "Warden") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "EliteVIP" ) ) then setElementData(source, "class", "Elite VIP") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "VIP" ) ) then setElementData(source, "class", "VIP") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Commander" ) ) then setElementData(source, "class", "Commander") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Everyone" ) ) then setElementData(source, "class", "Player") else setElementData(source, "class", "Player") end end end ); i tryed removing everything one by one direcly in server when players was active it didnt show no less/more result, it was same. Link to comment
Moderators IIYAMA Posted October 2, 2017 Moderators Share Posted October 2, 2017 Images are still there. I want to see less code, not more lol. Link to comment
[MTA]Weed Posted October 3, 2017 Author Share Posted October 3, 2017 strings = { { "_", " " }, { "-", " " }, { "^%[[%w@]+%]", " " }, { "^%a+|", " " }, { "|.+$", " " }, { "1", "" }, { "2", "" }, { "3", "" }, { "4", "" }, { "5", "" }, { "6", "" }, { "7", "" }, { "8", "" }, { "9", "" }, { "0", "" }, } myfont = dxCreateFont("DFHEIMDU_id.ttf",10) nametags_Root = getRootElement() nametags_ResRoot = getResourceRootElement(getThisResource()) nametags_Players = getElementsByType('player') nametags_Me = getLocalPlayer() nametag = {} local nametags = {} local sWidth,sHeight = guiGetScreenSize() local Nametags_Hide = false local Nametags_Scale = 0.4 local Nametags_Alpha_Distance = 30 local Nametags_Distance = 40 local Nametags_Alpha = 255 local Nametags_Text_Bar_Space = -2 local Nametags_Width = 50 local Nametags_Height = 40 local Nametags_Size = 0.4 local Nametags_Outline_Thickness = 10 local Nametags_Alpha_Diff = Nametags_Distance - Nametags_Alpha_Distance Nametags_Scale = 1/Nametags_Scale * 800 / sHeight local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } function nametags.Create ( player ) nametags[player] = true end function nametags.Destroy ( player ) nametags[player] = nil end addEventHandler ( "onClientRender", nametags_Root, function() if getElementData(getLocalPlayer(), "state.hud") == "disabled" then return end for i,player in ipairs(nametags_Players) do if isElement(player) then setPlayerNametagShowing ( player, false ) if not nametags[player] then nametags.Create ( player ) end end end if Nametags_Hide then return end local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(nametags_Me) then break end local px,py,pz = getElementPosition ( player ) local bx, by, bz = getPedBonePosition( player, 5 ) if processLineOfSight(x, y, z, px, py, pz, true, false, false, true, false, true) then break end local playerDistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if playerDistance <= Nametags_Distance then --Get screen position --local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) local sx,sy = getScreenFromWorldPosition( bx + 0, by, bz + 0.4 ) if not sx or not sy then break end --Calculate our components local scale = 1/(Nametags_Scale * (playerDistance / Nametags_Distance)) local alpha = ((playerDistance - Nametags_Alpha_Distance) / Nametags_Alpha_Diff) alpha = (alpha < 0) and Nametags_Alpha or Nametags_Alpha-(alpha*Nametags_Alpha) scale = math.evalCurve(maxScaleCurve,scale) local textScale = math.evalCurve(textScaleCurve,scale) local textAlpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = Nametags_Outline_Thickness*(scale) --Requirements local team = getPlayerTeam(player) local level = getElementData(player, "LV") or 0 local class = getElementData(player, "class") local r,g,b = getPlayerNametagColor(player) local offset = (scale) * Nametags_Text_Bar_Space/2 local playerName = getPlayerName(player) for k,v in ipairs (strings) do if string.find( string.lower ( playerName ),v[1]) then playerName = playerName:gsub ( v[1], v[2] ) end end local imageSize = dxGetFontHeight ( textScale*Nametags_Size, myfont ) local lp = getElementData(player, "experience.rank") or "Newbie" --Draw our text --dxDrawText ( playerName, sx, sy - offset, sx, sy - offset, tocolor(0,0,0,255), textScale*Nametags_Size, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText ( playerName.."", sx, sy - offset + 4*scale, sx, sy - offset + 4*scale, tocolor(0,0,0,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText ( playerName.."", sx, sy - offset + 4*scale, sx, sy - offset + 4*scale, tocolor(r,g,b,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) nameWidth = dxGetTextWidth ( playerName.."", textScale*Nametags_Size, myfont ) teamWidth = nameWidth if team then dxDrawText (" ["..getTeamName(team).."] ", sx, sy - offset + 8*scale, sx, sy - offset + 8*scale, tocolor(0,0,0,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) dxDrawText (" ["..getTeamName(team).."] ", sx, sy - offset + 8*scale, sx, sy - offset + 8*scale, tocolor(r,g,b,255), textScale*Nametags_Size*0.75, myfont, "center", "bottom", false, false, false, true, true ) teamWidth = dxGetTextWidth (" ["..getTeamName(team).."] ", textScale*Nametags_Size*0.75, myfont ) end end end ) function nametagsCreate() for i,player in ipairs(getElementsByType"player") do nametags.Create ( player ) end end addEventHandler('onClientResourceStart', nametags_Root, nametagsCreate) function nametagsCreateOnJoin() if source == nametags_Me then return end setPlayerNametagShowing ( source, false ) nametags.Create ( source ) end addEventHandler('onClientPlayerJoin', nametags_Root, nametagsCreateOnJoin) function nametagsDestroy() nametags.Destroy ( source ) end addEventHandler('onClientPlayerQuit', nametags_Root, nametagsDestroy) function math.lerp(from,to,alpha) return from + (to-from) * alpha end function math.evalCurve( curve, input ) if input<curve[1][1] then return curve[1][2] end for idx=2,#curve do if input<curve[idx][1] then local x1 = curve[idx-1][1] local y1 = curve[idx-1][2] local x2 = curve[idx][1] local y2 = curve[idx][2] local alpha = (input - x1)/(x2 - x1); return math.lerp(y1,y2,alpha) end end return curve[#curve][2] end function fixSomeLoops() if (getElementData(source, "player.key") == "") or (getElementData(source, "player.key") == "") or (getElementData(source, "player.key") == "") then cancelEvent() end end addEventHandler("onClientPlayerDamage", getRootElement(), fixSomeLoops) addEventHandler("onPlayerStealthKill", getRootElement(), fixSomeLoops) 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