Jump to content

Chat Output -.-


MasterTobi

Recommended Posts

Hey i have a porblem

the code:

  
function hey(source,command,parameter) 
outputChatBox("Player 1 say: "parameter,source) 
end 
addCommandHandler("live",live) 
  

if i type /hey test test test test in the Chatbox then comes in the Chatbox test and not test test test test

i have to change the function to function hey(source,command,parameter,parameter2,parameter3,parameter4)

but this is f**k :D

if i type more dann parameter4 also /hey 1 2 3 4 5 then comes Player 1 say : 1 2 3 4

and i need the 1 2 3 4 in one parameter

this goes???

i hope you understand me i´m a german player :)

thx

MasterTobi

Link to comment

First of all, read wiki over and over again! It's the first source where you should get all the info from!

-- DO NOT USE source IN FUNCTION PARAMETERS! 
function hey( plr, command, ... )  
    -- ... <- 3 dots represent rest of the parameters passed to the function  
    --       (in this case all the words that player types after /live) 
    outputChatBox("Player 1 say: " .. table.concat( arg ), plr ) 
end 
addCommandHandler("live", hey) 

Link to comment
I'm just clearing it up shouldn't it be table.concat({...}, " ") instead of table.concat(arg, " ") ? Does arg already mean all the arguments in a table?

That's what he wants, concatenate all passed parameters after the command as one string. The "arg" variable represents the table of parameters passed by the variable argument list "..." in the function call. So table.concat(arg, " ") is correct as well.

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