SweetyWolf Posted June 19, 2010 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?
dzek (varez) Posted June 19, 2010 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 Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
SweetyWolf Posted June 19, 2010 Author 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!
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