Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- lua_register(m_luaState, "selfFocus", NpcScript::luaActionFocus);
- lua_register(m_luaState, "selfSay", NpcScript::luaActionSay);
- lua_register(m_luaState, "selfFollow", NpcScript::luaActionFollow);
- lua_register(m_luaState, "getNpcId", NpcScript::luaGetNpcId);
- lua_register(m_luaState, "getNpcParameter", NpcScript::luaGetNpcParameter);
- lua_register(m_luaState, "getNpcState", NpcScript::luaGetNpcState);
- lua_register(m_luaState, "setNpcState", NpcScript::luaSetNpcState);
- lua_register(m_luaState, "openShopWindow", NpcScript::luaOpenShopWindow);
- lua_register(m_luaState, "closeShopWindow", NpcScript::luaCloseShopWindow);
- lua_register(m_luaState, "getShopOwner", NpcScript::luaGetShopOwner);
- --]]
- -- general config
- local required_money = 80000
- local time_to_make = 24 * 60 * 600
- -- storages
- local storage_state = 15000
- local storage_time = 15000
- -- config of items' id
- local sword_broked_id = 2350
- local sword_reward_id = 10513
- local items_task = {
- [2225] = 30, -- pieces of iron, 30
- [2134] = 30, -- silver broochs, 10
- }
- local function setState(state, cid)
- if not isCreature(cid) then return false end
- doCreatureSetStorage(cid, storage_state, state)
- end
- local function getState(cid)
- if not isCreature(cid) then return false end
- return getCreatureStorage(cid, storage_state)
- end
- function onCreatureSay(cid, type, msg)
- local state = tonumber(getState(cid))
- local msg = msg:lower()
- if isInArray({"hi", "hello", "oi", "olá"}, msg) then
- selfFocus(cid)
- if state < 3 then
- selfSay(string.format("Ola %s, eu sou morador daqui, gosto deste lugar, me sinto protegido.", getCreatureName(cid)))
- setState(1, cid)
- elseif state == 5 then
- else
- selfSay("Trouxe o que lhe pedi?")
- selfFocus(cid)
- setState(4, cid)
- end
- end
- if isInArray({"espada", "sword"}, msg) and state == 1 then
- if getPlayerItemCount(cid, sword_broked_id) > 0 then
- selfSay("Onde você encontrou esta espada quebrada? Com ela posso fazer uma poderosa espada, mas você vai precisar trazer 30 pieces of iron, 30 silver broochs, 10 golden mugs, 1 demonic finger e 80k. Aceita?")
- setState(2, cid)
- else
- selfSay("Voce nao tem a espada que procuro")
- setState(nil, cid)
- selfFocus(getNpcId())
- end
- end
- if isInArray({"yes", "no", "sim", "nao"}, msg) then
- if state == 2 and isInArray({"yes", "sim"}, msg) and doPlayerRemoveItem(cid, sword_broked_id, 1) then
- selfSay("Otimo, me traga o que te pedi: 30 pieces of iron, 30 silver broochs, 10 golden mugs, 1 demonic finger e 80k.")
- selfFocus(getNpcId())
- setState(3, cid)
- end
- if state == 4 and isInArray({"yes", "sim"}, msg) then
- for itemid, count in pairs(items_task) do
- if not getPlayerItemCount(cid, itemid) >= count then
- selfSay(string.format("Voce não tem %d %s. Volte quando estiver com eles", count, itemid))
- selfFocus(getNpcId())
- setState(3, cid)
- return true
- end
- end
- if not getPlayerMoney(cid) >= required_money then
- selfSay(string.format("Voce nao tem %d coins", required_money))
- selfFocus(getNpcId())
- selfState(3, cid)
- return true
- end
- for itemid, count in pairs(items_task) do
- doPlayerRemoveItem(cid, itemid, count)
- end
- doPlayerRemoveMoney(cid, required_money)
- selfSay(
- setState(5, cid)
- end
- end
- return true
- end
- function onCreatureDisappear(cid)
- selfSay("How hude!")
- selfFocus(getNpcId())
- local state = getState(cid)
- if state and state < 3 then
- setState(nil, cid)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement