GOD Half
Member
- Joined
- May 9, 2010
- Messages
- 179
- Reaction score
- 15
Hi guys, I need fixing this problem. I did this script to summon some monsters, but he always summons the other players too, can anyone help me, please? Thank's
Lua:
local configId = {
[1] = {"Corym Charlatan"}
}
function onCastSpell(creature, variant)
for _, player in ipairs(Game.getPlayers()) do
local namePlayer = player:getName()
local positionPlayer = player:getPosition()
local summonPlayer = player:getSummons()
local target = player:getTarget()
local master = getCreatureMaster(namePlayer)
if master then
for _, i in pairs(configId) do
if type(i) == 'table' then
NamePet = i[1]
if (#summonPlayer > 0) then
for _, SummonID in ipairs(summonPlayer) do
summonName = getCreatureName(SummonID)
end
else
summonName = "no summon summoned"
end
if (summonName ~= NamePet) then
if target then
if isPlayer(target) or isMonster(target) then
local positionTarget = getCreaturePosition(target)
for r = 1, math.random(2,5) do
local PetNameSummon = doForceSummonCreature(NamePet, positionTarget)
doConvinceCreature(player, PetNameSummon)
end
end
else
for r = 1, math.random(2,5) do
local PetNameSummon = doForceSummonCreature(NamePet, positionPlayer)
doConvinceCreature(player, PetNameSummon)
end
end
else
doPlayerSendCancel(player, "You already have summoned "..NamePet..".")
return false
end
end
end
end
end
return true
end