Jump to content

Col Shape help


Recommended Posts

2 hours ago, Snakegold said:

didn't work

-- First, create a variable to store the size of the colshape
local colshapeSize = 5 -- Let's assign a default size of 5 units

-- Function to create a square colshape
function createSquareColshape(x, y, z)
    local size = colshapeSize -- Get the colshape size

    local colshape = createColRectangle(x - size / 2, y - size / 2, size, size) -- Create the square colshape

    return colshape -- Return the created colshape
end

-- Function to adjust the colshape size
function setColshapeSize(newSize)
    colshapeSize = newSize -- Set the new size
end

-- Create a square colshape for testing purposes
addCommandHandler("squarecolshape", function(player)
    local x, y, z = getElementPosition(player) -- Get the position of the player executing the command
    local colshape = createSquareColshape(x, y, z) -- Create the square colshape
    outputChatBox("Square colshape created!", player) -- Send a message indicating the colshape is created
end)

-- Add a command to adjust the size
addCommandHandler("colshapesize", function(player, cmd, newSize)
    newSize = tonumber(newSize) -- Convert the argument to a number
    if newSize then
        setColshapeSize(newSize) -- Set the colshape size
        outputChatBox("Colshape size set to " .. newSize .. "!", player) -- Send a message indicating the size is set
    else
        outputChatBox("Invalid size. Please enter a number!", player) -- Send an error message for an invalid size
    end
end)

 

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