Jump to content

[SOLVED]A extra team chat


Khtsjefen

Recommended Posts

Hey, I have made this code:

addCommandHandler("r", fbir) 
  
function fbir( thePlayer,_,text ) 
    local theTeam = getTeamFromName ( FBI ) 
        local text = table.concat( {text}, " " ) 
        local name = getPlayerName( thePlayer ) 
    if ( theTeam ) then 
        local players = getPlayersInTeam ( FBI ) 
        for players, players in ipairs ( players ) do 
                     outputChatBox ("(FBI RADIO) "..tostring( name ).." says: "..tostring( text ), players, 0, 0, 205, true) 
        end 
    end 
end 

It's gonna be a alternate teamchat, with command to /r, only available for a team called "FBI", but for some reason, I cant make it show for only them. As it is now, it wont show for anyone.

Help please?

Edited by Guest
Link to comment

try this

function fbir( thePlayer,_,text ) 
    local theTeam = getTeamFromName ( teamName ) 
        local text = table.concat( {text}, " " ) 
        local name = getPlayerName( thePlayer ) 
     for players, players in pairs( getPlayersInTeam ( FBI ) ) do 
                     outputChatBox ("(FBI RADIO) "..tostring( name ).." says: "..tostring( text ), players, 0, 0, 205, true) 
        end 
    end 
addCommandHandler("r", fbir) 

Link to comment
  
addCommandHandler("r", fbir) 
  
function fbir( thePlayer,_,text ) 
        local text = table.concat( text, " " ) 
        local name = getPlayerName( thePlayer ) 
        local team = getPlayerTeam 
    if ( team == "FBI" ) then 
        local players = getPlayersInTeam ( team ) 
                     outputChatBox ("(FBI RADIO) "..name .." says: "..text , players, 0, 0, 205, true) 
        end 
    end 
end 
  

Dear Skatchof , 1. That will output so many times , as the players in that team

2. outputChatBox doesn't needs "tostring" , it will convert it automaticly

Link to comment

 

 

GanJaRuleZ  you have Syntax Error the end line 12

 

Server side :

addCommandHandler("r", fbir) 
  
function fbir( thePlayer,_,text ) 
        local text = table.concat( text, " " ) 
        local name = getPlayerName( thePlayer ) 
        local team = getPlayerTeam 
    if ( team == "FBI" ) then 
        local players = getPlayersInTeam ( team ) 
                     outputChatBox ("(FBI RADIO) "..name .." says: "..text , players, 0, 0, 205, true) 
        end 
    end 

Link to comment

@@sckatchof Your code is wrong. You can't attack a command to a nil function. And you need use a for-loop to get all players in team.

Here:

addCommandHandler ( 'f',  
    function ( player, command, ... ) 
        local text = table.concat ( { ... }, " " ) 
        if ( getPlayerTeam ( player ) == "FBI" ) then 
            for _, players in ipairs ( getPlayersInTeam ( getPlayerTeam ( player ) ) ) do 
                outputChatBox ( "( FBI RADIO ) " .. getPlayerName ( player ) .. " says: " .. text, players, 0, 0, 205, true ); 
            end 
        end 
    end 
) 

Edited by Guest
Link to comment

Like this ?

  
function teamGet() 
local team = getPlayerTeam(source) 
outputChatBox(team,source,255,0,0,true) 
end 
  
function skinGet() 
local skin = getElementModel(source) 
outputChatBox(skin,source,255,0,0,true) 
end 
  
addCommandHandler("team",teamGet) 
addCommandHandler("skin",skinGet) 

Link to comment
function teamGet ( thePlayer ) 
    local team = getPlayerTeam ( thePlayer ) 
    local teamName = team and getTeamName ( team ) or "None" 
    outputChatBox ( teamName, thePlayer, 255, 0, 0, true ) 
end 
addCommandHandler ( "team", teamGet ) 
  
function skinGet ( thePlayer ) 
    local skin = getElementModel ( thePlayer ) 
    outputChatBox ( skin, thePlayer, 255, 0, 0, true ) 
end 
addCommandHandler ( "skin", skinGet ) 

Your errors:

1: 'source' is nil there, you forgot to define the player argument.

2: You forgot to get the name of the player team.

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