Jump to content

Help


ma2med

Recommended Posts

hi, i was doing small script but it's seem like setPlayerNametagShowing don't work:

  
hasClicked = true 
addCommandHandler("ok",function() 
if hasClicked == true then 
for i,player in ipairs(getElementsByType("player")) do 
setPlayerNametagShowing ( player, false ) 
end 
hasClicked = false 
else 
for i,player in ipairs(getElementsByType("player")) do 
setPlayerNametagShowing ( player, true ) 
hasClicked = true 
end 
end 
end 
) 
  

Link to comment
local hasClicked = true 
addCommandHandler("ok", 
function() 
if hasClicked == true then 
setPlayerNametagShowing ( source, false ) 
end 
if hasClicked == false 
setPlayerNametagShowing ( source, true ) 
end 
end 
) 

This code makes no sense, please, do not post answers if you cannot write a simple if statement correctly. And besides, addCommandHandler returns no source.

Link to comment
  
function disableTag () 
for i, player in ipairs(getElementsByType("player")) do 
if isPlayerNametagShowing(player) == true then 
setPlayerNametagShowing (player, false) 
outputChatBox ("Players name tag disabled!", player) 
elseif isPlayerNametagShowing(player) == false then 
setPlayerNametagShowing(player, true) 
outputChatBox ("Players name tag enabled!", player) 
     end 
  end 
end   
addCommandHandler ("ok", disableTag) 

This might work properly for disabling player name tag. I haven't tested it though.

Link to comment

If you are using hasClicked to see if the user clicked on a GUI Button, better use onClientGUIClick.

If you are using hasClicked for something else, you may use a short code:

  
hasClicked = true 
function handleTags () 
    for i,v in ipairs (getElementsByType ('player')) do 
        if hasClicked then 
            setPlayerNametagShowing( v, not(hasClicked) ) 
            outputChatBox ("Nametags triggered") 
        end 
    end 
end 
addCommandHandler ("triggertags",handleTags) 
  

I did not test this, reply with any error you find.

Note: You need to disable nametags on client side, you don't want to disable all nametags for all players, right?

Link to comment
If you are using hasClicked to see if the user clicked on a GUI Button, better use onClientGUIClick.

If you are using hasClicked for something else, you may use a short code:

  
hasClicked = true 
function handleTags () 
    for i,v in ipairs (getElementsByType ('player')) do 
        if hasClicked then 
            setPlayerNametagShowing( v, not(hasClicked) ) 
            outputChatBox ("Nametags triggered") 
        end 
    end 
end 
addCommandHandler ("triggertags",handleTags) 
  

I did not test this, reply with any error you find.

Note: You need to disable nametags on client side, you don't want to disable all nametags for all players, right?

yes for all players but when I do that it's still showing it's bug maybe?

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