Jump to content

why this didn't work?


Sparrow

Recommended Posts

my code:

  
function setMyTeam(source) 
    local getTeam = getTeamName (source) 
    if (getTeam) then 
        outputChatBox("Your team now is "..getTeamName..".", source, 0, 255, 0) 
    else 
        outputChatBox("Bara nayek.", source, 255, 0, 0) 
    end 
end 
addCommandHandler ("setteam", setMyTeam) 
  

Link to comment
function setMyTeam( player ) 
    local team = getPlayerTeam( player ) 
    if team then 
        outputChatBox( "Your team now is "..getTeamName( team )..".", player, 0, 255, 0 ) 
    else 
        outputChatBox( "Bara nayek.", player, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "setteam", setMyTeam ) 
  

Link to comment

hm, I want it to set the player in team after he type /setteam

  
function setMyTeam( player ) 
    local team = getPlayerTeam( player ) 
    if team then 
        setPlayerTeam (player, team) 
        outputChatBox( "Your team now is "..getTeamName( team )..".", player, 0, 255, 0 ) 
    else 
        outputChatBox( "Bara nayek.", player, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "setteam", setMyTeam ) 
  

it didn't set me in team.

Link to comment
function setMyTeam( player,_,name ) 
    if name then 
        local team = getPlayerTeam( player ) 
        if not team then 
            if setPlayerTeam ( player, getTeamFromName( name ) ) then 
                outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) 
            else 
                outputChatBox( "Can't set to team.", player, 255, 0, 0 ) 
            end  
        else 
            outputChatBox( "Alreadly in team.", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox( "SYNTAX: /setteam [team name].", player, 255, 0, 0 ) 
    end  
end 
addCommandHandler ( "setteam", setMyTeam ) 

Link to comment

this didn't work, I changed the command, but it says that I'm Alreadly in team

function setMyTeam( player,_,name ) 
    if name then 
        local team = getPlayerTeam( player ) 
        if not team then 
            if setPlayerTeam ( player, getTeamFromName( name ) ) then 
                outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) 
            else 
                outputChatBox( "Can't set to team.", player, 255, 0, 0 ) 
            end  
        else 
            outputChatBox( "Alreadly in team.", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox( "SYNTAX: /newteam [team name].", player, 255, 0, 0 ) 
    end  
end 
addCommandHandler ( "newteam", setMyTeam ) 

Link to comment
function setMyTeam( player, cmd, ... ) 
    local name = table.concat({...}, " ") 
    if (name and name ~= "") then 
        local team = getPlayerTeam( player ) 
        if (not team) then 
            if setPlayerTeam ( player, getTeamFromName( name ) ) then 
                outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) 
            else 
                outputChatBox( "Can't set to team.", player, 255, 0, 0 ) 
            end  
        else 
            outputChatBox( "Alreadly in team.", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox( "SYNTAX: /newteam [team name].", player, 255, 0, 0 ) 
    end  
end 
addCommandHandler ( "changeteam", setMyTeam ) 

I think the command "/newteam" is part of the Admin panel, that's why I renamed it to "/changeteam".

Link to comment

That's because you added to check for team..

function setMyTeam( player, cmd, ... ) 
    local name = table.concat({...}, " ") 
    if (name and name ~= "") then 
        local team = getPlayerTeam( player ) 
        if setPlayerTeam ( player, getTeamFromName( name ) ) then 
            outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) 
        else 
            outputChatBox( "Can't set to team.", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox( "SYNTAX: /newteam [team name].", player, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "changeteam", setMyTeam ) 

Link to comment

I mean:

function setMyTeam( player, cmd, ... ) 
    local name = table.concat({...}, " ") 
    if (name and name ~= "") then 
        local team = getPlayerTeam( player ) 
        if setPlayerTeam ( player, getTeamFromName( name ) ) then 
            setElementModel (player, team) 
            outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) 
        else 
            outputChatBox( "Access Denied.", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox( "SYNTAX: /changeteam [team name].", player, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "changeteam", setMyTeam ) 

Link to comment

So, I guess you mean a table with team names and skins?

Like this:

local skins = { 
     ["Team 1"] = 299, 
     ["Team 2"] = 288, 
} 
  
function setMyTeam( player, cmd, ... ) 
    local name = table.concat({...}, " ") 
    if (name and name ~= "") then 
        local team = getPlayerTeam( player ) 
        if setPlayerTeam ( player, getTeamFromName( name ) ) then 
            setElementModel (player, tonumber(skins[getTeamName(getPlayerTeam(player))]) or 0) 
            outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) 
        else 
            outputChatBox( "Access Denied.", player, 255, 0, 0 ) 
        end 
    else 
        outputChatBox( "SYNTAX: /changeteam [team name].", player, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "changeteam", setMyTeam ) 

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