• 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] Jump over Fence script

Spoking

Oldschool Developer
Joined
Sep 4, 2007
Messages
434
Reaction score
34
If you are on the left of the fence, you will teleport to the right on use.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local position = getThingPos(item.uid)
local playerpos = getCreaturePosition(cid)
local pos1 = {position.x - 1, y=position.y, z=position.z}

	if pos1 == playerpos then
		doTeleportThing(cid, {x=position.x + 1, y=position.y, z=position.z}, true)
		doSendMagicEffect(getCreaturePosition(cid), 10)
	else
		doPlayerSendCancel(cid, "Positions aren't correct.")
	end
end

Why is this not working? it's always saying: "positions aren't correct."
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local position = getThingPos(item.uid)
local playerpos = getCreaturePosition(cid)
local pos1 = {[COLOR=Red]x=[/COLOR]position.x - 1, y=position.y, z=position.z}

    if pos1 == playerpos then
        doTeleportThing(cid, {x=position.x + 1, y=position.y, z=position.z}, true)
        doSendMagicEffect(getCreaturePosition(cid), 10)
    else
        doPlayerSendCancel(cid, "Positions aren't correct.")
    end
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k = getThingPos(cid)
	local p = {x = k.x - 1, y = k.y, z = k.z}
	local c = getTileItemById(p, item.uid).uid
	if c > 0 then
		doTeleportThing(cid, {x = k.x + 1, y = k.y, z = k.z}, true)
		doSendMagicEffect(k, 10)
	else
		doPlayerSendCancel(cid, "Positions aren't correct.")
	end
	return true
end
 
For some reason, it's still saying: Positions aren't correct.
Why!?!

Could it be because the fence is an action ID and not an unique ID?
 
idk what the dick your trying to do, i just copy pasted ur script, ur the one who is doing wrong either way you can post what ur trying to do exactly................
 
If you are on the left side of the fence, and use the fence, teleport to the right side of the fence.
 
Lua:
function onUse(cid, item, frompos, item2, topos)
local playerpos = {x=frompos.x-1, y=frompos.y, z=frompos.z, stackpos=253}
local newpos = {x=frompos.x+1, y=frompos.y, z=frompos.z}
local player = getThingfromPos(playerpos)
if player.itemid >= 1 then
doTeleportThing(player.uid,newpos)
else
doPlayerSendCancel(cid,"Stay in right positions.")
end
end
Try it :D
 
I think it won't work, because the player have to be on his fromPosition.x-1, which he can't be(if I'm thinking right) xd
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local i = getThingPos(item.uid)
local pp = getCreaturePosition(cid)
local toPos = {x = i.x+1, i.y, i.z}

    if i then
        p = {x = pp.x-1, y = pp.y, z = pp.z}
        if p then
            doTeleportThing(cid, toPos, FALSE)
        end
    end
return true
end
That should work I think ;s
 
I think it won't work, because the player have to be on his fromPosition.x-1, which he can't be(if I'm thinking right) xd

Lol in actions frompos means pos from item with action/uniqueid...(But in movements tile from where player went to tile with actionid.)

Your script is that what you say in my quote...
 
@wesoly
i edited your script and now it works both ways left to right and right to left.
Lua:
function onUse(cid, item, frompos, item2, topos)
local playerposleft = {x=frompos.x-1, y=frompos.y, z=frompos.z, stackpos=253}
local playerposright = {x=frompos.x+1, y=frompos.y, z=frompos.z, stackpos=253}
local newposright = {x=frompos.x+1, y=frompos.y, z=frompos.z}
local newposleft = {x=frompos.x-1, y=frompos.y, z=frompos.z}
local playerleft = getThingfromPos(playerposleft)
local playerright = getThingfromPos(playerposright)
	if playerleft.itemid >= 1 then
		doTeleportThing(playerleft.uid, newposright)
	elseif playerright.itemid >= 1 then
		doTeleportThing(playerright.uid, newposleft)
	end
end
also i can re-edit this to work also up and down, that is if anyone wants it like that
 
really?? how come is that???
right now I'm editing the script to work up and down but in the same script and now luck working it only works left and right.
 
Last edited:
i got it to work, so here it is:
Lua:
function onUse(cid, item, frompos, item2, topos)
--[DOWN]--
	DOWNplayerpos = {x = frompos.x, y = frompos.y+1, z = frompos.z, stackpos = 253}
	DOWNnewpos = {x = frompos.x, y = frompos.y+1, z = frompos.z}
	DOWNplayer = getThingfromPos(DOWNplayerpos)
--[UP]--	
	UPplayerpos = {x = frompos.x, y = frompos.y-1, z = frompos.z, stackpos = 253}
	UPnewpos = {x = frompos.x, y = frompos.y-1, z = frompos.z}
	UPplayer = getThingfromPos(UPplayerpos)
--[LEFT]--
	LEFTplayerpos = {x = frompos.x-1, y = frompos.y, z = frompos.z, stackpos = 253}
	LEFTnewpos = {x = frompos.x-1, y = frompos.y, z = frompos.z}
	LEFTplayer = getThingfromPos(LEFTplayerpos)
--[RIGHT]--	
	RIGHTplayerpos = {x = frompos.x+1, y = frompos.y, z = frompos.z, stackpos = 253}
	RIGHTnewpos = {x = frompos.x+1, y = frompos.y, z = frompos.z}
	RIGHTplayer = getThingfromPos(RIGHTplayerpos)
--[END LOOK DIRECTIONS]--	
	if item.itemid == 1534 then	
		if LEFTplayer.itemid >= 1 then
			doTeleportThing(LEFTplayer.uid, RIGHTnewpos)
			doCreatureSetLookDirection(cid, 1)
		elseif RIGHTplayer.itemid >= 1 then
			doTeleportThing(RIGHTplayer.uid, LEFTnewpos)
			doCreatureSetLookDirection(cid, 3)
		end
	
	elseif item.itemid == 1536 then
		if DOWNplayer.itemid >= 1 then
			doTeleportThing(DOWNplayer.uid, UPnewpos)
			doCreatureSetLookDirection(cid, 0)
		elseif UPplayer.itemid >= 1 then
			doTeleportThing(UPplayer.uid, DOWNnewpos)
			doCreatureSetLookDirection(cid, 2)
		end
	end	
end
XML:
PHP:
<action itemid="1534;1536" event="script" value="jumpfence.lua"/>
no credit for me, credits for wesoly136
 
Back
Top