LEDneotoxicity
New Member
- Joined
- Mar 3, 2017
- Messages
- 27
- Reaction score
- 3
Hi all, I'm attempting to create a lootbag system where the player can only have 1 bag in existence as a time, which can be created by saying "!lootbag create" and if the player ever loses the bag, they can say "!lootbag reset" to remove the existing flag.
I can't get either command to recognize, and the only thing that seems to work is the blank params check at the beginning of the script. Can someone tell me what I'm missing?
I can't get either command to recognize, and the only thing that seems to work is the blank params check at the beginning of the script. Can someone tell me what I'm missing?
Lua:
local config = {
backpackId = 2000,
hasLootbag = 0
}
function onSay(player, words, param)
local playerID = player:getGuid()
local owner = (playerID + 100)
local ownerName = player:getName()
if param == "" then
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You must enter a proper command. '!lootbag create' creates a new lootbag, '!lootbag reset' disowns your previous lootbag and allows you to create a new one.")
return TRUE
end
if param == "reset" then
hasLootbag = 0,
o:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
o:setActionId(0)
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have disowned your previous lootbag. You may now create a new one.")
return TRUE
elseif param == "create" then
if hasLootbag == 1 then
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You cannot have more than 1 lootbag. If you have lost your lootbag, say '!lootbag reset'")
elseif hasLootbag == 0 then
local backpack = doPlayerAddItem(player:getId(), config.backpackId, 1)
if (backpack ~= nil) then
doSetItemSpecialDescription(backpack, ownerName..' owns this lootbag.')
doSetItemActionId(backpack, owner)
hasLootbag = 1,
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have created a lootbag for "..config.cost.." gold.")
end
end
end
return TRUE
end