DjMixCuma Posted February 8, 2013 Share Posted February 8, 2013 What is wrong? /debugscript - 0 errors, console 0 errors, but in game nametags not creating. nameTable = {} local screenX, screenY = guiGetScreenSize() local nameTags = {} function nameTable.Create(player) nameTags[player] = true end function nameTable.Delete(player) nameTags[player] = false end addEventHandler("onClientRender", getRootElement(), function() for i, player in ipairs(getElementsByType("player")) do if isElement(player) then if player ~= getLocalPlayer() then setPlayerNametagShowing(player, false) if not nameTags[player] then nameTable.Create(player) end end end end local cameraX, cameraY, cameraZ = getCameraMatrix() for thePlayer in pairs(nameTags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(getLocalPlayer()) then break end local playerX, playerY, playerZ = getElementPosition(player) if processLineOfSight(cameraX, cameraY, cameraZ, playerX, playerY, playerZ, true, false, false, true, false, true) then break end local distance3D = getDistanceBetweenPoints3D(cameraX, cameraY, cameraZ, playerX, playerY, playerZ) if distance3D <= 60 then local worldX, worldY = getScreenFromWorldPosition(playerX, playerY, playerZ + 0.95, 0.06) if not worldX or not worldY then break end dxDrawText(getPlayerName(player), worldX, worldY - 0.3, worldX, worldY - 0.3, tocolor(0, 0, 0, 255), 3, "default", "center", "bottom", false, false, false) dxDrawText(getPlayerName(player), worldX, worldY - 0.3, worldX, worldY - 0.3, tocolor(255, 224, 128, 220), 3, "default", "center", "bottom", false, false, false) end break end end end) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() for i, player in ipairs(getElementsByType("player")) do if player ~= getLocalPlayer() then nameTable.Create(player) end end end) addEventHandler("onClientPlayerJoin", getRootElement(), function() if source == getLocalPlayer() then return end setPlayerNametagShowing(source, false) nameTable.Create(source) end) addEventHandler("onClientPlayerQuit", getRootElement(), function() nameTable.Delete(source) end) Link to comment
PaiN^ Posted February 8, 2013 Share Posted February 8, 2013 Try This nameTable = {} local screenX, screenY = guiGetScreenSize() local nameTags = {} function nameTable.Create(player) nameTags[player] = true end function nameTable.Delete(player) nameTags[player] = false end addEventHandler("onClientRender", getRootElement(), function() for i, player in ipairs(getElementsByType("player")) do if isElement(player) then if player ~= getLocalPlayer() then setPlayerNametagShowing(player, false) if not nameTags[player] then nameTable.Create(player) end end end end end ) local cameraX, cameraY, cameraZ = getCameraMatrix() for thePlayer in pairs(nameTags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(getLocalPlayer()) then break end local playerX, playerY, playerZ = getElementPosition(player) if processLineOfSight(cameraX, cameraY, cameraZ, playerX, playerY, playerZ, true, false, false, true, false, true) then break end local distance3D = getDistanceBetweenPoints3D(cameraX, cameraY, cameraZ, playerX, playerY, playerZ) if distance3D <= 60 then local worldX, worldY = getScreenFromWorldPosition(playerX, playerY, playerZ + 0.95, 0.06) if not worldX or not worldY then break end dxDrawText(getPlayerName(player), worldX, worldY - 0.3, worldX, worldY - 0.3, tocolor(0, 0, 0, 255), 3, "default", "center", "bottom", false, false, false) dxDrawText(getPlayerName(player), worldX, worldY - 0.3, worldX, worldY - 0.3, tocolor(255, 224, 128, 220), 3, "default", "center", "bottom", false, false, false) end end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() for i, player in ipairs(getElementsByType("player")) do if player ~= getLocalPlayer() then nameTable.Create(player) end end end ) addEventHandler("onClientPlayerJoin", getRootElement(), function() if source == getLocalPlayer() then return end setPlayerNametagShowing(source, false) nameTable.Create(source) end ) addEventHandler("onClientPlayerQuit", getRootElement(), function() nameTable.Delete(source) end ) Link to comment
DjMixCuma Posted February 8, 2013 Author Share Posted February 8, 2013 @UP: Not working Link to comment
PaiN^ Posted February 8, 2013 Share Posted February 8, 2013 I think the reason is that the first 2 functions aren't attached to any event or command handler, And there is more than one function witch have the same name ( lines 15, 57, 68 and 78 ) . still i'm not an expert so it could be something else Link to comment
DjMixCuma Posted February 9, 2013 Author Share Posted February 9, 2013 Anyone can help me? Link to comment
Booo Posted February 9, 2013 Share Posted February 9, 2013 Anyone can help me? code FreeAxel function Tag( ) local x, y, z = getCameraMatrix( ) local dimension = getElementDimension( getLocalPlayer() ) for key, player in ipairs ( getElementsByType( "player", resourceRoot ) ) do if player ~= getLocalPlayer() then if getElementDimension( player ) == dimension then local px, py, pz = getElementPosition( player ) local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z ) if distance <= 60 then local text = getPlayerName(player) if isLineOfSightClear( x, y, z, px, py, pz + 1.1, true, true, true, true, false, false, true, getLocalPlayer() ) then local sx, sy = getScreenFromWorldPosition( px, py, pz + 1.1 ) if sx and sy then dxDrawText( tostring( text ), sx, sy, sx, sy, tocolor(0, 0, 0, 255), 3, "default", "center", "bottom", false, false, false) dxDrawText( tostring( text ), worldX, worldY - 0.3, worldX, worldY - 0.3, tocolor(255, 224, 128, 220), 3, "default", "center", "bottom", false, false, false) end end end end end end end addEventHandler( "onClientRender", getRootElement( ),Tag) Link to comment
DjMixCuma Posted February 9, 2013 Author Share Posted February 9, 2013 My code: local screenX, screenY = guiGetScreenSize() addEventHandler("onClientRender", getRootElement(), function() local cameraX, cameraY, cameraZ = getCameraMatrix() for _, thePlayer in pairs(getElementsByType("player")) do while true do if not isElement(thePlayer) then break end if getElementDimension(thePlayer) ~= getElementDimension(getLocalPlayer()) then break end local playerX, playerY, playerZ = getElementPosition(thePlayer) if processLineOfSight(cameraX, cameraY, cameraZ, playerX, playerY, playerZ, true, false, false, true, false, true) then break end local distance3D = getDistanceBetweenPoints3D(cameraX, cameraY, cameraZ, playerX, playerY, playerZ) if distance3D <= 10 then local worldX, worldY = getScreenFromWorldPosition(playerX, playerY, playerZ + 0.95, 0.06) if not worldX or not worldY then break end dxDrawText(getPlayerName(thePlayer), worldX, worldY - 0.1, worldX, worldY - 0.1, tocolor(0, 0, 0, 255), 1.64, "default", "center", "bottom", false, false, false) dxDrawText(getPlayerName(thePlayer), worldX, worldY - 0.1, worldX, worldY - 0.1, tocolor(255, 224, 128, 215), 1.65, "default", "center", "bottom", false, false, false) end break end end end) Working, but i see my nick on ped head, but i dont wont it, and i want bold my dxDraw, because actually is difficult to see. Link to comment
3NAD Posted February 9, 2013 Share Posted February 9, 2013 local screenX, screenY = guiGetScreenSize ( ) addEventHandler ( "onClientRender", root, function ( ) local cameraX, cameraY, cameraZ = getCameraMatrix() for _, thePlayer in pairs ( getElementsByType ("player") ) do while true do if thePlayer ~= localPlayer then if not isElement ( thePlayer ) then return end if getElementDimension ( thePlayer ) ~= getElementDimension ( localPlayer ) then return end local playerX, playerY, playerZ = getElementPosition ( thePlayer ) local ps = processLineOfSight ( cameraX, cameraY, cameraZ, playerX, playerY, playerZ, true, false, false, true, false, true ) if ps then return end local distance3D = getDistanceBetweenPoints3D ( cameraX, cameraY, cameraZ, playerX, playerY, playerZ) if distance3D <= 10 then local worldX, worldY = getScreenFromWorldPosition ( playerX, playerY, playerZ + 0.95, 0.06 ) if not worldX or not worldY then return end dxDrawText(getPlayerName(thePlayer), worldX, worldY - 0.1, worldX, worldY - 0.1, tocolor(0, 0, 0, 255), 1.64, "bold", "center", "bottom", false, false, false) dxDrawText(getPlayerName(thePlayer), worldX, worldY - 0.1, worldX, worldY - 0.1, tocolor(255, 224, 128, 215), 1.65, "bold", "center", "bottom", false, false, false) end end break end end end ) 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