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

Need some editing

sick

Member
Joined
Feb 5, 2009
Messages
258
Reaction score
6
Location
Lithuania, Vilnius
I've got a problem on my script. I need someone to edit it so that people couldn't use lever when they are standing on empty place, where has to be wall ( when lever pulled ).

klausimas.png



Code:
function onUse(cid, item, frompos, item2, topos)
gatepos1 = {x=1018, y=989, z=6, stackpos=1}
gatepos2 = {x=1018, y=990, z=6, stackpos=1}
getgate1 = getThingfromPos(gatepos1)
getgate2 = getThingfromPos(gatepos2)
if item.uid == 5000 and item.itemid == 1945 and getgate1 and getgate2.itemid == 6857 then
doRemoveItem(getgate1.uid,1)
doRemoveItem(getgate2.uid,1)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 5000 and item.itemid == 1946 and getgate1 and getgate2.itemid == 0 then
doCreateItem(6857,1,gatepos1)
doCreateItem(6857,1,gatepos2)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
return 1
end

Thanks in advance.
 
Lua:
function onUse(cid, item, frompos, item2, topos)
	local gatepos1 = {x=1018, y=989, z=6, stackpos=1}
	local gatepos2 = {x=1018, y=990, z=6, stackpos=1}
	local playerPosition1 = {x=1018, y=989, z=6, stackpos=253}
	local playerPosition2 = {x=1018, y=990, z=6, stackpos=253}
	local getgate1 = getThingfromPos(gatepos1)
	local getgate2 = getThingfromPos(gatepos2)
		if(item.uid == 5000 and item.itemid == 1945 and getgate1 and getgate2.itemid == 6857) then
			doRemoveItem(getgate1.uid,1)
			doRemoveItem(getgate2.uid,1)
			doTransformItem(item.uid,item.itemid+1)
		elseif(item.uid == 5000 and item.itemid == 1946 and getgate1 and getgate2.itemid == 0) then
			if(getCreaturePosition(cid) ~= playerPosition1 and getCreaturePosition(cid) ~= playerPosition2) then
				doCreateItem(6857,1,gatepos1)
				doCreateItem(6857,1,gatepos2)
				doTransformItem(item.uid,item.itemid-1)
			else
				doPlayerSendCancel(cid,"Sorry, not possible.")
			end
		else
			doPlayerSendCancel(cid,"Sorry, not possible.")
		end
	return 1
end
 
Nothing have changed with you edit :/

Then you've done something wrong ^_^, it should work.

EDIT:

I see the problem in your script now. Didn't look at it too well before, you can't do like getgate1 and getgate2 == 0, you should do getgate1 == 0 and getgate2 == 0.. :p, here's the fixed one:

