Jump to content

There's only this one thing, I've never known...


Maurize

Recommended Posts

Posted
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!(:

Guest Guest4401
Posted
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 
) 

Posted (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 by Guest
Guest Guest4401
Posted
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

Guest Guest4401
Posted (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 by Guest4401
Posted
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.

Posted

If you're struggling, there is an example on the wiki how to show all the text from commands anyway. Use wiki please.

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