GOD Half
Member
- Joined
- May 9, 2010
- Messages
- 179
- Reaction score
- 15
Hi again, I have developed a code to summon a Pet, but I don't understand much about how the "master" or "getCreatureMaster" system works ... I think I'm using it the wrong way. If anyone can explain to me the logic of this system, please. There have been some errors because of this, in the example below my Pet/Summon should say "WEEEEEEEEEEEEEE!", but if already have another one with the same name on the screen, the speaker is the other and not mine. If someone helps me, I did too the "summonName", which in this case would be to identify only this summon, since I intend to do others summons and if not identify who this is, the others will disappear together if I remove the item from the slot. Thank's
Lua:
local configId = {
[1] = {26382}
}
function doRemoveCreatureSummons(cid, name)
if isCreature(cid) and type(name) == "string" then
local c = getCreatureSummons(cid)
if #c > 0 then
for i, v in ipairs(c) do
doRemoveCreature(v)
end
end
end
return true
end
function onThink(interval, lastExecution, thinkInterval)
for _, player in ipairs(Game.getPlayers()) do
local nomePlayer = player:getName()
local positionPlayer = player:getPosition()
local summonPlayer = player:getSummons()
local master = getCreatureMaster(nomePlayer)
if master then
for _, i in pairs(configId) do
if type(i) == 'table' then
NomePet = getItemName(i[1])
if (#summonPlayer > 0) then
for s = 1, #summonPlayer do
summonName = summonPlayer[s]:getName()
summonPos = summonPlayer[s]:getPosition()
end
else
summonPos = nil
end
if isInArray(i, getPlayerSlotItem(nomePlayer, CONST_SLOT_AMMO).itemid) then
if (player:getStorageValue(storage00005) ~= 1) and ((summonName ~= NomePet) or (#summonPlayer == 0)) then
player:setStorageValue(storage00005, 1)
player:setStorageValue(storage00006, 0)
local PetName = doForceSummonCreature(NomePet, positionPlayer)
doConvinceCreature(player, PetName)
doCreatureSay(summonName, "WEEEEEEEEEEEE!", TALKTYPE_ORANGE_1)
end
else
if (summonName == NomePet) and (player:getStorageValue(storage00006) ~= 1) then
player:setStorageValue(storage00005, 0)
player:setStorageValue(storage00006, 1)
doSendMagicEffect(summonPos, CONST_ME_POFF)
doRemoveCreatureSummons(player, NomePet)
end
end
end
end
end
end
return true
end