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

add more gates

xLosT

Member
Joined
Jan 11, 2010
Messages
1,021
Reaction score
13
Location
Brasil, Rio Grande do Sul
need to add two more gates

The script removes only a wall, need to put 3 to remove wall

PHP:
local gatepos = {x=313, y=592, z=7, stackpos=1}

function onUse(cid, item, frompos, item2, topos)
local getgate = getThingfromPos(gatepos)

	if item.itemid == 1945 and getgate.itemid == 8538 then
		doRemoveItem(getgate.uid, 1)
		doTransformItem(item.uid, item.itemid+1)
	elseif item.itemid == 1946 and getgate.itemid == 0 then
		doCreateItem(8538, 1, gatepos)
		doTransformItem(item.uid, item.itemid-1)
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end
return 1
end
 
Last edited:
LUA:
local c =  {
door1 = {x = 313, y = 592, z = 7},
door2 = {x = x, y = x, z = x}, <-- new gate2
door3 = {x = x, y = x, z = x}  <-- new gate3
}

function onUse(cid, item, frompos, item2, topos)
local getgate = getThingfromPos(gatepos)

    if item.itemid == 1945 and getgate.itemid == 8538 then
        doRemoveItem(getgate.uid, 1)
        doTransformItem(item.uid, item.itemid+1)
    elseif item.itemid == 1946 and getgate.itemid == 0 then
        doCreateItem(8538, 1, c.door1)
        doCreateItem(8538, 1, c.door2)
        doCreateItem(8538, 1, c.door3)
        doTransformItem(item.uid, item.itemid-1)
    else
        doPlayerSendCancel(cid,"Sorry, not possible.")
    end
return 1
end
 
hmm try
LUA:
local c = 
{
door1 = {x = 313, y = 592, z = 7, stackpos = 1},
door2 = {x = x, y = x, z = x, stackpos = 1},
door3 = {x = x, y = x, z = x, stackpos = 1  
}

function onUse(cid, item, frompos, item2, topos)
local getgate = getThingfromPos(c)

    if item.itemid == 1945 and getgate.itemid == 8538 then
        doRemoveItem(getgate.uid, 1)
        doTransformItem(item.uid, item.itemid+1)
    elseif item.itemid == 1946 and getgate.itemid == 0 then
        doCreateItem(8538, c.door1, c.door2, c.door3)
        doTransformItem(item.uid, item.itemid-1)
    else
        doPlayerSendCancel(cid,"Sorry, not possible.")
    end
return 1
end

in your console have errors not load script.. ?
 
LUA:
local gatepos1 = {x=313, y=592, z=7, stackpos=1}
local gatepos2 = {x=314, y=592, z=7, stackpos=1}
local gatepos3 = {x=315, y=592, z=7, stackpos=1}

function onUse(cid, item, frompos, item2, topos)
    local getgate1 = getThingfromPos(gatepos1)
    local getgate2 = getThingfromPos(gatepos2)
    local getgate3 = getThingfromPos(gatepos3)

    if item.itemid == 1945 then
        doRemoveItem(getgate1.uid, 1)
        doRemoveItem(getgate2.uid, 1)
        doRemoveItem(getgate3.uid, 1)
        doTransformItem(item.uid, item.itemid+1)
    elseif item.itemid == 1946 then
        doCreateItem(8538, 1, gatepos1)
        doCreateItem(8538, 1, gatepos2)
        doCreateItem(8538, 1, gatepos3)
        doTransformItem(item.uid, item.itemid-1)
    else
        doPlayerSendCancel(cid,"Sorry, not possible.")
    end
    return 1
end
How about this? not the most elegant way to do it, but it should work, remember to change the coordenates!
it would also help to tell us what the actual error is, not where it is
also, please try to learn better english :)


@Cronoxs
u were doing it wrong cause u were accessing the whole array on getThingfromPos, you had to do something like "c.door1" to get that door, you then had to do the same for the other ones(like I did with my code)
 
Try
LUA:
local config =
{
	gateId 		= 0,
	positions 	=
	{
		{x = 0, y = 0, z = 0},
		{x = 0, y = 0, z = 0},
		{x = 0, y = 0, z = 0}
	}
}

function onUse(cid, item, fromPos, itemEx, toPos)
	for _, pos in config.positions do
		local gate = getTileItemById(pos, config.gateId)
		if (gate.uid > 0 and gate.itemid == config.gateId) then
			doRemoveItem(gate.uid, 1)
			doTransformItem(item.uid, item.itemid + 1)
		else
			doCreateItem(config.gateId, 1, pos)
			doTransformItem(item.uid, item.itemid - 1)
		end
	end
	return true
end
 
i found script
thx for all
PHP:
local gatepos = {
	{x = 701, y = 848, z = 7}, {x = 701, y = 847, z = 7}, {x = 701, y = 846, z = 7}  
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for i = 1, 3 do
		local check = getTileItemById(gatepos[i], 3361)
		if item.itemid == 1945 then
			if check.uid >= 1 then
				doRemoveItem(check.uid, 1)
			end
		elseif item.itemid == 1946 then
			if check.uid < 1 then
				doCreateItem(3361, 1, gatepos[i])
			end
		end
	end
	
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Back
Top