Jump to content

why this didn't work?


Sparrow

Recommended Posts

Posted
why when I do this:
  
local getTeam = getTeamName (source) 
  

it comes error:

Bad 'team' pointer @ 'getTeamName'

Try this :

    
 local team = getTeamFromName(teamname) 
    if team and getPlayerTeam(player) == team then 

Posted

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) 
  

Posted
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 ) 
  

Posted

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.

Posted
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 ) 

Posted

well , as far i know /setteam is an command , on freeroam servers...

So there are 2 scripts :

The command : Error:'Test' matches no players.

You're script : Aleardy in a team

Posted

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 ) 

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

Posted

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 ) 

Posted

another question please,

when I use /changeteam command, I get another team and I didn't get his skin,

so I must add

setElementModel (player, team) 

after

if setPlayerTeam ( player, getTeamFromName( name ) ) then 

Posted

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 ) 

Posted

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 ) 

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