Splintx
New Member
- Joined
- Apr 18, 2008
- Messages
- 6
- Reaction score
- 0
Date/Npc
Uzgod
Date/Npc/scripts
MapEditor
:thumbup:
Uzgod
Code:
<?xml version="1.0"?>
<npc name="Uzgod" script="data/npc/scripts/uzgod.lua" access="5" lookdir="2" autowalk="25">
<mana now="800" max="800" />
<health now="200" max="200" />
<look type="160" head="0" body="87" legs="86" feet="116" />
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I can trade you a few nice items." />
</parameters>
</npc>
Date/Npc/scripts
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'items') or msgcontains(msg, 'item') then
selfSay('I sell blessed wooden stakes. I can also exchange your green tunics, red robes and mystic turbans for green, red or blue pieces of cloth also I can give you an obsidian knife if you bring me some items.')
elseif msgcontains(msg, 'obsidian knife') or msgcontains(msg, 'obsidian') or msgcontains(msg, 'knife') then
if getPlayerItemCount(cid,5889) >= 1 and getPlayerItemCount(cid,2425) >= 1 then
selfSay('Do you want to trade draconian steel and an onsidian lance for an obsidian knife?')
talk_state = 1
else
selfSay('Comeback when you have an obsidian lance and draconian steel.')
end
elseif msgcontains(msg, 'blessed stake') or msgcontains(msg, 'blessed wooden stake') then
selfSay('Do you want to buy a blessed wooden stake for 8000 gold?')
talk_state = 2
elseif msgcontains(msg, 'green') or msgcontains(msg, 'tunic') or msgcontains(msg, 'green tunic') or msgcontains(msg, 'green piece of cloth') then
selfSay('Do you want trade 40 green tunics for a green piece of cloth?')
talk_state = 3
elseif msgcontains(msg, 'red') or msgcontains(msg, 'robe') or msgcontains(msg, 'red robe') or msgcontains(msg, 'red piece of cloth') then
selfSay('Do you want trade a red robe for a red piece of cloth?')
talk_state = 4
elseif msgcontains(msg, 'blue') or msgcontains(msg, 'turban') or msgcontains(msg, 'mystic turban') or msgcontains(msg, 'blue piece of cloth') then
selfSay('Do you want trade a mystic turban for a blue piece of cloth?')
talk_state = 5
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,5889) >= 1 and getPlayerItemCount(cid,2425) >= 1 then
if doPlayerTakeItem(cid,5889,1) == 0 and doPlayerTakeItem(cid,2425,1) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5908,1)
end
else
selfSay('Sorry, you don\'t have the items.')
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 then
if player_money >= 8000 then
if pay(cid,8000) then
selfSay('Here you are.')
doPlayerAddItem(cid,5942,1)
end
else
selfSay('Sorry, you don\'t have enough money.')
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 3 then
if getPlayerItemCount(cid,2652) >= 40 then
if doPlayerTakeItem(cid,2652,40) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5910,1)
end
else
selfSay('Sorry, you don\'t have the items.')
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 4 then
if getPlayerItemCount(cid,2655) >= 1 then
if doPlayerTakeItem(cid,2655,1) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5911,1)
end
else
selfSay('Sorry, you don\'t have the item.')
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 5 then
if getPlayerItemCount(cid,2663) >= 1 then
if doPlayerTakeItem(cid,2663,1) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5912,1)
end
else
selfSay('Sorry, you don\'t have the item.')
end
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
MapEditor
Code:
<creature looktype="160" name="Uzgod" head="0" body="87" legs="86" feet="116" type="npc"/>
:thumbup:
Last edited by a moderator: