dofile("./petConfig.lua")
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local costPerLevel = 300
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'revive') then
if getPlayerStorageValue(cid, storages.petUid) == 0 then
if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
npcHandler:say('YOUR PET DIED?!, YOU\'R A BAD OWNER, THIS WILL COST YOU ' .. getPlayerLevel(cid)*costPerLevel .. ' GOLD COINS!, AGREE?!', cid)
talkState[talkUser] = 1
else
npcHandler:say('Your pet is alive.', cid)
talkState[talkUser] = 0
end
else
npcHandler:say('Your pet is standing next to you.', cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] = 1)then
if doPlayerRemoveMoney(cid, getPlayerLevel(cid)*costPerLevel) == TRUE then
setPlayerStorageValue(cid, storages.petIsOnline, 1)
npcHandler:say('You can now summon again your pet.', cid)
talkState[talkUser] = 0
else
npcHandler:say('You don\'t have enought money.', cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] = 1)then
npcHandler:say('Ok so i can not do nothing for you.', cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Madrid" script="revive.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="57" head="115" body="113" legs="31" feet="38" addons="3"/>
<parameters>
<parameter key="message_greet" value="Hello, |PLAYERNAME|!" />
<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="help; pet" />
<parameter key="keyword_reply1" value="I can revive your pet" />
<parameter key="keyword_reply2" value="I can revive your pet" />
</parameters>
</npc>
man put !petnick for agree nick pet
ej: pet demon -> pet nick Boby xd
CHANGE NAME PET PLS
This script is amazing, but could be even more amazing, Like true levels instead of just getting to another monsters.
function onSay(cid, words, param)
local magix = getPlayerMaxMana(cid)
local formula = magix/2
if getPlayerMana(cid) >= formula and isCreature(getPlayerStorageValue(cid, storages.petUid)) == 0 and getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
setPlayerStorageValue(cid, storages.petIsOnline, 1)
doPlayerAddMana(cid, -getPlayerMaxMana(cid)/2)
doPlayerSendTextMessage(cid,22,"NOW YOU CAN SUMMON YOUR PET!")
else
doPlayerSendCancel(cid,"You dont have enough mana.")
doSendMagicEffect(getPlayerPosition(cid),2)
end
return TRUE
end
<talkaction words="!revive" script="pets/!revive.lua"/>
HEY EVERYONE, I RE-SCRIPTED THE NPC CODE SO IT CAN BECOME AN EASY TALKACTION TO REVIVE PET. IT TAKES HALF OF THE USER'S MAX MANA, BUT YOU CAN EDIT
!resurrect.lua
PHP:function onSay(cid, words, param) local magix = getPlayerMaxMana(cid) local formula = magix/2 if getPlayerMana(cid) >= formula and isCreature(getPlayerStorageValue(cid, storages.petUid)) == 0 and getPlayerStorageValue(cid, storages.petIsOnline) == 2 then setPlayerStorageValue(cid, storages.petIsOnline, 1) doPlayerAddMana(cid, -getPlayerMaxMana(cid)/2) doPlayerSendTextMessage(cid,22,"NOW YOU CAN SUMMON YOUR PET!") else doPlayerSendCancel(cid,"You dont have enough mana.") doSendMagicEffect(getPlayerPosition(cid),2) end return TRUE end
ADD TO TALKACTIONS.XML:
PHP:<talkaction words="!revive" script="pets/!revive.lua"/>
Where is that logg out lua file? I can't find it in my maps ;S
Im kinda noobie but hey!?
if you don't have, just create it
dofile("./petConfig.lua")
function onLogout(cid)
if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 1 then
if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
setPlayerStorageValue(cid, storages.petIsOnline, 1)
end
end
return TRUE
end
<event type="logout" name="Logout" script="logout.lua"/>
PHP:if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 1 then if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then setPlayerStorageValue(cid, storages.petIsOnline, 1) end end
save last code as logout.lua@creaturescripts
then add to creaturescripts.xml:
PHP:<event type="logout" name="Logout" script="logout.lua"/>
that ought to work, rep me if worked for u