• 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!

Help,please an npc

Nacke

New Member
Joined
Feb 13, 2008
Messages
79
Reaction score
0
hello, I have a problem with these scripts if anyone can help me. I do not answer the NPC
PHP:
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())

PHP:
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)
    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, 'job') or msgcontains(msg, 'help') then
            selfSay('I can give you a "lottery ticket" for empty vials.')
------------------------------------------------ addon ------------------------------------------------
        elseif msgcontains(msg, 'lottery ticket') then
            if isPremium(cid) then
            selfSay('Do you want to exchange great or divine empty potions?')
            talk_state = 1
                if msgcontains(msg, 'great') and talk_state == 1 then    
                    if getPlayerItemCount(cid,7635) >= 50 then
                        selfSay('Did you bring me 50 empty great potions for a lottery ticket?')
                        talk_state = 2
                    else
                        selfSay('I need 50 empty great potions, to give you the lottery ticket. Come back when you have them.')
                        talk_state = 0
                    end
                elseif msgcontains(msg, 'divine') and talk_state == 1 then
                    if getPlayerItemCount(cid, 7634) >= 200 then
                        selfSay('Did you bring me 200 empty divine potions for a lottery ticket?')
                        talk_state = 3
                    else
                        selfSay('I need 200 empty great potions, to give you the lottery ticket. Come back when you have them.')
                        talk_state = 0
                    end
                else 
                    selfSay('Ok, then.')
                    talk_state = 0
                end
            else
                selfSay('I will deal only with premium characters.')
                talk_state = 0
            end
------------------------------------------------ confirm yes ------------------------------------------------
        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            talk_state = 0
            if getPlayerItemCount(cid,7635) >= 200 then
                    if doPlayerRemoveItem(cid,2006,200) == 1 then
                        doPlayerAddItem(cid,5957,1)
                    end
            end
        elseif msgcontains(msg, 'yes') and talk_state == 3 then
            talk_state = 0
            if getPlayerItemCount(cid,7634) >= 200 then
                    if doPlayerRemoveItem(cid,7634,200) == 1 then
                        doPlayerAddItem(cid,5957,1)
                    end
            end
------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state >= 1) and (talk_state <= 34) then
            selfSay('Ok than.')
            talk_state = 0
        end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

the functions of trade yes the scripts not

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Uzgod" script="data/npc/scripts/obsidian.lua" walkinterval="1000" floorchange="0">
    <health now="100" max="100"/>
    <look type="160" head="77" body="79" legs="56" feet="0" addons="0"/>
    <parameters>
        <parameter key="message_greet" value="Hiho |PLAYERNAME|! Wanna {weapon}, eh?"/>
        <parameter key="message_farewell" value="Guut bye. Coming back soon, |PLAYERNAME|."/>
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="weapon;job;" />
        <parameter key="keyword_reply1" value="See my weapons, light an' heavy ones? Ask for {trade}." />
        <parameter key="keyword_reply2" value="Me a blacksmith is, an' weapons me sell. You want buy weapons?" />

        <parameter key="module_shop" value="1"/>
        <parameter key="shop_buyable" value="axe,2386,20;battle axe,2378,235;battle hammer,2417,350;club,2382,5;dagger,2379,5;mace,2398,90;morning star,2394,430;rapier,2384,15;sabre,2385,35;spear,2389,10;sword,2376,85;throwing knife,2410,25;two handed sword,2377,950;" />
        <parameter key="shop_sellable" value="battle axe,2378,75;battle hammer,2417,50;carlin sword,2395,118;club,2382,1;dagger,2379,1;double axe,2387,260;fire sword,2392,1000;halberd,2381,310;longsword,2397,51;mace,2398,23;morning star,2394,100;rapier,2384,3;sabre,2385,5;spear,2389,1;spike sword,2383,225;sword,2376,15;two handed sword,2377,190;war hammer,2391,470;" />
    </parameters>
</npc>


thz
 
Back
Top Bottom