[NPC] EGG

XkluivertX
em NPCs, monsters e raids

XkluivertX

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 24/03/13Posts: 24

Olá galera venho aqui trazer um sistema de egg.

 

 

Demorei tirar um bug que tinha mais finalmente consegui e to vindo para disponibilizar para todos.

 

 

1- Passo: Va em data/npc/script crie um arquivo eggsystem.lua e coloque dentro.

 

 

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 onCreatureSayCallback(cid, type, msg)

local config = {

price = 50000,

delay = 5 * 60,

control = {10555, 10556},

eggn = 4850

}

if not npcHandler:isFocused(cid) then

return false

end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

 

if msgcontains(msg, "care") then

local p = (config.price % 1000 == 0 and (config.price / 1000) or config.price)

if getPlayerStorageValue(cid, config.control) > os.time() then

selfSay("Sorry, but I am already caring one of your eggs.", cid)

else

selfSay("Do you want me to take care of your egg for ".. p .." ".. (p == config.price and "" or "k") .."?", cid)

talkState[talkUser] = 1

end

 

elseif msgcontains(msg, "back") then

if getPlayerStorageValue(cid, config.control[2]) == 1 then

selfSay("Hello, do you came to pick up your egg?", cid)

talkState[talkUser] = 2

else

selfSay("Sorry, but I am not caring eggs from you.", cid)

end

 

elseif msgcontains(msg, "check") then

local t = getPlayerStorageValue(cid, config.control[1])

if getPlayerStorageValue(cid, config.control[2]) == -1 then

selfSay("Sorry, but I am not caring eggs from you.", cid)

else

if t < os.time() then

selfSay("Yay, your egg has started to hatch, take it.", cid)

setPlayerStorageValue(cid, config.control[1], -1)

setPlayerStorageValue(cid, config.control[2], -1)

else

selfSay("I will be caring your egg for more ".. (math.floor((t - os.time()) / 60) > 0 and "".. math.floor((t - os.time()) / 60) .." minutes and" or "") .." ".. (t - os.time()) % 60 .." seconds.", cid)

end

end

end

 

if talkState[talkUser] == 1 then

if msgcontains(msg, "yes") then

if getPlayerStorageValue(cid, config.control[2]) == -1 then

if doPlayerRemoveMoney(cid, config.price) then

setPlayerStorageValue(cid, config.control[2], 1)

setPlayerStorageValue(cid, config.control[1], os.time()+config.delay)

selfSay("Okay! Check back soon.", cid)

else

selfSay("Sorry, you don't have enough money. You need more ".. (config.price - getPlayerMoney(cid)) .." coins.", cid)

end

else

selfSay("I am already taking care of a egg for you.", cid)

end

elseif msgcontains(msg, "no") then

selfSay("Too pricey for you, heh?", cid)

end

elseif talkState[talkUser] == 2 then

local x = getPlayerStorageValue(cid, config.control)

local t = getPlayerStorageValue(cid, config.control[1])

if msgcontains(msg, "yes") then

if x > os.time() then

local item = doPlayerAddItem(cid, config.eggn, 1)

doItemSetAttribute(item, "description", "A hatched egg.")

selfSay("Take it!", cid)

setPlayerStorageValue(cid, control[2], -1)

setPlayerStorageValue(cid, control[1], -1)

else

selfSay("Sorry, but your egg need care for more ".. (math.floor((t - os.time()) / 60) > 0 and "".. math.floor((t - os.time()) / 60) .." minutes and" or "") .." ".. (t - os.time()) % 60 .." seconds.", cid)

end

end

end

return true

end

 

npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|. I am a pet egg carer. Do you want me to {care} your pet eggs? Also you can {check} the egg status and if you have any egg here, you can get it {back}.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)

 

npcHandler:addModule(FocusModule:new())

 

2- Passo: Va em data/npc e crie um npc chamado mary ou outro nome que voce quiser.

 

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Mary" script="eggsystem.lua" walkinterval="2000" floorchange="0">

<health now="100" max="100"/>

<look type="138" head="20" body="39" legs="45" feet="7" addons="3"/>

</npc>

 

Como Funciona:

 

1- Você pega um ovo qualquer.

2- Leva para o NPC

3- Ele cuidará dele

4- Depois de um tempo você pega ele de volta.

 

 

Se gostarem REP+button_ok.png

BrunooMaciell

Bruno Maciel
avatar
Infante
Infante

INFOS

Grupo: InfanteRegistrado: 27/08/11Posts: 1919Gênero: MasculinoChar no Tibia: Bruno Maciel

parece ser um belo systema e ainda mais sem bug ^^

 

porem pega em PDA ??

StyloMaldoso

a good son makes the house...;p
avatar
Infante
Infante

INFOS

Grupo: InfanteRegistrado: 25/01/12Posts: 1593

creditos.. ?

nem fui q fez isso cara, esse npc ja é velho pacarai, ja fizerão bem antens do PDA, espero que coloke os credítos

Project Pokémon Mysterion OpenSoures 2016.

Em breve, mais informações!

 

23vfcht.png

XkluivertX

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 24/03/13Posts: 24

Mano foi meu amigo no msn que me passo ai ele pediu pra eu tirar o bug quando vc ia tirar o egg ele sai com um iten de tibia e quando vc abria sai um Demon morto na sua bp ai bugava, e os creditos eu não sei de quem fes pow, Mas so sei que eu ajetei esse bug demorei mais ajeitei.

 

Se puder tbm dizer os creditos eu ponho, mais tbm terei credito pq ajeitei.

 

parece ser um belo systema e ainda mais sem bug ^^

 

porem pega em PDA ??

 

 

Bruno eu testei em Cerution, Flash e Svke. mais provavelmente pegue em PDA.