Hello, is anyone able to help me? give or add a function that could not use a spell to NO LOGOUT (google translate)
Code:
local function f(c)
if isMonster(c) then
doRemoveCreature(c)
end
end
local summonName = "SUMMON"
local summonTime = 100
function onCastSpell(cid, var)
local p = getThingPos(cid)
local summons = getCreatureSummons(cid)
if getTileInfo(p).protection then
doCreatureSay(cid, 'You cannot summon in PZ!', TALKTYPE_ORANGE_1, false, cid, p)
doSendMagicEffect(p, CONST_ME_POFF)
elseif #summons > 0 then
local sumonCheck = false
for _, pid in ipairs(summons) do
if getCreatureName(pid) == summonName then
sumonCheck = true
end
end
if sumonCheck then
doPlayerSendCancel(cid, 'You can\'t summon more than one.')
doSendMagicEffect(p, CONST_ME_POFF)
else
local r = doSummonMonster(cid, summonName)
if r == 1 then
doSendMagicEffect(getPlayerPosition(cid), 223)
doPlayerSendCancel(cid, summonName .." is ready to help you.")
addEvent(f, summonTime*1000, getCreatureSummons(cid)[1])
return true
else
doPlayerSendDefaultCancel(cid, r)
end
end
else
local r = doSummonMonster(cid, summonName)
if r == 1 then
doSendMagicEffect(getPlayerPosition(cid), 223)
doPlayerSendCancel(cid, summonName .." is ready to help you.")
addEvent(f, summonTime*1000, getCreatureSummons(cid)[1])
return true
else
doPlayerSendDefaultCancel(cid, r)
end
end
end