Zsoltisz Posted October 13, 2016 Share Posted October 13, 2016 (edited) Hello guys I got error in this script. please help me. ERROR:names/nametags.lua:75:attempt to perform arithmetic on local "sy" (a nil value) local myfont = "" local nametags = { } local nevekbe = false -- settings local _max_distance = 300 local _adminszoli_tavolsag = 20 local _adminszoli_textsize = 1.3 local _min_distance = 7.5 local _alpha_distance = 20 local _nametag_alpha = 170 local _bar_alpha = 300 local _scale = 0.2 local _nametag_textsize = 1.5 local _chatbubble_size = 15 local _bar_width = 40 local _bar_height = 6 local _bar_border = 1.2 local _, screenY = guiGetScreenSize( ) real_scale = screenY / ( _scale * 800 ) local _alpha_distance_diff = _max_distance - _alpha_distance local localPlayer = getLocalPlayer( ) addEventHandler( 'onClientRender', root, function( ) -- get the camera position of the local player local cx, cy, cz = getCameraMatrix( ) local dimension = getElementDimension( localPlayer ) local interior = getElementInterior( localPlayer ) -- loop through all players for player, chaticon in pairs( nametags ) do if (getElementDimension( player ) == dimension and getElementInterior( player ) == interior and isElementOnScreen( player )) then local px, py, pz = getElementPosition( player ) local distance = getDistanceBetweenPoints3D( px, py, pz, cx, cy, cz ) if distance <= _adminszoli_tavolsag then local dz = 1 + 2 * math.min( 1, distance / _min_distance ) * _scale if isPedDucked( player ) then dz = dz / 2 end pz = pz + dz local sx, sy = getScreenFromWorldPosition( px, py, pz ) if sx and sy then local cx = sx distance = math.max( distance, _min_distance ) local scale = 1 local alpha = ( ( distance - _alpha_distance ) / _alpha_distance_diff ) local bar_alpha = ( ( alpha < 0 ) and _bar_alpha or _bar_alpha - (alpha * _bar_alpha) ) * ( getElementData( localPlayer, "collisionless" ) and 1 or getElementAlpha( player ) / 255 ) if bar_alpha > 0 then end local nametag_alpha = 1000 end local jatekosid = getElementData ( player, "playerid" ) local adminduty = getElementData ( player, "adminduty" ) local adminrang = exports.StarMTA_core:AdminRang( player ) local alpha = getElementAlpha(player) or 0 if (adminduty == 0 and getElementAlpha(player, 255)) then local jatekosid = getElementData ( player, "playerid" ) dxDrawText(getPlayerNametagText( player ).." #FFFFFF("..jatekosid..")", sx, sy+75, sx, sy+75, tocolor( 255, 255, 255, 255 ), 1.5, 'arial', 'center', 'bottom',false,false,false,true ) end if (exports.StarMTA_core:Tulajdonos(player) and adminduty == 1 and alpha == 255) then local jatekosid = getElementData ( player, "playerid" ) local adminduty = getElementData ( player, "adminduty" ) local adminrang = exports.StarMTA_core:AdminRang( player ) dxDrawText("#FFFFFF"..getPlayerNametagText( player ).." #FF3333(#"..adminrang..") #FFFFFF("..jatekosid..")", sx, sy+75, sx, sy+75, tocolor( 0, 240, 255, 255), 1.7, 'arial', 'center', 'bottom',false,false,false,true ) elseif (exports.StarMTA_core:Fejleszto(player) and adminduty == 1 and alpha == 255) then dxDrawText("#FFFFFF"..getPlayerNametagText( player ).." #32B3EF<"..adminrang.."/> #FFFFFF("..jatekosid..")", sx, sy, sx, sy+75, tocolor( 0, 240, 255, 255 ), 1.7, 'arial', 'center', 'bottom',false,false,false,true ) elseif (exports.StarMTA_core:Rendszergazda(player) and adminduty == 1 and alpha == 255) then dxDrawText("#FFFFFF"..getPlayerNametagText( player ).." #ec9d9d("..adminrang..") #FFFFFF("..jatekosid..")", sx, sy, sx, sy+75, tocolor( 0, 240, 255, 255 ), 1.7, 'arial', 'center', 'bottom',false,false,false,true ) elseif (exports.StarMTA_core:SzuperAdmin(player) and adminduty == 1 and alpha == 255) then dxDrawText("#FFFFFF"..getPlayerNametagText( player ).." #9c00ff("..adminrang..") #FFFFFF("..jatekosid..")", sx, sy, sx, sy+75, tocolor( 0, 240, 255, 255 ), 1.7, 'arial', 'center', 'bottom',false,false,false,true ) elseif (exports.StarMTA_core:FoAdmin(player) and adminduty == 1 and alpha == 255) then dxDrawText("#FFFFFF"..getPlayerNametagText( player ).." #ffb32f("..adminrang..") #FFFFFF("..jatekosid..")", sx, sy, sx, sy+75, tocolor( 0, 240, 255, 255 ), 1.7, 'arial', 'center', 'bottom',false,false,false,true ) elseif (exports.StarMTA_core:EgyesAdmin(player) and adminduty == 1 and alpha == 255) then dxDrawText("#FFFFFF"..getPlayerNametagText( player ).." #7cc576("..adminrang..") #FFFFFF("..jatekosid..")", sx, sy, sx, sy+75, tocolor( 0, 240, 255, 255 ), 1.7, 'arial', 'center', 'bottom',false,false,false,true ) end end end end end ) addEventHandler( 'onClientResourceStart', getResourceRootElement( ), function( ) for _, player in pairs( getElementsByType( 'player' ) ) do if player ~= localPlayer then -- hide the default nametag setPlayerNametagShowing( player, false ) if isElementStreamedIn( player ) then -- save the player data nametags[ player ] = false end end end end ) addEventHandler( 'onClientResourceStop', getResourceRootElement( ), function( ) -- handle stopping this resource for player in pairs( nametags ) do -- restore the nametag setPlayerNametagShowing( player, true ) -- remove saved data nametags[ player ] = nil end end ) addEventHandler ( 'onClientPlayerJoin', root, function( ) -- hide the nametag setPlayerNametagShowing( source, false ) end ) addEventHandler ( 'onClientElementStreamIn', root, function( ) if source ~= localPlayer and getElementType( source ) == "player" then -- save the player data nametags[ source ] = false triggerServerEvent( "nametags:chatbubble", source ) end end ) addEventHandler ( 'onClientElementStreamOut', root, function( ) if nametags[ source ] then -- cleanup nametags[ source ] = nil end end ) addEventHandler ( 'onClientPlayerQuit', root, function( ) if nametags[ source ] then -- cleanup nametags[ source ] = nil end end ) -- local oldConsoleState = false local oldInputState = false local tag = dxCreateTexture("Duty/Tulajdonos_Duty.png") local tag2 = dxCreateTexture("Duty/Fejleszto_Duty.png") local tag3 = dxCreateTexture("Duty/Rendszergazda_Duty.png") local tag4 = dxCreateTexture("Duty/SzuperAdmin_Duty.png") local tag5 = dxCreateTexture("Duty/FoAdmin_Duty.png") local tag6 = dxCreateTexture("Duty/Admin_Duty.png") function Fejleszto_Duty() local players = getElementsByType("player") for i = 1 , #players do local adminduty = getElementData(players[i], "adminduty") or 0 local alpha = getElementAlpha(players[i]) or 0 if tonumber(adminduty) == 1 and alpha == 255 then if players[i] ~= localPlayer then if exports.StarMTA_core:Tulajdonos(players[i]) then dxDrawImageOnElement(players[i],tag) elseif exports.StarMTA_core:Fejleszto(players[i]) then dxDrawImageOnElement(players[i],tag2) elseif exports.StarMTA_core:Rendszergazda(players[i]) then dxDrawImageOnElement(players[i],tag3) elseif exports.StarMTA_core:SzuperAdmin(players[i]) then dxDrawImageOnElement(players[i],tag4) elseif exports.StarMTA_core:FoAdmin(players[i]) then dxDrawImageOnElement(players[i],tag5) elseif exports.StarMTA_core:EgyesAdmin(players[i]) then dxDrawImageOnElement(players[i],tag6) end end end end end addEventHandler("onClientRender", root, Fejleszto_Duty) function dxDrawImageOnElement(TheElement,Image,distance,height,width,R,G,B,alpha) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local width = width or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance), x, y, z+height, Image, width-(distanceBetweenPoints/distance), tocolor(R or 255, G or 255, B or 255, alpha or 255)) end end end end Edited October 13, 2016 by Zsoltisz Link to comment
Gravestone Posted October 13, 2016 Share Posted October 13, 2016 Go throw the drawing function again. Look which 'end' is ending which function. 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