Jump to content

[UNSOLVED]Problem


GanJaRuleZ

Recommended Posts

Hai allz.

I've got this script , but when im muted and i change the nick , it outputs how many players are in the server

ex : im muted and i change my nick , this script disallows it , but it outputchatbox the players amount , ex there are 5 players in server , this script outputs it 5 times.. ( Sry for english , im very stressed )

  
function onClientChangeHisNick() 
  local players = getElementsByType ( "player" )  
   for k,v in ipairs(players) do 
     if isPlayerMuted ( source ) then 
      outputChatBox ( "#FF0000You're not allowed to change you're nick , while you're muted!", source, 255, 255, 255, true ) 
      cancelEvent() 
     else 
      outputChatBox ( "#99FF00Nick successfully changed!", source, 255, 255, 255, true ) 
     end 
end 
end 
addEventHandler ( "onPlayerChangeNick", getRootElement(), onClientChangeHisNick ) 

Link to comment

Why do you need a for-loop?

function onClientChangeHisNick() 
     if isPlayerMuted ( source ) then 
      outputChatBox ( "#FF0000You're not allowed to change you're nick , while you're muted!", source, 255, 255, 255, true ) 
      cancelEvent() 
     else 
      outputChatBox ( "#99FF00Nick successfully changed!", source, 255, 255, 255, true ) 
      end 
end 
addEventHandler ( "onPlayerChangeNick", getRootElement(), onClientChangeHisNick ) 

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