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

Storage check

kamilcioo

Veteran OT User
Joined
Jul 25, 2008
Messages
978
Solutions
1
Reaction score
289
Hey, can't find a way how to put storage check in my npc. I want him to respose "Please make my brother tasks and them speak to me" if you don't have storage and if so "Kill one sealed rat". I want him to check storage: 76000 and str ==4

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState = {}
local quest = 47775
local reward = 71006
   
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)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if(not npcHandler:isFocused(cid)) then
        return false
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        npcHandler:say("It's dangerous. Is it {ok}?.", cid)
        talkState[talkUser] = 2
    elseif msgcontains(msg, "ok") and talkState[talkUser] == 2 then
        npcHandler:say("Okay, do it", cid)
        setPlayerStorageValue(cid, quest, 2)
        talkState[talkUser] = 0
    elseif msgcontains(msg, "mission") or msgcontains(msg, "task") then
        local str = getPlayerStorageValue(cid, quest)
        if(str < 2) then
            npcHandler:say("Great, please kill one sealed rat for me. Will you do it?", cid)
            talkState[talkUser] = 1
            return true
        elseif(str == 2) then
            npcHandler:say("Please come back when you're done.", cid)
        elseif(str == 3) then
            npcHandler:say("Killed, already? Here's your reward.", cid)
            doPlayerAddItem(cid, 2160, 2)
            doPlayerAddExp(cid, 45000)
            setPlayerStorageValue(cid, quest, 4)
        elseif(str == 4) then
            npcHandler:say("You have done enough for me.", cid)
        end
        talkState[talkUser] = 0
    end
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
try:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState = {}
local quest = 47775
local reward = 71006
local qest = getPlayerStorageValue(cid,76000)
   
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)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if(not npcHandler:isFocused(cid)) then
        return false
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        npcHandler:say("It's dangerous. Is it {ok}?.", cid)
        talkState[talkUser] = 2
    elseif msgcontains(msg, "ok") and talkState[talkUser] == 2 then
        npcHandler:say("Okay, do it", cid)
        setPlayerStorageValue(cid, quest, 2)
        talkState[talkUser] = 0
    elseif msgcontains(msg, "mission") or msgcontains(msg, "task") then
        local str = getPlayerStorageValue(cid, quest)
        if(str == 4) and qest == -1 then
            npcHandler:say("Great, please kill one sealed rat for me. Will you do it?", cid)
            talkState[talkUser] = 1
            return true
        else
        npcHandler:say("Please make my brother tasks and them speak to me", cid)
        return false
        elseif(str == 2) then
            npcHandler:say("Please come back when you're done.", cid)
        elseif(str == 3) then
            npcHandler:say("Killed, already? Here's your reward.", cid)
            doPlayerAddItem(cid, 2160, 2)
            doPlayerAddExp(cid, 45000)
            setPlayerStorageValue(cid, quest, 4)
        elseif(str == 4) then
            npcHandler:say("You have done enough for me.", cid)
        end
        talkState[talkUser] = 0
    end
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState = {}
local quest = 47775
local reward = 71006
local qest = getPlayerStorageValue(cid,76000)
  
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)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if(not npcHandler:isFocused(cid)) then
        return false
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        npcHandler:say("It's dangerous. Is it {ok}?.", cid)
        talkState[talkUser] = 2
    elseif msgcontains(msg, "ok") and talkState[talkUser] == 2 then
        npcHandler:say("Okay, do it", cid)
        setPlayerStorageValue(cid, quest, 2)
        talkState[talkUser] = 0
    elseif msgcontains(msg, "mission") or msgcontains(msg, "task") then
        local str = getPlayerStorageValue(cid, quest)
        if(str == 4) and (qest == -1) then
            npcHandler:say("Great, please kill one sealed rat for me. Will you do it?", cid)
            talkState[talkUser] = 1
            return true
        else
        npcHandler:say("Please make my brother tasks and them speak to me", cid)
        return false
        elseif(str == 2) then
            npcHandler:say("Please come back when you're done.", cid)
        elseif(str == 3) then
            npcHandler:say("Killed, already? Here's your reward.", cid)
            doPlayerAddItem(cid, 2160, 2)
            doPlayerAddExp(cid, 45000)
            setPlayerStorageValue(cid, quest, 4)
        elseif(str == 4) then
            npcHandler:say("You have done enough for me.", cid)
        end
        talkState[talkUser] = 0
    end
    return TRUE
end

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

Can you please copy the error aswell, if i'm missing or bad value etc
try this one
 
Back
Top