• 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 Greet message

habiba

New Member
Joined
Aug 26, 2007
Messages
586
Reaction score
4
Location
Örebro, Sweden
I need help on NPCs in GREET_MESSAGE

So what i need is to use the function:

npcHandler:setMessage(MESSAGE_GREET, "Message here")

It work fine but i need to add getPlayerStorageValue to get other greet messages
depending on the storage value, How can i do this?


Script base:

Used Gesior script:

PHP:
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)             end
function onCreatureDisappear(cid)
    talk_state[cid] = 0
    npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)         npcHandler:onCreatureSay(cid, type, msg)     end
function onThink()                             npcHandler:onThink()                         end


npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I'm banker.")


talk_state = {}
last_count = {}
last_name = {}
function creatureSayCallback(cid, type, msg)
    orginal_msg = msg
    msg = string.lower(msg)
    if(not npcHandler:isFocused(cid)) then
    talk_state[cid] = 0
        return false
    end
    if talk_state[cid] == nil then
        talk_state[cid] = 0
        last_count[cid] = 0
        last_name[cid] = ""
    end
    -- select action
    if msgcontains(msg, 'change') and talk_state[cid] ~= 41 then
        talk_state[cid] = 10
        npcHandler:say('We exchange gold, platinum and crystal coins.', cid)
    elseif msgcontains(msg, 'balance') and talk_state[cid] ~= 41 then
        talk_state[cid] = 0
		end
    return true
end

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

If someone can tell me the solution ill rep him :D
 
PHP:
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)             end
function onCreatureDisappear(cid)
    talk_state[cid] = 0
    npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)         npcHandler:onCreatureSay(cid, type, msg)     end
function onThink()                             npcHandler:onThink()                         end


function greetCallback(cid)
	quest = getPlayerStorageValue(cid, 40100)
    if(quest < 1) then
        npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I'm banker. Would you like to do something for me?")
        return true
    else
		npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I'm banker.")
        return true
    end
end

talk_state = {}
last_count = {}
last_name = {}
function creatureSayCallback(cid, type, msg)
    orginal_msg = msg
    msg = string.lower(msg)
    if(not npcHandler:isFocused(cid)) then
    talk_state[cid] = 0
        return false
    end
    if talk_state[cid] == nil then
        talk_state[cid] = 0
        last_count[cid] = 0
        last_name[cid] = ""
    end
    -- select action
    if msgcontains(msg, 'change') and talk_state[cid] ~= 41 then
        talk_state[cid] = 10
        npcHandler:say('We exchange gold, platinum and crystal coins.', cid)
    elseif msgcontains(msg, 'balance') and talk_state[cid] ~= 41 then
        talk_state[cid] = 0
        end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top