ma2med Posted November 23, 2014 Share Posted November 23, 2014 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
myonlake Posted November 24, 2014 Share Posted November 24, 2014 Please describe the issue you are facing, or we cannot help. Link to comment
Bilal135 Posted November 24, 2014 Share Posted November 24, 2014 local hasClicked = true addCommandHandler("ok", function() if hasClicked == true then setPlayerNametagShowing ( source, false ) end if hasClicked == false setPlayerNametagShowing ( source, true ) end end ) Link to comment
myonlake Posted November 24, 2014 Share Posted November 24, 2014 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
.:HyPeX:. Posted November 24, 2014 Share Posted November 24, 2014 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. Yep, its actually function(source,cmd) Link to comment
ma2med Posted November 24, 2014 Author Share Posted November 24, 2014 I wan't hide the nametag from all players but it's not working it's still show Link to comment
Irish Posted November 25, 2014 Share Posted November 25, 2014 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
AJXB Posted November 25, 2014 Share Posted November 25, 2014 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
ma2med Posted November 29, 2014 Author Share Posted November 29, 2014 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
myonlake Posted November 29, 2014 Share Posted November 29, 2014 You probably use a custom nametag script that does not work with that function. 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