• 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 that revives your pet tfsbeta0,3

Guapoke

Member
Joined
Nov 21, 2008
Messages
259
Reaction score
5
This NPC
local focus = 0
local talk_start = 0
local talk_state = 0
local costPerLevel = 300

dofile("./petConfig.lua")



function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('How rude!.')
focus = 0
talk_start = 0
end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if getDistanceToCreature(cid) < 4 then
if (msgcontains(msg, 'hi') and (focus == 0)) then
selfSay('Hello! I can take you to the train!')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) then
selfSay('Sorry! I talk to you in a minute.')
end

if msgcontains(msg, 'revive') and focus == cid then
if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 0 then
if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
selfSay('YOUR PET DIED?!, YOU\'R A BAD OWNER, THIS WILL COST YOU ' .. getPlayerLevel(cid)*costPerLevel .. ' GOLD COINS!, AGREE?!')
talk_state = 1
else
selfSay('Your pet is alive.')
end
else
selfSay('Your pet is standing next to you.')
end
talk_start = os.clock()
end
if msgcontains(msg, 'yes') and focus == cid and talk_state == 1 then
if doPlayerRemoveMoney(cid, getPlayerLevel(cid)*costPerLevel) == 1 then
setPlayerStorageValue(cid, storages.petIsOnline, 1)
selfSay('You can now summon again your pet.')
else
selfSay('You don\'t have enought money.')
end
talk_state = 0
talk_start = os.clock()
end

if msgcontains(msg, 'bye') then
selfSay('Good bye!')
focus = 0
talk_start = 0
talk_state = 0
end
end
end


function onCreatureChangeOutfit(creature)

end


function onThink()

doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
talk_state = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
talk_state = 0
selfSay('Good bye then.')
talk_state = 0
focus = 0
end
end
end
Don't work with TFS 0.3 Beta I need another one that works!
Please someone help me :D
 
Alright! here you are:

## First ##

data -> Talkactions -> talkactions.xml

Code:
<talkaction words="!petrevive" script="pets/!petrevive.lua"/>


data -> Talkactions -> scripts -> pets -> !petrevive.lua
Code:
dofile("./petConfig.lua")

local config = {
Money = 50000,
MsgBuy = "YOUR PET DIED? YOU\'RE A BAD OWNER, THIS WILL COST YOU 50000 GOLD COINS!",
MsgBuy2 = "TYPE:    !yes",
MsgBuyStats = "Status: Buyed",
MsgNoMoney = "Sorry, you don't have enough money."
}
function onSay(cid, words, param)
if  isCreature(getPlayerStorageValue(cid, storages.petUid)) == 0 then
				if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,config.MsgBuy)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,config.MsgBuy2)

				else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Your Pet is alive!.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				end
			else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Your Pet is standing next to you!.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			end
return TRUE			
		end

## Second ##

data -> Talkactions -> talkactions.xml

Code:
	<talkaction words="!yes" script="pets/!yes.lua"/>


data -> Talkactions -> scripts -> pets -> !yes.lua

Code:
local config = {
Money = 50000,
MsgBuy = "You can now summon again your pet!.",
MsgNoMoney = "Sorry, you don't have enough money."
}
function onSay(cid, words, param)
			    	if doPlayerRemoveMoney(cid, config.Money) == 1 then
			   setPlayerStorageValue(cid, storages.petIsOnline, 1)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,config.MsgBuy)
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YALAHARIGHOST)
			else
            			
doPlayerSendCancel(cid,config.MsgNoMoney)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			end   
			
return TRUE
		end
 
Last edited:
Back
Top