[20:12:18.359] [Error - Action Interface]
[20:12:18.359] data/actions/scripts/bag.lua:<putting space here because emote> onUse
[20:12:18.359] Description:
[20:12:18.359] data/actions/scripts/bag.lua:2: attempt to call global 'Player' (a nil value)
[20:12:18.359] stack traceback:
[20:12:18.359] data/actions/scripts/bag.lua:2: in function <data/actions/scripts/bag.lua:1>
When I right click the tree to receive the quest loot I get the error above.
In the scripts folder I have 'bag.lua' saved.
bag.lua:
Code:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey) --This is mostly used to state the script executes onUse (right-clicking an object)
local player = Player(cid)
local storage = 1500 --This is a variable, it contains the prefix 'local' so that it doesn't interfere in another script, this is a value we will set into the player once he receives the reward, as we don't them to keep receiving it after the first time
if player:getStorageValue(storage) == -1 then --Here we just check if the Player has the storage value we mentioned before, -1 means that the player DOESN'T have the value
local backpack = player:addItem(1987, 1) --This variable contains a function, 'addItem', I named it backpack just to remember i'm refering to a container. 1987 stands for the ID of the item, in this case, a bag, the 1 stands for the amount of items (Or charges if you select a rune)
backpack:addItem(2120, 1) --Self explanatory, adds item id 2120 (Rope) to the container 'backpack'
backpack:addItem(2643, 1) --Leather boots
backpack:addItem(1950, 1):setAttribute(ITEM_ATTRIBUTE_TEXT, 'Here lies the text.') --Here we give an item, in this case a book, containing an ATTRIBUTE, in this case, TEXT.
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a mysterious bag...") --This is just a message so the player knows something happened.
player:setStorageValue(storage, 1) --We set the storage value to 1
else --What happens if the value is already assigned to that player (He already received the reward)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There's nothing of interest here.") --Only shows this message
end
return true
end
In the actions.xml I have:
Code:
<action uniqueid="1500" script="bag.lua"/>
And in RME I have the tree set to UID = 1500.
I can't get it to work! Please help!