elnelson
Lunaria World Dev
Hello, otlanders im experiencing an issue, i have a reward shop (like Premium shop with npc) so, when i buy an ítem the npc ignores capacity and give ítems even when capacity is overloaded.
heres my lua scripts (tfs 0.4 rev 3884)...
heres my lua scripts (tfs 0.4 rev 3884)...
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() 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 = {
[6533] = 200,
[2268] = 50,
[2273] = 5,
[2293] = 8,
[2304] = 3,
[2313] = 4,
[2274] = 4,
[2315] = 4,
[2278] = 30,
[2169] = 20,
[7620] = 5,
[7589] = 8,
[7590] = 10,
[7618] = 5,
[7588] = 8,
[7591] = 10,
[8473] = 15,
[8472] = 10,
[7589] = 5,
[7443] = 10,
[7440] = 10,
[7439] = 10,
[12466] = 35,
[2167] = 20,
[2207] = 20,
[2208] = 20,
[2269] = 20,
[2166] = 20,
[2164] = 50,
[2165] = 50,
[2168] = 50,
[2216] = 50,
[2789] = 10
}
local onBuy = function(cid, item, subType, amount, inBackpacks)
if t[item] and getAccountPoints(cid) < t[item] then
selfSay("You need "..t[item].." reward points to buy this item.", cid)
else
doAccountRemovePoints(cid, t[item])
doPlayerAddItem(cid, item, 10)
selfSay("Here your item! (total points: " .. getAccountPoints(cid) .. ")", cid)
end
return true
end
if (msgcontains(msg, 'tutorial') or msgcontains(msg, 'help'))then
doPlayerPopupFYI(cid, "[Tutorial]: Reward shop!\
\
1-.You must have atleast 50 gp in your backpack (to enable trade).\
2-.You may trade your !points here.\
\
use !online to see your time.\
")
setPlayerStorageValue(cid, 444447910, 1)
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
if getPlayerStorageValue(cid, 444447910) == -1 then
doPlayerPopupFYI(cid, "[Tutorial]: Reward shop!\
\
1-.You must have atleast 50 gp in your backpack (to enable trade).\
2-.You may trade your !points here.\
\
use !online to see your time.\
")
setPlayerStorageValue(cid, 444447910, 1)
end
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: