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

Lua Petscript

Exmortis

Member
Joined
Jun 27, 2008
Messages
189
Reaction score
5
I've got a problem with my Pet system a TFS 0.2.7 server.
When I logout when my pet is summoned, i get alot of errors in console.
Everything works the way I want, its just the errors that annoys me.
Imagine when i open the server and 30 people are summoning their pets and logging then out. :D
Would be a huge spam apartment in the serverlogs.
If anyone can solve the problem or just find a way to help me get rid of the errors, that'd be swell.
Ofc, rep.

Original script:
http://otland.net/f81/many-my-fully-lua-pet-system-many-features-3432/#post47258
I get the following error:
Code:
Lua Script Error: [TalkAction Interface]
in a timer event called from:
data/talkactions/scripts/pets/!pet.lua:onSay

luaGetPlayerStorageValue<>. Player not found

Lua Script Error: [TalkAction Interface]
in a timer event called from:
data/talkactions/scripts/pets/!pet.lua:onSay

luaGetPlayerStorageValue<>. Player not found

data\talkactions\scripts\pets\!pet.lua
Code:
dofile("./petConfig.lua")

function doPlayerAddSummon(cid, name, pos)
    local MyCreature = doSummonCreature(name, pos)    
    doConvinceCreature(cid, MyCreature)
    return MyCreature
end


local myPet = ""
local myPetUid = 0

function onSay(cid, words, param)
    
    if isExhausted(cid) == 1 then
        return 0
    end
    if getPlayerStorageValue(cid, storages.petMag) == -1 then
        setPlayerStorageValue(cid, storages.petMag, 0)
    end
    if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 0 then
        if getTilePzInfo(getCreaturePosition(cid)) == 0 then
            if getPlayerStorageValue(cid, storages.petIsOnline) == 1 or getPlayerStorageValue(cid, storages.petIsOnline) == -1 then
                for i = 1, #pets do
                    if isInArray(pets[i].vocations, getPlayerVocation(cid)) == 1 then
                        for k = 1, #pets[i].pets do                            
                            if pets[i].pets[k].level <= getPlayerLevel(cid) then
                                myPet = pets[i].pets[k].name
                                break
                            end
                        end
                    break
                    end
                end
                myPetUid = doPlayerAddSummon(cid, myPet, getCreaturePosition(cid))
                if myPetUid ~= -1 then
                    setPlayerStorageValue(cid, storages.petUid, myPetUid)
                    if getPlayerStorageValue(cid, storages.petDamage) ~= 0 and getPlayerStorageValue(cid, storages.petDamage) ~= -1  then
                        if getPlayerStorageValue(cid, storages.petDamage) < getCreatureMaxHealth(getPlayerStorageValue(cid, storages.petUid)) then
                            doCreatureAddHealth(getPlayerStorageValue(cid, storages.petUid), getPlayerStorageValue(cid, storages.petDamage)*-1)
                        end
                    end
                    doChangeSpeed(myPetUid, getCreatureBaseSpeed(cid) - getCreatureBaseSpeed(myPetUid))
                    doCreatureSay(myPetUid, 'Hello!', TALKTYPE_ORANGE_1)
                    addMana({cid = cid})
                    setPlayerStorageValue(cid, storages.petIsOnline, 2)
                else
                    doPlayerSendCancel(cid, 'Not enough room.')
                end
            else            
                doPlayerSendCancel(cid, 'Your pet died! You have to revive it.')
            end
        else
            doPlayerSendCancel(cid, 'You cannot summon your pet in PZ.')
        end        
    else
    local daPet = getPlayerStorageValue(cid, storages.petUid)
        setPlayerStorageValue(cid, storages.petDamage, getCreatureMaxHealth(daPet) - getCreatureHealth(daPet))
        doCreatureSay(daPet, 'Byebye !', TALKTYPE_ORANGE_1)
        setPlayerStorageValue(cid, storages.petIsOnline, 1)
        doSendMagicEffect(getCreaturePosition(daPet), CONST_ME_POFF)
        doRemoveCreature(daPet)
    end
    return setExhausted(cid)
end
 
Last edited:
Hmm... try editing this function (it's in petConfig.lua)
Code:
function addMana(a)
	local cid = a.cid
[COLOR="red"]	if isPlayer(cid) then[/COLOR]
		local petManaMax = getPlayerLevel(cid)*manaGainPerLevel
		if getPlayerStorageValue(cid, storages.petMana) < petManaMax then
			if petManaMax - getPlayerStorageValue(cid, storages.petMana) < 10 then
				setPlayerStorageValue(cid, storages.petMana, getPlayerStorageValue(cid, storages.petMana) + petManaMax - getPlayerStorageValue(cid, storages.petMana))
			else
				setPlayerStorageValue(cid, storages.petMana, getPlayerStorageValue(cid, storages.petMana) + 10)
			end
			addEvent(addMana, manaGainTicks, {cid = cid})
		else
			setPlayerStorageValue(cid, storages.petIsHealing, 0)
		end
[COLOR="red"]	end[/COLOR]
end
 
Hmm... try editing this function (it's in petConfig.lua)
Code:
function addMana(a)
	local cid = a.cid
[COLOR="red"]	if isPlayer(cid) then[/COLOR]
		local petManaMax = getPlayerLevel(cid)*manaGainPerLevel
		if getPlayerStorageValue(cid, storages.petMana) < petManaMax then
			if petManaMax - getPlayerStorageValue(cid, storages.petMana) < 10 then
				setPlayerStorageValue(cid, storages.petMana, getPlayerStorageValue(cid, storages.petMana) + petManaMax - getPlayerStorageValue(cid, storages.petMana))
			else
				setPlayerStorageValue(cid, storages.petMana, getPlayerStorageValue(cid, storages.petMana) + 10)
			end
			addEvent(addMana, manaGainTicks, {cid = cid})
		else
			setPlayerStorageValue(cid, storages.petIsHealing, 0)
		end
[COLOR="red"]	end[/COLOR]
end
i will try to make one, i dont know if will work

Lua:
-- Little modify script by RaikND
function addMana(a)
local cid = a.cid
if not isPlayer(cid) then
        return true
end

local petManaMax = getPlayerLevel(cid)*manaGainPerLevel
if petManaMax - getPlayerStorageValue(cid, storages.petMana) < 10 then
setPlayerStorageValue(cid, storages.petMana, getPlayerStorageValue(cid, storages.petMana) + petManaMax - getPlayerStorageValue(cid, storages.petMana))
return true
end

if getPlayerStorageValue(cid, storages.petMana) < petManaMax then
addEvent(addMana, manaGainTicks, {cid = cid})
else
setPlayerStorageValue(cid, storages.petIsHealing, 0)
end
return true
end
 
Last edited:
Back
Top