Lua:
function onUse(cid, item, frompos, item2, topos)
        local gatepos1 = {x=1018, y=989, z=6, stackpos=1}
        local gatepos2 = {x=1018, y=990, z=6, stackpos=1}
        local playerPosition1 = {x=1018, y=989, z=6, stackpos=253}
        local playerPosition2 = {x=1018, y=990, z=6, stackpos=253}
        local getgate1 = getThingfromPos(gatepos1)
        local getgate2 = getThingfromPos(gatepos2)
                if(item.uid == 5000 and item.itemid == 1945 and getgate1 == 6857 and getgate2.itemid == 6857) then
                        doRemoveItem(getgate1.uid,1)
                        doRemoveItem(getgate2.uid,1)
                        doTransformItem(item.uid,item.itemid+1)
                elseif(item.uid == 5000 and item.itemid == 1946 and getgate1 == 0 and getgate2.itemid == 0) then
                        if(getCreaturePosition(cid) ~= playerPosition1 and getCreaturePosition(cid) ~= playerPosition2) then
                                doCreateItem(6857,1,gatepos1)
                                doCreateItem(6857,1,gatepos2)
                                doTransformItem(item.uid,item.itemid-1)
                        else
                                doPlayerSendCancel(cid,"Sorry, not possible.")
                        end
                else
                        doPlayerSendCancel(cid,"Sorry, not possible.")
                end
        return 1
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local leverUID = 5000
	-- For northGatePosition just enter the position of the north gate.
	local northGatePosition = {x = 1018, y = 989, z = 6, stackpos = 1}
	-- Leave this as it is.
	local southGatePosition = {x = northGatePosition.x, y = northGatePosition.y+1, z = northGatePosition.z, stackpos = northGatePosition.stackpos
	if(item.uid == leverUID and item.itemid == 1945) then
		if(getThingFromPos(northGatePosition) >= 1) then
			doRemoveItem(getThingFromPos(northGatePosition)
			doRemoveItem(getThingFromPos(southGatePosition)
			doTransformItem(item.uid, item.itemid+1)
		end
	elseif(item.uid == leverUID and item.itemid == 1946) then
		if(getCreaturePosition(cid) ~= playerPosition1 and getCreaturePosition(cid) ~= playerPosition2) then						doCreateItem(6857, 1, getThingFromPos(northGatePosition))
			doCreateItem(6857, 1, getThingFromPos(northGatePosition))
			doCreateItem(6857, 1, getThingFromPos(southGatePosition))
			doTransformItem(item.uid, item.itemid-1)
		else
			doPlayerSendCancel(cid, "Sorry, not possible.")
		end
	end
	return TRUE
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local leverUID = 5000
	-- For northGatePosition just enter the position of the north gate.
	local northGatePosition = {x = 1018, y = 989, z = 6, stackpos = 1}
	-- Leave this as it is.
	local southGatePosition = {x = northGatePosition.x, y = northGatePosition.y+1, z = northGatePosition.z, stackpos = northGatePosition.stackpos
	if(item.uid == leverUID and item.itemid == 1945) then
		if(getThingFromPos(northGatePosition) >= 1) then
			doRemoveItem(getThingFromPos(northGatePosition)
			doRemoveItem(getThingFromPos(southGatePosition)
			doTransformItem(item.uid, item.itemid+1)
		end
	elseif(item.uid == leverUID and item.itemid == 1946) then
		if(getCreaturePosition(cid) ~= playerPosition1 and getCreaturePosition(cid) ~= playerPosition2) then						doCreateItem(6857, 1, getThingFromPos(northGatePosition))
			doCreateItem(6857, 1, getThingFromPos(northGatePosition))
			doCreateItem(6857, 1, getThingFromPos(southGatePosition))
			doTransformItem(item.uid, item.itemid-1)
		else
			doPlayerSendCancel(cid, "Sorry, not possible.")
		end
	end
	return TRUE
end


Damn, didn't thought that the simple lever can cause so many problems. Im just doing the same as you said, just without your comments on script. And now it just makes an error...
 
Damn, didn't thought that the simple lever can cause so many problems. Im just doing the same as you said, just without your comments on script. And now it just makes an error...

What error and what version of TFS are you using?
 
What error and what version of TFS are you using?

Im using TFS 0.3.5 version.

And the error sounds like this :

[20/10/2009 23:18:14] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/lever3.lua)
[20/10/2009 23:18:14] data/actions/scripts/other/lever3.lua:5: '}' expected (to close '{' at line 4) near 'if'
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
        local leverUID = 5000
        -- For northGatePosition just enter the position of the north gate.
        local northGatePosition = {x = 1018, y = 989, z = 6, stackpos = 1}
        -- Leave this as it is.
        local southGatePosition = {x = northGatePosition.x, y = northGatePosition.y+1, z = northGatePosition.z, stackpos = northGatePosition.stackpos}
        if(item.uid == leverUID and item.itemid == 1945) then
                if(getThingFromPos(northGatePosition) >= 1) then
                        doRemoveItem(getThingFromPos(northGatePosition)
                        doRemoveItem(getThingFromPos(southGatePosition)
                        doTransformItem(item.uid, item.itemid+1)
                end
        elseif(item.uid == leverUID and item.itemid == 1946) then
                if(getCreaturePosition(cid) ~= playerPosition1 and getCreaturePosition(cid) ~= playerPosition2) then                                            doCreateItem(6857, 1, getThingFromPos(northGatePosition))
                        doCreateItem(6857, 1, getThingFromPos(northGatePosition))
                        doCreateItem(6857, 1, getThingFromPos(southGatePosition))
                        doTransformItem(item.uid, item.itemid-1)
                else
                        doPlayerSendCancel(cid, "Sorry, not possible.")
                end
        end
        return TRUE
end

Sorry lol, forgot a }.... :p, should be working now.
 
Back
Top