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

NPC seller

Gubailovo

Well-Known Member
Joined
Dec 19, 2013
Messages
407
Solutions
2
Reaction score
62
I can not add a counter NPC (opens as a bagpack)
12345.gif

example npc
Jadi

XML:
<?xml version="1.0"?>

<npc name="Jadi" script="data/npc/scripts/Jadi.lua" access="3" pushable="0" lookdir="2">
    <look type="136" head="78" body="50" legs="58" feet="95"/> 

    <shop>

        <item type="1" id="2120" price="50"/>
        <item type="1" id="2554" price="120"/>
        <item type="1" id="1988" price="20"/>
        <item type="1" id="1987" price="10"/>
        <item type="1" id="2050" price="5"/>
        <item type="1" id="2260" price="60"/>
        
        <item type="1" id="5267" price="10" />
        <item type="1" id="5222" price="10" />
        <item type="1" id="2175" price="10" />
        <item type="1" id="5540" price="10" />
        <item type="1" id="1984" price="10" />
        
        <item type="1" id="2599" price="50"/>
        <item type="1" id="2595" price="500"/>
        <item type="1" id="2597" price="100"/>
        
        <item type="1" id="2550" price="120"/>
        <item type="1" id="2580" price="500"/>
        
        <item type="1" id="7222" price="50000"/>
    </shop>

    <sell>
        <item id="1988" price="4"/>
        <item id="1987" price="2"/>
        <item id="2120" price="10"/>
        <item id="2050" price="1"/>
        <item id="2554" price="24"/>
    </sell>


</npc>
Lua:
--::::::::::::::::::::::::::::::::::::::::
--System name: Darkonia RPG
--Short Desc: old-style MMoRPG
--Version: 5.0
--Authors: Torian Kel
--Date: 2 января, 2013
--Modul Desc: скрипт почтового NPC
--получение писем и посылок
--::::::::::::::::::::::::::::::::::::::::

focus = 0
talk_start = 0

function onThingMove(creature, thing, oldpos, oldstackpos)
end

function onCreatureAppear(creature)
end

function onCreatureDisappear(cid, pos)
    if focus == cid then
        selfSay('До свидания, ' .. creatureGetName(focus) .. '!')
        focus = 0
        talk_start = 0
    end
end

function onCreatureTurn(creature)
end

function onCreatureSay(cid, type, msg)
    cname = creatureGetName(cid)
    msg = string.lower(msg)

    dist = getDistanceToCreature(cid)
    
    if dist >= 4 then
        return
    end

    ---------------------------------- ПРИВЕТСТВИЕ --------------------------------------------
    if string.find(msg, '(%a*)привет(%a*)') and string.len(msg) == 6 then
        if focus == cid then
            selfSay('Я уже говорю с тобой!')
        else
            if focus > 0 then
                selfSay('' .. cname .. ', подожди своей очереди!')
            end
        end
        
        if(focus == 0) then
            selfSay('Привет, ' .. cname .. '! Я заведую местным почтовым отделением. Я продаю почтовые принадлежности, а так же могу выдать тебе твои посылки или письма. [проверить|выдать]')
            focus = cid
        end
        talk_start = os.clock()
    end

    --------------------------------- ПРОЩАНИЕ ---------------------------------------
    if string.find(msg, '(%a*)пока(%a*)') and cid == focus then
        selfSay('До свидания, ' .. cname .. '!')
        focus = 0
        itemid = 0
        talk_start = 0
        talkcount = 0
    end

    ------------------------------- ВЫБОР ----------------------------------------------
    if string.find(msg, '(%a*)проверить(%a*)') and cid == focus then
        mail_count = getMailCount(cid)
        parcel_count = getParcelCount(cid)
        
        if (mail_count == 0) and (parcel_count == 0) then
            selfSay('Почты для вас нет.')
        elseif (mail_count > 0) and (parcel_count == 0) then
            selfSay('У вас ' .. mail_count .. ' писем.')
        elseif (mail_count == 0) and (parcel_count > 0) then
            parcel_massa = getParcelsWeight(cid)
            selfSay('У вас ' .. parcel_count .. ' посылок общим весом ' .. parcel_massa .. '.')
        elseif (mail_count > 0) and (parcel_count > 0) then
            parcel_massa = getParcelsWeight(cid)
            selfSay('У вас ' .. mail_count .. ' писем и ' .. parcel_count .. ' посылок общим весом ' .. parcel_massa .. '.')
        end
        
        talk_start = os.clock()
    end

    if string.find(msg, '(%a*)выдать(%a*)') and cid == focus then
        selfSay('Тебе выдать посылки или письма? Или все вместе? [посылки|письма|все]')
        talkcount = 1
        talk_start = os.clock()
    end
    
    if string.find(msg, '(%a*)письма(%a*)') and cid == focus and talkcount == 1 then
        if getMailCount(cid) > 0 then
            --все письма одной строкой
            mails = getMails(cid)
            
            --парсим письма
            doPlayerAddMails(cid, mails)
            
            --удаляем письма
            deleteMails(cid, 1)
        else
            selfSay('Писем на твое имя нет.')
        end
    end


end

function onCreatureChangeOutfit(creature)

end

function onThink()
    if (os.clock() - talk_start) > 30 then
        if focus > 0 then
            selfSay('До свидания, ' .. creatureGetName(focus) .. '!')
        end

        focus = 0
        talk_start = 0
    end
    
    if focus > 0 then
        dist = getDistanceToCreature(focus)
        
        if dist >= 6 then
            selfSay('До свидания, ' .. creatureGetName(focus) .. '!')
            focus = 0
            talk_start = 0
        end
    end
end

can not add to another server (just adding npc and script). what am I missing?
Post automatically merged:

NPC can both buy and sell goods by simply dragging and dropping them from the counter or to the counter
111.gif
 
Last edited:
Back
Top