Jump to content

Help with shout command


FR0314

Recommended Posts

I'm trying to make a script where you can shout if you want more people to hear what you are saying. The problem is no matter what I say only the first part displays.
Like if I try to say: "/s Hey what are you doing?" It comes back as HEY!

function shout( source, command, ... )
	outputDebugString ( ... , 1)
	local message = table.concat( {...}, " " )
	outputDebugString ( ... , 1)
	outputChatBox(..., source)
	local x, y, z = getElementPosition(source)
    local radius = createColSphere(x, y, z, 100)
    local nearplayers = getElementsWithinColShape(radius, "player")
    destroyElement(radius)
        
    for _, player in ipairs(nearplayers) do
        if getElementDimension(player) == getElementDimension(source) then
			local chatter = pregReplace( getPlayerName(source), '_', ' ' )
			outputChatBox(..., player, 255, 255, 255, true)
			local MESSAGE = string.upper( ... )
            outputChatBox(chatter..' ordítja: '..MESSAGE, player, 255, 255, 255, true)
        end
    end
end

addCommandHandler ( "s", shout)

What could be the problem?

Link to comment

Hello FR0314,

how about you try changing...

...
	local message = table.concat( {...}, " " )
	outputDebugString ( ... , 1)
...

to...

...
	local message = table.concat( {...}, " " )
	outputDebugString ( message , 1)
...

Even if help is no longer needed, it will help other people.

Link to comment
3 hours ago, FR0314 said:

The debugstring was just for me to check where is the problem. I took all of the out of the code.
But thanks for the recommendation!

You took out the call to outputChatBox aswell? My hint was mainly related to that function call as it relates to your inquiry. Thus the dots have to be replaced by the "message" variable too.

Link to comment
addCommandHandler ( "s",
function(source, cmd, ...)
	local message = table.concat({ ... }, " ")
	local x, y, z = getElementPosition(source)
    local radius = createColSphere(x, y, z, 100)
    local nearplayers = getElementsWithinColShape(radius, "player")
    destroyElement(radius)
        
    for _, player in ipairs(nearplayers) do
        if getElementDimension(player) == getElementDimension(source) then
			local chatter = pregReplace( getPlayerName(source), '_', ' ' ) or '#cf7ee6[FroMTA - Admin] #db5151'..getPlayerName(source)
			local MESSAGE = string.upper(message)
            outputChatBox(chatter..' ordítja: '..MESSAGE, player, 255, 255, 255, true)
        end
    end
end)

This is my new code; I only changed ... to message in string upper.
This code works just as I expect it, thanks for the help!

  • Like 1
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...