Jump to content

setPlayerNametagShowing problem


Blinker.

Recommended Posts

hello ,

i want to turn off all players nametags , but it's not working. i'm using the wiki example

  
function onResourceStart ( ) 
    local players = getElementsByType ( "player" ) -- Store all the players in the server into a table 
    for key, player in ipairs ( players ) do       -- for all the players in the table 
        setPlayerNametagShowing ( player, false )  -- turn off their nametag 
    end 
end 
addEventHandler ( "onResourceStart", root, onResourceStart ) 
  
  
  

Thanks in Advance

Link to comment
  
addEventHandler("onResourceStart", root, 
    function() 
        local players = getElementsByType("player") 
        for i = 1, #players do 
            setPlayerNametagShowing(players[i], false) 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        setPlayerNametagShowing(source, false) 
    end 
) 

Link to comment
  
addEventHandler("onResourceStart", root, 
    function() 
        local players = getElementsByType("player") 
        for i = 1, #players do 
            setPlayerNametagShowing(players[i], false) 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        setPlayerNametagShowing(source, false) 
    end 
) 

You need to create a table for this, or (players) will be left undefined. +Your first part has no use in the script. He wanted to just turn off player nametags.

Link to comment

WTF guys -_-

addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for _, player in ipairs(getElementsByType("player")) do 
            setPlayerNametagShowing(player, false) 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        setPlayerNametagShowing(source, false) 
    end 
) 

Link to comment
  
addEventHandler("onResourceStart", root, 
    function() 
        local players = getElementsByType("player") 
        for i = 1, #players do 
            setPlayerNametagShowing(players[i], false) 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        setPlayerNametagShowing(source, false) 
    end 
) 

You need to create a table for this, or (players) will be left undefined. +Your first part has no use in the script. He wanted to just turn off player nametags.

FFS are you all mad? He's CODE IS TOTALLY CORRECT. Go learn Bilal! i is defined in the loop already. i = 1, #players do and when it runs it returns i's value so you check the table's index of i value. #logic

Link to comment
WTF guys -_-
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for _, player in ipairs(getElementsByType("player")) do 
            setPlayerNametagShowing(player, false) 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        setPlayerNametagShowing(source, false) 
    end 
) 

Same as mine, it's just slower with ipairs.. so WTF to you

Link to comment
  • Moderators

He did the responsive element (resourceRoot) correct, so his code is not as inefficient as yours except for the ipairs part.

If you had other code executed by that event, you would have bugs.

it is only so WTF that WASSIm. isn't explaining his changes.

Link to comment
He did the responsive element (resourceRoot) correct, so his code is not as inefficient as yours except for the ipairs part.

If you had other code executed by that event, you would have bugs.

it is only so WTF that WASSIm. isn't explaining his changes.

That's becouse I copy/pasted the code from the first post, didn't even notice that.

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