Khtsjefen Posted March 27, 2012 Share Posted March 27, 2012 (edited) 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 March 27, 2012 by Guest Link to comment
sckatchof Posted March 27, 2012 Share Posted March 27, 2012 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
GanJaRuleZ Posted March 27, 2012 Share Posted March 27, 2012 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
sckatchof Posted March 27, 2012 Share Posted March 27, 2012 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
drk Posted March 27, 2012 Share Posted March 27, 2012 (edited) @@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 March 27, 2012 by Guest Link to comment
Khtsjefen Posted March 27, 2012 Author Share Posted March 27, 2012 Thanks for answering, but none of them worked to me Server side btw, if it's needed for any of you. Continuing to try. Link to comment
drk Posted March 27, 2012 Share Posted March 27, 2012 Is your team FBI? You get any error? Link to comment
Khtsjefen Posted March 27, 2012 Author Share Posted March 27, 2012 A) Yes, I am on the team called "FBI". B) No, nothing in teh chat, nothing in the console. Link to comment
Khtsjefen Posted March 27, 2012 Author Share Posted March 27, 2012 Still nothing.. EDIT: Nothing appearing in the debug-box I mean, just a whole lot of stuff for a script I downloaded from the community. Link to comment
Khtsjefen Posted March 27, 2012 Author Share Posted March 27, 2012 Solved - Special thanks to Draken & Twisted. To Twisted since he sent me a fixed code over PM, and it worked. To Draken since he tried well, and the code Twisted send looked like it was a bit edited version of yours Link to comment
Twisted Posted March 27, 2012 Share Posted March 27, 2012 Your welcome it was from scratch btw but ok Link to comment
Khtsjefen Posted March 27, 2012 Author Share Posted March 27, 2012 Your welcome it was from scratch btw but ok Okay Link to comment
yMassai Posted March 27, 2012 Share Posted March 27, 2012 you could add to the script commands to get the Team and a skin? Link to comment
GanJaRuleZ Posted March 27, 2012 Share Posted March 27, 2012 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
Castillo Posted March 27, 2012 Share Posted March 27, 2012 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
yMassai Posted March 27, 2012 Share Posted March 27, 2012 this example would not be specific to a skin? for example, a command that adicionace the skin and the team. if we are talking about the player would enter the FBI / FBI and automatically add the Skin 286 e and the FBI Team. Link to comment
Castillo Posted March 27, 2012 Share Posted March 27, 2012 I've fixed GanJaRuleZ's script, which has two commands: /team and /skin, when you use them, it'll get your skin, team name and output it to the chat box. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now