Need some help with my !aol script which errors out.
It looks good to me, so I need some assistance as to why it does.
Code:
Error:
Thanks in advance.
It looks good to me, so I need some assistance as to why it does.
Code:
LUA:
local config = {
itemId = ITEM_AMULETOFLOSS,
price = 50000
}
local itemType = ItemType(config.itemId)
local itemWeight = itemType:getWeight()
local playerCap = player:getFreeCapacity()
function onSay(player, words, param)
if player:removeMoney(config.price) and playerCap >= itemWeight then
player:addItem(config.itemId)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought an amulet of loss for " .. config.price .. " gold coins.")
elseif playerCap < itemWeight then
player:sendCancelMessage("You can not recieve " .. itemType:getName() .. " weighing " .. itemWeight .. " oz, it is too heavy.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
else
player:sendCancelMessage("You do not have enough money, an amulet of loss costs " .. config.price .. " gold coins.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
end
Error:
Lua Script Error: [Test Interface]
data/talkactions/scripts/custom/buyaol.lua
data/talkactions/scripts/custom/buyaol.lua:8: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/talkactions/scripts/custom/buyaol.lua:8: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/custom/buyaol.lua
Thanks in advance.

Last edited: