Jump to content

Show player nametag just for friends


Artisz

Recommended Posts

Try to use

setPlayerNametagShowing 

and a boucle for to get player's friends with a getElementData ?

All of this client sided

Example:

  
--Client Side 
function resourceStart( ) 
    local players = getElementsByType ( "player" ) 
    for key, player in ipairs ( players ) do 
       -- Make your getElementData here or get if localPlayer and player are friends 
        setPlayerNametagShowing ( player, false ) 
    end 
end 
addEventHandler ( "onResourceStart", getResouceRootElement(getThisResource()), resourceStart ) 

Edited by Guest
Link to comment

So if I set the elementdata, when he introduce himself like this:

setElementData(source, tonumber(targetPlayer), 1) 

And in clientside I try this:

function resourceStart() 
    local players = getElementsByType ( "player" ) 
    for key, player in ipairs ( players ) do 
       if(getElementData(source, tonumber(player) == 1) then 
            setPlayerNametagShowing ( player, true ) 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getResouceRootElement(getThisResource()), resourceStart 

It'll working? I can't try this now.

Link to comment

Forgot to setPlayerNametagShowing off for other player, but yea, should work

function resourceStart() 
    local players = getElementsByType ( "player" ) 
    for key, player in ipairs ( players ) do 
       setPlayerNametagShowing ( player, false) 
       if(getElementData(source, tonumber(player) == 1) then 
            setPlayerNametagShowing ( player, true ) 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getResouceRootElement(getThisResource()), resourceStart 

Link to comment
function resourceStart() 
    local players = getElementsByType ( "player" ) 
    for key, player in ipairs ( players ) do 
       setPlayerNametagShowing ( player, false) 
       if(getElementData(getLocalPlayer(), tonumber(player) == 1) then 
            setPlayerNametagShowing ( player, true ) 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getResouceRootElement(getThisResource()), resourceStart 

Link to comment
function resourceStart() 
    local players = getElementsByType ( "player" ) 
    for key, player in ipairs ( players ) do 
       setPlayerNametagShowing ( player, false) 
       if(getElementData(getLocalPlayer(), tonumber(player) == 1) then 
            setPlayerNametagShowing ( player, true ) 
        end 
    end 
end 
addEventHandler ( "onClientResourceStart", getResouceRootElement(getThisResource()), resourceStart 

Link to comment

It's working, thank you! Sorry for the lot of problem!

If someone need this, here is my version:

addEventHandler( 'onClientRender', root, 
    function() 
        local players = getElementsByType ( "player" ) 
        for key, player in ipairs ( players ) do 
            setPlayerNametagShowing ( player, false) 
        if(getElementData(getLocalPlayer(), tonumber(getElementData(player,"accountID"))) == 1) then 
            setPlayerNametagShowing ( player, true ) 
        end 
    end 
end) 

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...