Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function doPlayerDeleteInventoryItem(name, slot)
- local resultId = db.storeQuery('SELECT `id` FROM `players` WHERE `name` = ' .. db.escapeString(name))
- if not resultId then
- return result.free(resultId)
- end
- local guid = result.getNumber(resultId, "id")
- result.free(resultId)
- resultId = db.query(('DELETE FROM `player_items` WHERE `player_id` = %u AND `pid` = %u'):format(guid, slot))
- return resultId
- end
- function onSay(player, words, param)
- local split = param:split(",")
- local target = Player(split[1])
- local slot = tonumber(split[2])
- if not slot or slot < 1 or slot > 11 then
- return not player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The second parameter is wrong or has a bad slot index.")
- end
- if target then
- local slotItem = target:getSlotItem(slot)
- if slotItem then
- slotItem:remove()
- return not player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The item was deleted successfully.")
- end
- return not player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "There is no item to delete.")
- elseif not doPlayerDeleteInventoryItem(split[1], slot) then
- return not player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "No items could be deleted.")
- end
- return not player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The item was deleted successfully.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement