CesarZ
Well-Known Member
- Joined
- Sep 20, 2012
- Messages
- 268
- Solutions
- 4
- Reaction score
- 63
Hey Guys i have been working on my coding for the past months i have been working on some stuff, im needing a little help here. im trying transform the henricus.lua to a NPC that charge your boots. first im starting with the soft boots to see if it succeed. im Using TFS 1.3
so this is what i have done.
its not set up right. because its collecting and adding at the same time without checking the collection first and then adding
its giving me a nil error when i say yes.
my plan was
so this is what i have done.
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local player = Player(cid)
if(msgcontains(msg, "charge soft boots")) then
npcHandler:say("Would you like to charge yo soft boots for 10000 gold? you need to have 1 empty soft boot and 10000 gold.")
if (msgcontains(msg, "Yes")) then
player:removeItem(6132) -- empty soft boots taken away
player:removeMoney(10000) -- collect the money
player:addItem(2640) -- add the new boots
else
npcHandler:say("Come back when you have everything i asked for")
end
return true
end
end
npcHandler:setMessage(MESSAGE_GREET, "Hello would like to {charge soft boots} today? |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good luck!, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Code:
player:addItem(2640)
its giving me a nil error when i say yes.
my plan was
INI:
if (players say("charge soft boots")) then
npc:say("Would you like to charge you soft for ect ect ect?")
if (player:say("yes")) then
removeItemfromplayer(itemid)
removemoney(amount)
additem(new softboots charged item id)
else
npc:say("sorry you suck on money")
end
return true
end