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

[Help] Lua Script!

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,782
Solutions
25
Reaction score
491
Location
Sweden
P.S *I don't have the function doRelocate*

bugx.jpg


LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doTransformItem(getThingfromPos({x=32410, y=32231, z=10, stackpos=0}).uid, item.itemid == 1945 and 1284 or 508)
	doTransformItem(getThingfromPos({x=32410, y=32232, z=10, stackpos=0}).uid, item.itemid == 1945 and 1284 or 508)
	doTransformItem(getThingfromPos({x=32411, y=32231, z=10, stackpos=0}).uid, item.itemid == 1945 and 1284 or 493)
	doTransformItem(getThingfromPos({x=32411, y=32232, z=10, stackpos=0}).uid, item.itemid == 1945 and 1284 or 493)
	return 1, doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Try this:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local positions = {
		{x=32410, y=32231, z=10},
		{x=32410, y=32232, z=10},
		{x=32411, y=32231, z=10},
		{x=32411, y=32232, z=10}
	}
	local toPos = {x=, y=, z=10}  -- Where to teleport?
	local transform = item.itemid == 1945 and 1284 or {508,508,493,493}
	
	for pos = 1, #positions do
		positions[pos].stackpos = 253
		local player = getThingFromPos(positions[pos]).uid
		
		if isCreature(player) then
			doTeleportThing(player, toPos)
		end
		positions[pos].stackpos = 0
		
	    doTransformItem(getThingfromPos(positions[pos]).uid, (type(transform) == "table" and transform[pos] or transform))
	end
    return 1, doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
then write urself? xD

LUA:
function doRelocate(pos, toPos)
	local item, c = 0,0;
	for i = 1, 255 do
		pos.stackpos = i;
		item  = getThingFromPos(pos);
		if(item>0) then
			doTeleportThing(item.uid, toPos);
			c =c+1;
		end
	end
	return c;
end
 
Code:
function doRelocate(pos, toPos)
	pos.stackpos = 1
	while getThingfromPos(pos).uid > 0 do
		doTeleportThing(getThingFromPos(pos).uid, toPos)
		pos.stackpos = pos.stackpos + 1
	end
end
? ^^
 
that can't happen, stackpos 1 is same as 255 except for 255 is only moveable :p
but it's rare that unmoveable item has stackpos 1 and there are items under it ^^
 
I did have it, was gonna add it, compiling working 100%, and just for the hekk of it, I search for it and woupido, it's there. Don't know why I thought I didn't have it... well anyway, if somoene is looking for a smiliar script, here is the one i USE:

LUA:
  -- rook lever by QuaS~
local posi3 = {x=32412, y=32231, z=10} --
poss = {
[1] = {x=32411, y=32231, z=10},
[2] = {x=32410, y=32231, z=10},
[3] = {x=32410, y=32232, z=10},
[4] = {x=32411, y=32232, z=10}
}

local lever = {
[1] = {x=32413, y=32230, z=10},
[2] = {x=32414, y=32251, z=10}
}
local itemids = 1284
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if item.itemid == 1945 then
                doCreateItem(itemids,poss[1])
                if getTileItemById(poss[2],508).itemid ~= nil then
                        doTransformItem(getTileItemById(poss[2],508).uid,itemids)
                end
                if getTileItemById(poss[3],508).itemid > 0 then
                        doTransformItem(getTileItemById(poss[3],508).uid,itemids)
                end
		if getTileItemById(poss[4],493).itemid > 0 then
                        doTransformItem(getTileItemById(poss[4],493).uid,itemids)
                end
                for i=1,#lever do
                        if lever[i].x == fromPosition.x then
                                o = i
                        end
                end
                if o == 1 then
                        b = 2
                else
                        b = 1
                end
                doTransformItem(item.uid,item.itemid+1)
                doTransformItem(getTileItemById(lever[b],1945).uid,1946)
        elseif item.itemid == 1946 then
                for p = 1,#poss do
                doRelocate(poss[p], posi3)
                end
                for z =1,#poss do
                                poss[z].stackpos = 254
                                if getThingfromPos(poss[z]).itemid > 1000 then
                                        doRemoveItem(getThingfromPos(poss[z]).uid)
                                end
                                poss[z].stackpos = 1
                                if getThingfromPos(poss[z]).itemid > 1000 then
                                        doRemoveItem(getThingfromPos(poss[z]).uid)
                                end

                end
                for i=1,#lever do
                        if lever[i].x == toPosition.x then
                                o = i
                        end
                end
                if o == 1 then
                        b = 2
                else
                        b = 1
                end
                doCreateItem(493,poss[1])
                doCreateItem(1284,poss[2])
                doCreateItem(1284,poss[3])
                doCreateItem(508,poss[2])
                doCreateItem(508,poss[3])
                doCreateItem(493,poss[4])
                doTransformItem(item.uid,item.itemid-1)
                doTransformItem(getTileItemById(lever[b],1946).uid,1945)
        end
        return TRUE
end

This script works but still gives errors;) something tile not found, could not tansform bla bla! PS. STILL WORKS
 
Back
Top