MadMOOK
Hoo
- Joined
- Apr 20, 2011
- Messages
- 802
- Reaction score
- 43
UPDATED THREAD...
Now my problem is It wont take points. the npc keeps telling me i need points and Ive got my tables in the function.lua what i need them to be...
My points is in znote_accounts under points...
There is no errors in my console when i try to purchase items from shop
I added this to lib function.. updated code in lib...
Now my problem is It wont take points. the npc keeps telling me i need points and Ive got my tables in the function.lua what i need them to be...
My points is in znote_accounts under points...
There is no errors in my console when i try to purchase items from shop
I added this to lib function.. updated code in lib...
Code:
function getAccountPoints(cid)
local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE `id` = " .. getPlayerGUID(cid))
return res:getDataInt("points") < 0 and 0 or res:getDataInt("points")
end
function doAccountRemovePoints(cid, count)
return db.executeQuery("UPDATE `znote_accounts` SET `points` = " .. getAccountPoints(cid) - count .. " WHERE `id` = " .. getPlayerGUID(cid))
end
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Premium shop" script="premiumshop.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="130" head="9" body="85" legs="9" feet="85" addons="1"/>
<parameters>
<parameter key="message_greet" value="Hello premium player. I got what you need."/>
<parameter key="message_farewell" value="Good bye."/>
<parameter key="message_walkaway" value="Farewell then.." />
</parameters>
</npc>
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local shopWindow = {}
local t = {
[2195] = 1,
[2493] = 25,
[2361] = 30,
[8851] = 20,
[8925] = 30,
[2640] = 50,
[2494] = 100,
[9932] = 50,
[2472] = 70,
[8931] = 100
}
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if t[item] and getAccountPoints(cid) < t[item] then
selfSay("You need "..t[item].." points to buy this item.", cid)
else
doAccountRemovePoints(cid, t[item])
doPlayerAddItem(cid, item)
selfSay("Here your item!", cid)
end
return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
for var, ret in pairs(t) do
table.insert(shopWindow, {id = var, subType = 0, buy = ret, sell = 0, name = getItemNameById(var)})
end
openShopWindow(cid, shopWindow, onBuy, onSell)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: