Jump to content

little script, little help needed


Stylez

Recommended Posts

hey i created this function, but i it doesnt work.. every time when i /team blue nick it outputs Wrong syntax : /team [teamName] [playerToAdd]"

function adminCanAddTeam(thePlayer, command, playerName, teamName) 
    if hasObjectPermissionTo(thePlayer, "function.ban", true) then 
        local playerToAdd = getPlayerFromName(playerName) 
        if playerToAdd then 
            outputChatBox(playerToAdd) 
            local isCreated = getTeamFromName(teamName) 
            if isCreated then 
                outputChatBox("team exists", thePlayer, 255,150,0) 
            else 
                createTeam(teamName) 
                setPlayerTeam(playerToAdd, teamName) 
                outputChatBox(playerToAdd) 
            end 
        else 
            outputChatBox("Wrong syntax : /team [teamName] [playerToAdd]", thePlayer, 255, 150,0) 
        end 
    end 
end 
addCommandHandler("team", adminCanAddTeam) 
  

Link to comment

Hello Stylez!

Try this :

addCommandHandler('team', 
    function ( player,command,team,traget ) 
        if not traget or not team then return outputChatBox ( 'Wrong syntax : /team [teamName] [playerToAdd]',player,255,150,0 ) end 
        if not hasObjectPermissionTo( player, "function.ban", true ) then return false end 
        local returnTraget = getPlayerFromName ( tostring ( traget ) ) 
        if getTeamFromName ( tostring ( team ) ) and returnTraget then 
            outputChatBox ( 'Team Found!' ) 
            outputChatBox ( getPlayerName ( returnTraget ) ) 
        else 
            new = createTeam ( tostring ( team ) )  
            setPlayerTeam ( returnTraget,new ) 
            outputChatBox ( 'Team Not Found Team Has Been Created!' ) 
            outputChatBox ( getPlayerName ( returnTraget ) ) 
        end 
    end 
) 

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