Saint Spear
Veteran OT User
- Joined
- Jun 22, 2016
- Messages
- 1,547
- Solutions
- 18
- Reaction score
- 379
Hello guys, I am making an npc which should sell War Weapons
i place it in temple
and all works fine untill i click ok , it wont take to me ( it wont sell )
so here's lua, also i took it from eryn ( npc for supplies )
<?xml version="1.0" encoding="UTF-8"?>
<npc name="War NPC" nameDescription="War Items" script="waritems.lua" walkinterval="2000" floorchange="0" skull="red">
<health now="100" max="100"/>
<look type="130" head="39" body="122" legs="125" feet="57" addons="3"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I sell Weapons for War"/>
<parameter key="message_decline" value="Is |TOTALCOST| gold coins too much for you? Get out of here!"/>
</parameters>
</npc>
____________________________________________________________________________
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler
nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler
nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler
nCreatureSay(cid, type, msg) end
function onThink() npcHandler
nThink() end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'War Wand', 'Wand'}, 2453, 20000, 'War Wand')
shopModule:addBuyableItem({'War Star', 'Star'}, 7366, 20000, 'War Star')
shopModule:addBuyableItem({'War Sword', 'Sword'}, 6528, 20000, 'War Sword')
shopModule:addBuyableItem({'War Axe', 'Axe'}, 2454, 20000, 'War Axe')
local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
if(isSorcerer(cid) or isDruid(cid)) then
if(getPlayerStorageValue(cid, 30002) <= 0) then
selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
talkState[talkUser] = 1
else
selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
end
else
selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
end
elseif(msgcontains(msg, 'yes')) then
if(talkState[talkUser] == 1) then
doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
selfSay('Here you are young adept, take care yourself.', cid)
setPlayerStorageValue(cid, 30002, 1)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
selfSay('Ok then.', cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
i place it in temple
and all works fine untill i click ok , it wont take to me ( it wont sell )
so here's lua, also i took it from eryn ( npc for supplies )
<?xml version="1.0" encoding="UTF-8"?>
<npc name="War NPC" nameDescription="War Items" script="waritems.lua" walkinterval="2000" floorchange="0" skull="red">
<health now="100" max="100"/>
<look type="130" head="39" body="122" legs="125" feet="57" addons="3"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I sell Weapons for War"/>
<parameter key="message_decline" value="Is |TOTALCOST| gold coins too much for you? Get out of here!"/>
</parameters>
</npc>
____________________________________________________________________________
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler
function onCreatureDisappear(cid) npcHandler
function onCreatureSay(cid, type, msg) npcHandler
function onThink() npcHandler
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'War Wand', 'Wand'}, 2453, 20000, 'War Wand')
shopModule:addBuyableItem({'War Star', 'Star'}, 7366, 20000, 'War Star')
shopModule:addBuyableItem({'War Sword', 'Sword'}, 6528, 20000, 'War Sword')
shopModule:addBuyableItem({'War Axe', 'Axe'}, 2454, 20000, 'War Axe')
local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
if(isSorcerer(cid) or isDruid(cid)) then
if(getPlayerStorageValue(cid, 30002) <= 0) then
selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
talkState[talkUser] = 1
else
selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
end
else
selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
end
elseif(msgcontains(msg, 'yes')) then
if(talkState[talkUser] == 1) then
doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
selfSay('Here you are young adept, take care yourself.', cid)
setPlayerStorageValue(cid, 30002, 1)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
selfSay('Ok then.', cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())