Recommended Posts

Hi! I wanted to create a broadcast script and i've got this error:

attempt to concatenate local 'msg' (a userdata value)

server.lua

function ad (msg)
    outputChatBox ( "#fbe0ff[Hiradó]: " .. msg .. getRootElement(), 255, 255, 255, true )
end
addCommandHandler ("hirado", ad)

 

and i don't know what the problem is.

 

Sorry the link for scripting subforum is doesn't works for me.

Share this post


Link to post

That's an easy fix. You don't have to concatenate the end of the string if it's not followed by anything.

 

function ad (msg)
    outputChatBox ( "#fbe0ff[Hiradó]: " .. msg, getRootElement(), 255, 255, 255, true )
end
addCommandHandler ("hirado", ad)

This will work. 

 

If you want to continue the string after msg, here's how it would look:

function ad (msg)
    outputChatBox ( "#fbe0ff[Hiradó]: " .. msg .. " and yeah", getRootElement(), 255, 255, 255, true )
end
addCommandHandler ("hirado", ad)

 

Share this post


Link to post
28 minutes ago, keymetaphore said:

That's an easy fix. You don't have to concatenate the end of the string if it's not followed by anything.

 


function ad (msg)
    outputChatBox ( "#fbe0ff[Hiradó]: " .. msg, getRootElement(), 255, 255, 255, true )
end
addCommandHandler ("hirado", ad)

This will work. 

 

If you want to continue the string after msg, here's how it would look:


function ad (msg)
    outputChatBox ( "#fbe0ff[Hiradó]: " .. msg .. " and yeah", getRootElement(), 255, 255, 255, true )
end
addCommandHandler ("hirado", ad)

 

Thansk very much!

  • Like 1

Share this post


Link to post

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.