Jump to content

create team by command


-misterX-

Recommended Posts

function createNewTeam (playerSource, cmd, team) 
local newTeam = createTeam(team) 
setPlayerTeam(playerSource, newTeam) 
end 
addCommandHandler("createteam", createNewTeam) 

Not sure if works, give it a shot and then reply if it works or not.

Good, but it won't work at some points. Check at my code, it has more checks to it and shizzle.

Server-side

addCommandHandler("createteam", -- The command is "createteam" 
    function(player, cmd, team) 
        if team then -- Check if the parameter has been entered 
            local team = table.concat({...}, " ") -- Make sure all the spaces are gathered 
            if #team > 1 then -- Check if the parameter is longer than one letter 
                local newTeam = createTeam(team) -- Create the actual team 
                setPlayerTeam(player, newTeam) -- Set the player into the team 
                outputChatBox("Team created and you were set to the team.", player, 10, 255, 10, false) -- Output a message to the player 
            else 
                outputChatBox("Syntax: /" .. cmd .. " [team name]", player, 255, 180, 10, false) -- Returns this when the parameter is not longer than one letter 
            end 
        else 
            outputChatBox("Syntax: /" .. cmd .. " [team name]", player, 255, 180, 10, false) -- Returns this when the parameter has not been entered 
        end 
    end 
) 

Link to comment

Try this code (i have not tested it)

function createMyTeam(player,cmd,...,c1,c2,c3) -- Discribes the command 
    local text = table.concat({...}, " ")  -- Get text for team name 
    myTeam = createTeam(...,c1,c2,c3) -- Create the team 
    setPlayerTeam(player,myTeam) -- Set Play to the team that they have just created 
end -- ends function 
addCommandHandler("createteam", createMyTeam) -- Command 
--[[ 
The command Syntax is /createteam teamname colorRed colorGreen colorBlue 
For Example: 
/createteam 255 255 0 
--]] 

Link to comment
Try this code (i have not tested it)
function createMyTeam(player,cmd,...,c1,c2,c3) -- Discribes the command 
    local text = table.concat({...}, " ")  -- Get text for team name 
    myTeam = createTeam(...,c1,c2,c3) -- Create the team 
    setPlayerTeam(player,myTeam) -- Set Play to the team that they have just created 
end -- ends function 
addCommandHandler("createteam", createMyTeam) -- Command 
--[[ 
The command Syntax is /createteam teamname colorRed colorGreen colorBlue 
For Example: 
/createteam 255 255 0 
--]] 

Your code is wrong in many aspects. You are not experienced enough to post such simple scripts without testing and confusing people. Please don't post incorrect code to confuse people even more.

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