Jump to content

[help] table


JuniorMelo

Recommended Posts

hello, table is just blocking 'Console' is not to block other words, Can anyone tell me why :|:|

sorry my bad english :mrgreen:

noTeams = { "Console", "Admin", "Moderator", "SuperModerator" } 
  
function create( player, commandName, teamName ) 
    if teamName ~=  noTeams[1] and noTeams[2] then 
        local gang = createTeam( teamName ) 
        if (gang) then 
            setPlayerTeam( player, gang ) 
            setTeamColor ( gang, math.random(0,255), math.random(0,255), math.random(0,255) ) 
            outputChatBox( getPlayerName(player) .." #677079Create team #0084FF" ..teamName, getRootElement(), 255, 255, 255,true, thePlayer ) 
        end 
    else 
        outputChatBox("#A020F0[Gang]  #ffffffERROR.",thePlayer,255,255,255,true) 
    end 
end 
  
addCommandHandler("gang", create ) 

Link to comment
hello, table is just blocking 'Console' is not to block other words, Can anyone tell me why :|:|

sorry my bad english :mrgreen:

noTeams = { "Console", "Admin", "Moderator", "SuperModerator" } 
  
function create( player, commandName, teamName ) 
    if teamName ~=  noTeams[1] and noTeams[2] then 
        local gang = createTeam( teamName ) 
        if (gang) then 
            setPlayerTeam( player, gang ) 
            setTeamColor ( gang, math.random(0,255), math.random(0,255), math.random(0,255) ) 
            outputChatBox( getPlayerName(player) .." #677079Create team #0084FF" ..teamName, getRootElement(), 255, 255, 255,true, thePlayer ) 
        end 
    else 
        outputChatBox("#A020F0[Gang]  #ffffffERROR.",thePlayer,255,255,255,true) 
    end 
end 
  
addCommandHandler("gang", create ) 

It's a mistake a lot of people make.. the if-statement doesn't work like that. You've to ask new questions all the time;

if ( teamName ~=  noTeams [ 1 ] and teamName ~= noTeams [ 2 ] ) then 

A better ( and easier ) approach would be to create it like this;

noTeams = { [ "Console" ] = true, [ "Admin"  ] = true, [ "Moderator"  ] = true, [ "SuperModerator" ] = true }; 
if ( not noTeams [ teamName ] ) then 

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