Jump to content

MTA:paradise rp problem


AeroXbird

Recommended Posts

Hello mta forums,

i've been building on the mta:paradise rp core from mabako, but i have stumbled upon a huge problem that i just cant seem to fix.

function takeKey( element, slot, valueID ) 
    -- we need a base to work on 
    if load( element ) then 
        -- check for existance of the slot 
        if data[ element ].items[ slot ] then 
            -- only continue if we could delete it 
            local success, error = exports.sql:query_free( "DELETE FROM items WHERE `value` = " .. valueID ) 
            if success then 
                -- remove it from the table, shift following items to pos=pos-1 
                table.remove( data[ element ].items[slot], valueID ) 
                 
                -- tell everyone who wants to know 
                notify( element ) 
                 
                -- we managed it 
                return true 
            end 
            return false, "MySQL Query failed" 
        end 
        return false, "No such slot exists" 
    end 
    return false, "Unable to load element" 
end 
  

I have gotten to fix the query stuff, but what i just cant seem to figure out is the table.remove.

What i want it to do is to remove an entry in the data[ element ].items[slot]

and that entry equals the value: valueID, wich i used in the query.

But i cant seem to figure out how to do that.

I hope you guys can help me, AeroXbird

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