SweetyWolf Posted June 19, 2010 Share Posted June 19, 2010 Hello. I was created this code: function WhisperChat( source, cmd, ident, text ) if (text) then local playeronline = 0 for id, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "playerid" ) == tonumber(ident) ) then outputChatBox ("" .. getPlayerName(player) .. " whisper: "..tostring(text).." ",player, 55,255,127 ) local x,y,z = getElementPosition( source ) playeronline = 1 end end if (playeronline == 0) then outputChatBox (" This player offline ",source, 255,255,127 ) end else outputChatBox ("Correct: /w [player id] text ", 255,255,127 ) end end addCommandHandler ("w", WhisperChat) But when i type, for example, /w 13 hello man, i see only - SweetyWolf whisper: hello. Without second and another words. Can you help me? Where's problem? Link to comment
dzek (varez) Posted June 19, 2010 Share Posted June 19, 2010 every command can have more than one parameter.. each "words" you are separating by space ("hello" "man") are arguments (it's all on wiki!), so you will have to do something like (it's on wiki too!): function handlerFunction(playerSource, commandName, ...) if playerSource then local parametersTable = {...} local stringWithAllParameters = table.concat(parametersTable, " ") outputChatBox("Parameters passed: "..stringWithAllParameters, playerSource) end end addCommandHandler("my_command", handlerFunction) conclusion: read more wiki Link to comment
SweetyWolf Posted June 19, 2010 Author Share Posted June 19, 2010 every command can have more than one parameter.. each "words" you are separating by space ("hello" "man") are arguments (it's all on wiki!), so you will have to do something like (it's on wiki too!): function handlerFunction(playerSource, commandName, ...) if playerSource then local parametersTable = {...} local stringWithAllParameters = table.concat(parametersTable, " ") outputChatBox("Parameters passed: "..stringWithAllParameters, playerSource) end end addCommandHandler("my_command", handlerFunction) conclusion: read more wiki Thanks! 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