• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

lua - npc script lugri

vingo

Active Member
Joined
Oct 27, 2012
Messages
464
Reaction score
43
This script does not remove the items, it asks for it but nothing further when i come back with the item required.




PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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

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, "outfit")) then
        if(getPlayerStorageValue(cid, 1003) < 1) then
            npcHandler:say("This skull shows that you are a true follower of Zathroth and the glorious gods of darkness. Are you willing to prove your loyalty?", cid)
            talkState[talkUser] = 1
        end
    elseif(msgcontains(msg, "shield")) then
        if(getPlayerStorageValue(cid, 1003) == 1) then
            npcHandler:say("Is it your true wish to sacrifice a medusa shield to Zathroth?", cid)
            talkState[talkUser] = 3
        end
    elseif(msgcontains(msg, "mail")) then
        if(getPlayerStorageValue(cid, 1003) == 2) then
            npcHandler:say("Is it your true wish to sacrifice a dragon scale mail to Zathroth?", cid)
            talkState[talkUser] = 4
        end   
    elseif(msgcontains(msg, "legs")) then
        if(getPlayerStorageValue(cid, 1003) == 3) then
            npcHandler:say("Is it your true wish to sacrifice crown legs to Zathroth?", cid)
            talkState[talkUser] = 5
        end   
    elseif(msgcontains(msg, "ring")) then
        if(getPlayerStorageValue(cid, 1003) == 4) then
            npcHandler:say("Is it your true wish to sacrifice a ring of the sky to Zathroth?", cid)
            talkState[talkUser] = 6
        end
    elseif(msgcontains(msg, "yes")) then
        if(talkState[talkUser] == 1) then   
            npcHandler:say("It will be a hard task which requires many sacrifices. Do you still want to proceed?", cid)
            talkState[talkUser] = 2
        elseif(talkState[talkUser] == 2) then   
            npcHandler:say("Good decision, <name>. Your first sacrifice will be a medusa shield. Bring it to me and do give it happily.", cid)
            setPlayerStorageValue(cid, 1003, 1)
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 2) then
            if(getPlayerItemCount(cid, 2536) >= 1) then
                npcHandler:say("Good. I accept your sacrifice. The second sacrifice I require from you is a dragon scale mail. Bring it to me and do give it happily.", cid)
                doPlayerRemoveItem(cid, 2536, 1)
                setPlayerStorageValue(cid, 1003, 2)
                talkState[talkUser] = 0   
            end
        elseif(talkState[talkUser] == 3) then
            if(getPlayerItemCount(cid, 2492) >= 1) then
                npcHandler:say("Good. I accept your sacrifice. The third sacrifice I require from you are crown legs. Bring them to me and do give them happily.", cid)
                doPlayerRemoveItem(cid, 2492, 1)
                setPlayerStorageValue(cid, 1003, 3)
                talkState[talkUser] = 0   
            end
        elseif(talkState[talkUser] == 4) then
            if(getPlayerItemCount(cid, 2488) >= 1) then
                npcHandler:say("Good. I accept your sacrifice. The last sacrifice I require from you is a ring of the sky. Bring it to me and do give it happily.", cid)
                doPlayerRemoveItem(cid, 2488, 1)
                setPlayerStorageValue(cid, 1003, 4)
                talkState[talkUser] = 0   
            end
        elseif(talkState[talkUser] == 5) then
            if(getPlayerItemCount(cid, 2123) >= 1) then
                npcHandler:say("Good. I accept your sacrifice. You have proven that you are a true follower of Zathroth and do not hesitate to sacrifice worldly goods. Thus, I will reward you with this headgear. ", cid)
                doPlayerRemoveItem(cid, 2123, 1)
                setPlayerStorageValue(cid, 1003, 5)
                doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and 149 or 145, 1)
                talkState[talkUser] = 0   
            end
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
The talkStates aren't correct with the questions.
When people say shield and confirm with yes that they have a medusa shield, it removes a dragon scale mail if people have them.

elseif(msgcontains(msg, "shield")) then
if(getPlayerStorageValue(cid, 1003) == 1) then
npcHandler:say("Is it your true wish to sacrifice a medusa shield to Zathroth?", cid)
talkState[talkUser] = 3
end
~~~~
elseif(talkState[talkUser] == 3) then
if(getPlayerItemCount(cid, 2492) >= 1) then
npcHandler:say("Good. I accept your sacrifice. The third sacrifice I require from you are crown legs. Bring them to me and do give them happily.", cid)
doPlayerRemoveItem(cid, 2492, 1)
setPlayerStorageValue(cid, 1003, 3)
talkState[talkUser] = 0​
end​


You also check 2x for talkState 2 after yes, so it will never do the second one.
 
Last edited:
So i just change the numbers to like - talkstate 1 for shield 2 for dsm 3 for c legs?

Nice thanks ! I fixed it


But isnt Lugri supposed to give me head aswell if I bring 100 holy orchids?

nvm this is queen of banshees
 
Last edited by a moderator:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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

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, "spectral dress")) then
        if(getPlayerStorageValue(cid, 90) == 48) then
            npcHandler:say("Your wish for a spectral dress is silly. Although I will grant you the permission to take one. My maidens left one in a box in a room, directly south of here.", cid)
            setPlayerStorageValue(cid, 90, 49)
        end
    elseif(msgcontains(msg, "addon")) then
        if(getPlayerStorageValue(cid, 1003) == 5) then
            npcHandler:say("Say... I have been longing for something for an eternity now... if you help me retrieve it, I will reward you. Do you consent to this arrangement?", cid)
            talkState[talkUser] = 1
        end
    elseif(msgcontains(msg, "orchid")) then
        if(getPlayerStorageValue(cid, 1003) == 6) then
            npcHandler:say("Have you really brought me 50 holy orchids?", cid)
            talkState[talkUser] = 3
        end
    elseif(msgcontains(msg, "yes")) then
        if(talkState[talkUser] == 1) then
            npcHandler:say("Listen... there are no blooming flowers down here and the only smell present is that of death and decay. ...", cid)
            npcHandler:say("I wish that I could breathe the lovely smell of beautiful flowers just one more time, especially those which elves cultivate. ...", cid)
            npcHandler:say("Could you please bring me 50 holy orchids?", cid)
            npcHandler:say("", cid)
            talkState[talkUser] = 2
        elseif(talkState[talkUser] == 2) then
            npcHandler:say("Thank you. I will wait for your return.", cid)
            setPlayerStorageValue(cid, 1003, 6)
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 3) then
            if(getPlayerItemCount(cid, 5922) >= 50) then
                npcHandler:say("Thank you! You have no idea what that means to me. As promised,here is your reward... as a follower of Zathroth, I hope that you will like this accessory.", cid)
                doPlayerRemoveItem(cid, 5922, 1)
                setPlayerStorageValue(cid, 1003, 7)
                doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and 149 or 145, 1)
                talkState[talkUser] = 0   
            end
        end
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())z


This one isnt working tho, can anyone see any problem with it?

The npc doesn't respond at all when saying any of the keywords

upupup

bump
 
Last edited by a moderator:
Code:
if(getPlayerStorageValue(cid, 90) == 48) then

Your character have this all storages?
 
I cant talk to banshee queen at all, do I need to make quest before I can?

I remove that if getplayerstorage line and still doesnt work

up

bu,p

up
 
Last edited by a moderator:
Back
Top