Jump to content

need help


Blaawee

Recommended Posts

hi all , all i wan't to do draw text only on admins head

i made this but not shure

local screenWidth, screenHeight = guiGetScreenSize() 
local name = getPlayerName() 
      
function createText ( ) 
    if isObjectInACLGroup ( "user." .. playerName, aclGetGroup ( "Admin" ) ) then 
    dxDrawText( "Admin"..tostring(name), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown" ) 
end 
addEventHandler("onPlayerLogin",root, createText) 

Link to comment

those all lines i want it right? :

local WORLD_OFFSET = 0.4 
local BONE_ID = 8 
  
addEventHandler ( "onClientRender", root, 
    function() 
        local color = tocolor(getPlayerNametagColor ( player )) 
        local headX,headY,headZ = getPedBonePosition(player,BONE_ID) 
        headZ = headZ + WORLD_OFFSET 
        local absX,absY = getScreenFromWorldPosition ( headX,headY,headZ ) 
            if not absX or not absY then 
                break 
            end 
        local camX,camY,camZ = getCameraMatrix() 
        if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, player ) then 
                break 
            end 
            dxDrawVoice ( absX, absY, color, getDistanceBetweenPoints3D(camX, camY, camZ, headX, headY, headZ) ) 
            break 
        end 
    end 
end 
) 

Link to comment

Server:

  
  
local account = getPlayerAccount(getPlayerName(source)) 
      
function ifAdmin ( ) 
     
    if isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Admin" ) ) then 
          triggerClientEvent("dxText", getRootElement()) 
    else 
    end 
     
end 
  

Client:

  
local screenHeight, screenWidth = guiGetScreenSize() 
      function aTag(thePlayer) 
            name = getPlayerName(thePlayer) 
                  dxDrawText( "Admin"..tostring(name), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown" ) 
       end 
addEvent("dxText", true) 
addEventHandler("dxText", getRootElement(), aTag) 
addEventHandler ( "onClientResourceStart", getRootElement(), aTag ) 

Pretty basic, not sure if it's correct, but from here you'll have to attach it to the player's head, somehow.

Link to comment
Server:
  
  
local account = getPlayerAccount(getPlayerName(source)) 
      
function ifAdmin ( ) 
     
    if isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Admin" ) ) then 
          triggerClientEvent("dxText", getRootElement()) 
    else 
    end 
     
end 
  

Client:

  
local screenHeight, screenWidth = guiGetScreenSize() 
      function aTag(thePlayer) 
            name = getPlayerName(thePlayer) 
                  dxDrawText( "Admin"..tostring(name), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown" ) 
       end 
addEvent("dxText", true) 
addEventHandler("dxText", getRootElement(), aTag) 
addEventHandler ( "onClientResourceStart", getRootElement(), aTag ) 

Pretty basic, not sure if it's correct, but from here you'll have to attach it to the player's head, somehow.

the code is realy mess

Link to comment

I would set element data to the player when login, and remove it when logout.

-- server side:

addEventHandler("onPlayerLogin",root, 
function () 
local account = getPlayerAccount(source) 
if account and not isGuestAccount(account) then 
local accountName = getAccountName(account) 
        if isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Admin" ) ) then 
             setElementData(source,"isAdmin",true) 
        end 
   end 
end) 
  
addEventHandler("onPlayerLogout",root, 
function () 
setElementData(source,"isAdmin",false) 
end) 

-- client side:

addEventHandler("onClientRender",getRootElement(), 
function () 
    for i,v in ipairs(getElementsByType("player")) do 
        if getElementData(v,"isAdmin") then 
            local x,y,z = getElementPosition(v) 
            local cx,cy,cz = getCameraMatrix() 
                if getDistanceBetweenPoints3D(cx,cy,cz,x,y,z) <= 15 then 
                local px,py = getScreenFromWorldPosition(x,y,z+1.3,0.06) 
                if px then 
                                        local text = "Admin ".. tostring(getPlayerName(v)) 
                    local width = dxGetTextWidth(text,1,"sans") 
                    dxDrawText(text, px, py, px, py, tocolor(0, 255, 0, 255), 2, "sans", "center", "center", false, false) 
                end 
            end 
        end 
    end 
end) 

Link to comment
Server:
  
  
local account = getPlayerAccount(getPlayerName(source)) 
      
function ifAdmin ( ) 
     
    if isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Admin" ) ) then 
          triggerClientEvent("dxText", getRootElement()) 
    else 
    end 
     
end 
  

Client:

  
local screenHeight, screenWidth = guiGetScreenSize() 
      function aTag(thePlayer) 
            name = getPlayerName(thePlayer) 
                  dxDrawText( "Admin"..tostring(name), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown" ) 
       end 
addEvent("dxText", true) 
addEventHandler("dxText", getRootElement(), aTag) 
addEventHandler ( "onClientResourceStart", getRootElement(), aTag ) 

Pretty basic, not sure if it's correct, but from here you'll have to attach it to the player's head, somehow.

the code is realy mess

May I ask why it's a mess?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...