• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Switch Thing Remover

igorbr

New Member
Joined
Jan 9, 2008
Messages
34
Reaction score
0
It's to many complex:

this is a script of switchs to remove something from a specific pos:
PARAMETERS

switchUniqueId = uniqueid of switch, i use 3500
itemid = id of item that will be removed
pos = position of item
scapePos = if something is on the pos, will be teleported to this pos (items and creatures)
duration = the removal duration

lets go script:
in data/actions/scripts add a file named switchThingRemover.lua
and put inside this:
PHP:
-- Switch advanced script created by Shadowman.
-- It's more than Perfect!

-- CONFIGURATIONS
-- ADD NEW ITEMS TO REMOVE HERE
local removeThingConfig = {
	[3500]={ -- unique id of switch
		[1] = {itemid = 1025, pos = {x=580, y=939, z=10}, scapePos = {x=581, y=939, z=10}, duration = 5*60*1000}, -- first item to remove (only this have duration(is for all items))
		[2] = {itemid = 1025, pos = {x=581, y=939, z=10}, scapePos = {x=581, y=939, z=10}} -- second item to remove
	},
}

-- DONT EDIT HERE
function onUse(cid, item, frompos, item2, topos)
	if removeThingConfig[item.uid] then
		if item.itemid == 1945 then
			local canAddEvent = 0
			for a = 1, table.maxn(removeThingConfig[item.uid]) do
				local itemPos = {x=removeThingConfig[item.uid][a].pos.x,y=removeThingConfig[item.uid][a].pos.y,z=removeThingConfig[item.uid][a].pos.z,stackpos=1}
				local itemEx = getTileThingByPos(itemPos)
				if removeThingConfig[item.uid][1].duration > 0 then
					canAddEvent = canAddEvent + 1
				end
				doRemoveItem(itemEx.uid)
				doSendMagicEffect(removeThingConfig[item.uid][a].pos, CONST_ME_POFF)
			end
			if canAddEvent == table.maxn(removeThingConfig[item.uid]) then
				eventID = addEvent(doReloadParameters, removeThingConfig[item.uid][1].duration, item)
			end
			doTransformItem(item.uid, 1946)
		elseif item.itemid == 1946 then
			doReloadParameters(item)
			stopEvent(eventID)
		end
	else
		return false
	end
	return true
end

function doReloadParameters(item)
	for a = 1, table.maxn(removeThingConfig[item.uid]) do
		local i = 0
		while (i == 0) do
		local getThing = getTileThingByPos({x=removeThingConfig[item.uid][a].pos.x,y=removeThingConfig[item.uid][a].pos.y,z=removeThingConfig[item.uid][a].pos.z,stackpos=1})
			if isMovable(getThing.uid) == true then
				doTeleportThing(getThing.uid, removeThingConfig[item.uid][a].scapePos)
			else
				i = 1
			end
		end
		doCreateItem(removeThingConfig[item.uid][a].itemid, 1, removeThingConfig[item.uid][a].pos)
		doSendMagicEffect(removeThingConfig[item.uid][a].pos, CONST_ME_TELEPORT)
		doTransformItem(item.uid, 1945)
	end
	return true	
end

in actions.xml add the line:
PHP:
<action uniqueid="3500" event="script" value="switchThingRemover.lua"/>

like?
rep for me xD :)

credts: me (Shadowman)
 
Back
Top