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

Lua 2 scripts similar errors

soul4soul

Intermediate OT User
Joined
Aug 13, 2007
Messages
1,875
Solutions
3
Reaction score
128
Location
USA
everything works now thanks for the help
 
Last edited:
Humm, there is somthng i dont get it can u tell me why this checks? :D

Code:
  if(useFromPos.x == 65535) then
        useFromPos = {x=playerPos.x, y=playerPos.y, z=playerPos.z}
    end


    if(topos.x == 65535 or (topos.x == 31 and topos.y == 31 and topos.z == 7)) then
        return FALSE
    end

And is this a normal item that when use on ground it create a teleport with a fixed destination and is removed after time and have cool down?
 
it checks to make sure ur not using it on/under yourself.

yes its an item. EX. hmm lets just say a frozenstar light. you use it on the ground and it creates a portal where u use it.
it dissappears after 5seconds.
yes it has cool down but that also doesnt work.
Code:
exhaustion.set(cid, item.itemid, 60*2)--2minutes cooldown
 
here is the teleport one : (modified - change the exhause.set and .get)
Lua:
local cooldown = 120   -- in seconds
local storage = 7374


local condition = createConditionObject(CONDITION_INFIGHT)
setConditionParam(condition, CONDITION_PARAM_TICKS, (10 * 1000))

 
local 	function removePortal(pos)
			if getTileItemById(pos,1387).uid > 0 then
				doRemoveItem(getTileItemById(pos,1387).uid)
				doSendMagicEffect(pos, CONST_ME_POFF)
			end
			return true
		end
	
local function isWalkable(cid, pos)
	pos.stackpos = 253
	if (doTileQueryAdd(cid, pos) == 1 and getTilePzInfo(pos) == FALSE and isCreature(getThingFromPos(pos).uid) == FALSE) then
		return TRUE
	end
	return FALSE
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local portalPos = {x=92, y=114, z=7}
    local p = getCreaturePosition(cid)
	if(getPlayerStorageValue(cid, storage) > os.time()) then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Cool Down -->  " .. os.date("%M : %S",  (getPlayerStorageValue(cid,storage)-os.time()) ) .."") and  doSendMagicEffect(p, CONST_ME_POFF) and doCreatureAddHealth(cid,-500)
	end
	if (toPosition.x == p.x and toPosition.y == p.y and toPosition.z == p.z) then
		return doPlayerSendCancel(cid,"You cant create portal in your place")
	end
        if itemEx.itemid == 1387 then
                return doPlayerSendCancel(cid,"You cant create on another portal.")
        end
	if (toPosition.x == portalPos.x and toPosition.y == portalPos.y and toPosition.z == portalPos.z) then
		return doPlayerSendCancel(cid,"You cannot create a portal in the same place you are going to!")
	end
	if getThingFromPos({x=toPosition.x,y=toPosition.y,z=toPosition.z,stackpos = 255},false).uid > 0 or not isWalkable(cid, toPosition) then
		return doPlayerSendCancel(cid,"You cannot create a portal here!")
	end
	
	doCreateTeleport(1387,portalPos,toPosition)
	doSendMagicEffect(toPosition, CONST_ME_ENERGYAREA)
	doSendDistanceShoot(p, toPosition, CONST_ANI_ENERGY)
	doSendMagicEffect(p, CONST_ME_MAGIC_GREEN)
	addEvent(removePortal, 5 * 1000, toPosition)
	doTargetCombatCondition(0, cid, condition, CONST_ME_NONE)
		if getPlayerGroupId(cid) < 3 then   --make the cool down to players
			setPlayerStorageValue(cid, storage, os.time() + cooldown)
		end
	
	 
	return true
end
 
that script works i just tested it.

btw i fixed the first script based off of what u did on the second script so ty
rep ++
 
Last edited:
Back
Top