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

A few useful functions (CHECK!)

Colandus

Advanced OT User
Senator
Joined
Jun 6, 2007
Messages
2,434
Solutions
19
Reaction score
219
Location
Sweden
Lua:
-- Returns the top item on a tile.
function getTopItem(pos)
    pos.stackpos = 1 + getTopCreature(pos).itemid
    return getTileThingByPos(pos)
end

-- Teleport a creature with effects, invisible players will not show effects!
function doTeleportCreature(cid, pos, pushmove)
    if(not isCreature(cid)) then
        return FALSE
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doSendMagicEffect(pos, CONST_ME_TELEPORT)
    end
   
    doTeleportThing(cid, pos, pushmove)
    return TRUE
end

-- Check whether a position is free (for a player to walk on)... can't remember if it works tho :D
function isPositionFree(pos)
    local thing = getTopCreature(pos)
    if isCreature(thing.uid) == FALSE then
        pos.stackpos = 0
        thing = getThingfromPos(pos)
       
        if thing.uid > 0 then
            while hasProperty(thing.uid, CONST_PROP_BLOCKINGANDNOTMOVEABLE) == FALSE do
                pos.stackpos = pos.stackpos + 1
                thing = getThingfromPos(pos)
               
                if thing.uid == FALSE then
                    return TRUE
                end
            end
        end
    end
    return FALSE
end

:)
 
Last edited:
Code:
function doTeleportCreature(cid, pos, move)

But where's used move parameter?
 
Forgot to use it :p It's for "doTeleportThing(cid, newpos[, pushmove = TRUE])"

It's an optional parameter.
 
god blesses ur brain, col
 
Lua:
-- Teleport a creature with effects, invisible players will not show effects!
function doTeleportCreature(cid, pos, pushmove)
        if(isCreature(cid) and not isPlayerGhost(cid)) then
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                doTeleportThing(cid, pos, pushmove)
                doSendMagicEffect(pos, CONST_ME_TELEPORT)
                return TRUE
        end
       
        return FALSE
end
hahahhhaaa, invisible player won't teleportet.

Better:
Lua:
-- Teleport a creature with effects, invisible players will not show effects!
function doTeleportCreature(cid, pos, pushmove)
	if isCreature(cid) == TRUE then
		if(isPlayer(cid) and isPlayerGhost(cid) == FALSE) or (isMonster(cid) == TRUE) or (isNpc(cid) == TURE) then
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			doSendMagicEffect(pos, CONST_ME_TELEPORT)
		end
		return doTeleportThing(cid, pos, pushmove)
	end
	return FALSE
end
 
Lua:
-- Teleport a creature with effects, invisible players will not show effects!
function doTeleportCreature(cid, pos, pushmove)
        if(isCreature(cid) and not isPlayerGhost(cid)) then
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                doTeleportThing(cid, pos, pushmove)
                doSendMagicEffect(pos, CONST_ME_TELEPORT)
                return TRUE
        end
       
        return FALSE
end
hahahhhaaa, invisible player won't teleportet.

Better:
Lua:
-- Teleport a creature with effects, invisible players will not show effects!
function doTeleportCreature(cid, pos, pushmove)
	if isCreature(cid) == TRUE then
		if(isPlayer(cid) and isPlayerGhost(cid) == FALSE) or (isMonster(cid) == TRUE) or (isNpc(cid) == TURE) then
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			doSendMagicEffect(pos, CONST_ME_TELEPORT)
		end
		return doTeleportThing(cid, pos, pushmove)
	end
	return FALSE
end

yess lol :p I forgot to edit hehe! Fixed it in my serv but i forgot to fix here :D

Thanks for notifying me ;)
 
heya colandus, I need a little upgrade of your ispositionfree function
I need it to check if pos is PZ and HOUSETILE plz I need it for my new spell
since I don't want to script many checkings(getTilePZinfo, getTileHouseinfo)
 
Back
Top