• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Npc Uzgod For Blessed Wooden Stake And Obsidian Knife

Splintx

New Member
Joined
Apr 18, 2008
Messages
6
Reaction score
0
Date/Npc

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"/>

:D:thumbup::p
 
Last edited by a moderator:
[10/10/2008 06:58:57] Lua Script Error: [Npc interface]
[10/10/2008 06:58:57] data/npc/scripts/uzgod.lua:eek:nThink

[10/10/2008 06:58:57] data/npc/scripts/uzgod.lua:9: attempt to call global 'npcHandlernThink' (a nil value)
[10/10/2008 06:58:57] stack traceback:
[10/10/2008 06:58:57] data/npc/scripts/uzgod.lua:9: in function <data/npc/scripts/uzgod.lua:9>

need a little help with this :confused:
 
@autor, when you post code use
PHP:
 or [CODE], not [QUOTE]
@up - its error with smiles in post in place of code :(
 
I modifyed the quote tags to code tags. Try to readd the codes and see if it works. Smilies might interrupt stuff.
 
Back
Top