Wezza
lua nOOb
- Joined
- May 31, 2008
- Messages
- 2,278
- Reaction score
- 31
The error:
The lever buy and lever roll works great.. but when the player is out of money it sends this error, and I want when player doesnt have money it send message you are out of money.
thanks in advance, waiting for u Cyko ;D
here is the lever_buy:
[Error - Action Interface]
data/actions/scripts/lever_buy.lua: onUse
Description:
data/actions/scripts/lever_buy.lua:40: attempt to call global 'warnPlayer' (a nil value)
stack traceback:
[29/06/2011 17:22:50] data/actions/scripts/lever_buy.lua:40: in function <data/actions/scripts/lever_buy.lua:14>
The lever buy and lever roll works great.. but when the player is out of money it sends this error, and I want when player doesnt have money it send message you are out of money.
thanks in advance, waiting for u Cyko ;D
here is the lever_buy:
LUA:
local itemList = {
[2261] = {6000, 15},
[2293] = {2000, 20},
[2268] = {5000, 40},
[2273] = {2000, 100},
[2173] = {40000, 1},
[2304] = {2000, 30},
[2305] = {7000, 5},
[2313] = {2000, 50},
[2265] = {1000, 100}
}
function onUse(cid, item)
if item.itemid == 1945 then
doTransformItem(item.uid, 1946)
else
doTransformItem(item.uid, 1945)
end
local pos = getCreaturePosition(cid)
local itemid = getThingfromPos({x=pos.x + 3, y=pos.y, z=pos.z, stackpos=2}).itemid
if doComparePositions(getCreaturePosition(cid), {x=836,y=702,z=7}) then
local buyItem = itemList[itemid]
if buyItem then
if getPlayerMoney(cid) >= buyItem[1] then
local uid = doPlayerAddItem(cid, itemid, 1)
if uid then
doChangeTypeItem(uid, buyItem[2])
doPlayerRemoveMoney(cid, buyItem[1])
doSendMagicEffect({x=pos.x + 3, y=pos.y, z=pos.z, stackpos=2}, CONST_ME_GIFT_WRAPS)
doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a " .. getItemNameById(itemid) .. " with " .. buyItem[2] .. " charges for " .. buyItem[1] .. " gold coins.")
else
warnPlayer(cid, "Not enough room.")
end
else
warnPlayer(cid, "This rune costs " .. buyItem[1] .. " gold coins.")
end
end
else
warnPlayer(cid, "You must stand infront of the lever.")
end
return TRUE
end
Last edited: