Jump to content

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


Maurize

Recommended Posts

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
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
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
Link to comment
Guest Guest4401
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
Guest Guest4401
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
Link to comment
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

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