Tbol
Well-Known Member
- Joined
- Apr 7, 2019
- Messages
- 625
- Reaction score
- 71
Hello trying to some changes in a code. But for some reason it doesnt give an item from the table even when there is no errors. It should give and item and remove 30 points from storage 25335 and it adds points when it should remove them. TFS 1.2
LUA:
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
local items = {
item1 = {8266} -- [ITEMID]
}
local counts = {
count1 = {30, 1} -- [PRICE, ITEM AMOUNT]
}
function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'event boost') then
if player:getStorageValue(25335) >= counts.count1[1] then
player:setStorageValue(25335, player:getStorageValue(25335) + counts.count1[1])
player:addItem(cid, items.item1[2], counts.count1[2])
selfSay('You just swap '.. counts.count1[1] ..' '.. getItemName(items.item1[1]) ..' for '.. counts.count1[2] ..' '.. getItemName(items.item1[2]) ..'.', cid)
else
selfSay('You need '.. counts.count1[1] ..' '.. getItemName(items.item1[1]) ..'.', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())