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

domelxp

Member
Joined
Mar 1, 2010
Messages
243
Reaction score
5
Its possibile to make some npc
who create monsters??
like
player :hi
npc :hi
player : fight
npc : are you ready ?
player :yes

and on this moment npc create monsters on room


.thx
domelxp
 
My NPC create monsters when you say 'hi' first time (like on rl tibia 'king of minotaurs'):
PHP:
local ID_STORAGE_QUESTA = 37411

talk_state = {}

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

function onCreatureAppear(cid)
talk_state[cid] = 0
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 creatureSayCallback(cid, type, message)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if(getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == 0) then
        if(msgcontains(string.lower(message), 'no') == true) or (msgcontains(string.lower(message), 'nie') == true) then
            selfSay('Wroc kiedy bedziesz mial troche czasu i checi, zeby mi pomoc.', cid)
            talk_state[cid] = 0
        elseif((msgcontains(string.lower(message), 'yes') == true) or (msgcontains(string.lower(message), 'tak') == true)) and talk_state[cid] == 1 then
            selfSay('Dziekuje. Mam nadzieje, ze jeszcze pamieta moje imie.', cid)
            setPlayerStorageValue(cid, ID_STORAGE_QUESTA, 1)
            talk_state[cid] = 0
        else
            selfSay('Moglbys znalezc Mistrza Warlockow i zapytac sie o mnie?', cid)
            talk_state[cid] = 1
        end
    elseif getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == 1 or (getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == 2) then
        if(msgcontains(string.lower(message), 'no') == true) then
            selfSay('Przyjdz kiedy zdobedziesz ulaskawienie od mistrza.', cid)
            talk_state[cid] = 0
        elseif((msgcontains(string.lower(message), 'yes') == true) or (msgcontains(string.lower(message), 'tak') == true)) and talk_state[cid] == 1 then
			local item = getPlayerItemById(cid, 1, 8370)
			if item.actionid == ID_STORAGE_QUESTA then
				doRemoveItem(item.uid)
				selfSay('Dzieki za pomoc. Zaraz bede mogl wrocic na zajecia. Masz tu nagrode za przekonanie mojego mistrza.', cid)
				doPlayerAddItem(cid, 2656, 1, 1)
				doPlayerAddMoney(cid, 20000)
				setPlayerStorageValue(cid, ID_STORAGE_QUESTA, 3)
			else
				selfSay('Przyjdz jak bedziesz mial ulaskawienie od mistrza.', cid)
			end
            talk_state[cid] = 0
        else
            selfSay('Masz dla mnie list z ulaskawieniem od Mistrza Warlockow?', cid)
            talk_state[cid] = 1
        end
    else
        selfSay('Raz juz mi pomogles, a ja znowu wpadlem w tarapaty, wiecej juz Ci nie zaufa Mistrz Warlockow.', cid)
        talk_state[cid] = 0
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
function greetCallback(cid)
    talk_state[cid] = 0
    if(getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == -1) then
        doCreateMonster('Stone Golem', getClosestFreeTile(cid, getCreaturePosition(cid)))
        setPlayerStorageValue(cid, ID_STORAGE_QUESTA, 0)
        return false
    else
        return true
    end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Czesc |PLAYERNAME|. Mistrz znowu mnie tu zamknal. Czy to moja wina, ze Fireball wymknal mi sie spod kontroli i spalil pare ksiazek?! Czy moglbys mi pomoc?')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Do zobaczenia |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Do zobaczenia |PLAYERNAME|.')

npcHandler:addModule(FocusModule:new())
part of code important for you:
PHP:
function greetCallback(cid)
    talk_state[cid] = 0
    if(getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == -1) then
        doCreateMonster('Stone Golem', getClosestFreeTile(cid, getCreaturePosition(cid)))
        setPlayerStorageValue(cid, ID_STORAGE_QUESTA, 0)
        return false
    else
        return true
    end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
 
Back
Top