JuniorMelo Posted February 20, 2016 Posted February 20, 2016 hello, table is just blocking 'Console' is not to block other words, Can anyone tell me why sorry my bad english 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 )
tosfera Posted February 20, 2016 Posted February 20, 2016 hello, table is just blocking 'Console' is not to block other words, Can anyone tell me why sorry my bad english 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
JuniorMelo Posted February 20, 2016 Author Posted February 20, 2016 Thx Tosfera, this way is more practical and simple
Tomas Posted February 20, 2016 Posted February 20, 2016 Thx Tosfera, this way is more practical and simple if not noTeams[teamName] then
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