Maurize Posted June 7, 2012 Share Posted June 7, 2012 addCommandHandler( "sms", function( player, cmd, name, text ) local target = getPlayerFromName( name ) if ( target ) and ( text ) then outputChatBox( getPlayerName( player ).." sendet: "..text..".", target, 0, 200, 200 ) outputChatBox( "SMS erfolgreich gesendet an "..name..".", player, 0, 200, 200 ) end end ) No words. Self-explain. Need to get function variable for text... If I use "text", it only gets the first word of the sms text message. So I know you know how to solve this!(: Link to comment
Guest Guest4401 Posted June 7, 2012 Share Posted June 7, 2012 addCommandHandler("sms", function(player,cmd,name,...) local target = getPlayerFromName(name) local text = table.concat(arg," ") if target and text then outputChatBox(getPlayerName(player).." sendet: "..text..".",target,0,200,200) outputChatBox("SMS erfolgreich gesendet an "..name..".",player,0,200,200) end end ) Link to comment
Anderl Posted June 7, 2012 Share Posted June 7, 2012 (edited) addCommandHandler("sms", function(player,cmd,name,...) local target = getPlayerFromName(name) local text = table.concat(arg," ") if target and text then outputChatBox(getPlayerName(player).." sendet: "..text..".",target,0,200,200) outputChatBox("SMS erfolgreich gesendet an "..name..".",player,0,200,200) end end ) That's wrong, I think. addCommandHandler ( "sms", function ( pPlayer, chCommand, chName, ... ) if ( chName and ... ) then local pTarget = getPlayerFromName ( chName ); local chText = table.concat ( { ... }, " " ); if ( pTarget ) then outputChatBox ( getPlayerName ( pPlayer ) .. " sendet: " .. chText .. ".", pTarget, 0, 200, 200 ); outputChatBox ( "SMS erfolgreich gesendet an " .. pTarget .. ".", pPlayer, 0, 200, 200 ); end else outputChatBox ( "SATZBAU: sms [ZIEL] [NACHRICHT]", pPlayer, 255, 0, 0 ); end end ) Edited June 7, 2012 by Guest Link to comment
Guest Guest4401 Posted June 7, 2012 Share Posted June 7, 2012 addCommandHandler("sms", function(player,cmd,name,...) local target = getPlayerFromName(name) local text = table.concat(arg," ") if target and text then outputChatBox(getPlayerName(player).." sendet: "..text..".",target,0,200,200) outputChatBox("SMS erfolgreich gesendet an "..name..".",player,0,200,200) end end ) That's wrong. Have you tested it before saying so? http://www.lua.org/pil/5.2.html Link to comment
Anderl Posted June 7, 2012 Share Posted June 7, 2012 Yes, I tested. It's wrong. As I saw in that page, arg is a table containing all function parameters. Link to comment
Guest Guest4401 Posted June 7, 2012 Share Posted June 7, 2012 (edited) Yes, I tested. It's wrong. It's not wrong. {...} is same as arg in this case. local pTarget = getPlayerFromName ( pPlayer ); It's wrong. getPlayerFromName gets player element from string But pPlayer is player element. outputChatBox ( "SMS erfolgreich gesendet an " .. pTarget .. ".", pPlayer, 0, 200, 200 ); Attempt to concatenate on pTarget a userdata value. It should be getPlayerName(pTarget) Edited June 7, 2012 by Guest4401 Link to comment
Anderl Posted June 7, 2012 Share Posted June 7, 2012 local pTarget = getPlayerFromName ( pPlayer ); It's wrong. getPlayerFromName gets player element from string But pPlayer is player element. Ok, I've put wrong argument on it 'cause I did it fast but don't change the conversation. Link to comment
50p Posted June 7, 2012 Share Posted June 7, 2012 If you're struggling, there is an example on the wiki how to show all the text from commands anyway. Use wiki please. 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