warriorfrog
Active Member
- Joined
- Jul 29, 2015
- Messages
- 334
- Reaction score
- 35
I have this spell that pull/push other players for their back...
It already check if this SQM is valid but i would like to check other think:
I would like to have a list of items for example [2595, 2103] (PARCEL/HONEYFLOWER)
That if there is some of this items on the SQM player would be teleported, it blocks the teleport...
How to do it?
It already check if this SQM is valid but i would like to check other think:
I would like to have a list of items for example [2595, 2103] (PARCEL/HONEYFLOWER)
That if there is some of this items on the SQM player would be teleported, it blocks the teleport...
How to do it?
Code:
local config = {
effect = 2,
dir = {
[0] = 2,
[1] = 3,
[2] = 0,
[3] = 1
}
}
local function isWalkable(cid, pos)
if isCreature(getTopCreature(pos).uid) then
return true
end
if not pos or type(pos) ~= "table" then
return false
end
pos.stackpos = 0
if not getThingFromPos(pos) then
return false
end
if getTileThingByPos(pos).uid ~= 0 then
local n = getTileInfo(pos)
if (doTileQueryAdd(cid, pos) == 1) then
return true
end
return false
end
if getThingFromPos(pos) and getThingFromPos(pos).uid > 0 and getThingFromPos(pos).itemid > 0 then
if hasProperty(getThingFromPos(pos).uid, 2) then
return false
end
end
if getThingFromPos(pos) and getThingFromPos(pos).uid > 0 and getThingFromPos(pos).itemid > 0 then
if getTilePzInfo(pos) then
return false
end
end
return true
end
function onCastSpell(cid, var)
local target = variantToNumber(var)
if isCreature(cid) and isCreature(target) then
local lookDir = getCreatureLookDirection(target)
local jPos = getPositionByDirection(getThingPos(target), config.dir[lookDir], 1)
if (isWalkable(cid, jPos) == false) then
doPlayerSendCancel(cid, "Back position is not reachable.")
return false
elseif (isWalkable(cid, jPos) == true) then
doSendMagicEffect(getThingPos(target), config.effect)
doTeleportThing(target, jPos)
return true
end
end
return true
end