Jump to content

Markers and sqlite


DLmass

Recommended Posts

Hi, I'd like to fix so I can delete markers with a command, I tried to do it but I cannot fix it. How can I solve this?

  
local con = dbConnect("sqlite", "marker.db") 
dbExec(con, "CREATE TABLE IF NOT EXISTS marker ('x', 'y', 'z', 'dim', 'int')") 
  
function addMarker(player) 
    local x,y,z = getElementPosition(player) 
    local dim = getElementDimension(player) 
    local int = getElementInterior(player) 
    dbExec(con, "INSERT INTO marker VALUES (?, ?, ?, ?, ?)", x, y, z-1, dim, int) 
    local marker = createMarker(x, y, z - 1, "cylinder", 1, 255, 0, 0, 150) 
    setElementDimension(marker, dim) 
    setElementInterior(marker, int) 
end 
addCommandHandler("am", addMarker) 
  
function deleteMarker(player) 
    local x, y, z = getElementPosition(player) 
    dbExec(con, "DELETE FROM marker WHERE x=? AND y=? and z=?", x, y, z) 
end 
addCommandHandler("dm", deleteMarker) 
  

Link to comment
Well, that won't work, because when you create the marker, you take 1 from the Z position, but when you try to delete it, you don't add 1 to the Z position.

I almost got what you mean. But still very confused lol

EDIT: Still haven't solved it!

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