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

Lua Lever Script teleport

Bladefist

New Member
Joined
Oct 26, 2010
Messages
65
Reaction score
0
Location
Carlin
Hey I need lever script that teleports player when he stand on a floor (5x,5y,5z)
And when the player pull a lever next to him he'll be teleported to (8x,8y,8z)

This need to be repeatable

and maybe a reset timer on 1 sec for the lever, would be great

Thanks,

Rep will be given
 
if i good understand...

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local teleporta = {x=1169,y=925,z=8}
doTeleportThing(cid, teleporta)
doSendMagicEffect(getPlayerPosition(cid), 10)
doCreatureSay(cid, "down!", TALKTYPE_ORANGE_1) 
return true
end
 


Heres a pircture as example.

Red circle is players poss lets say (5,5,5)
The lever (yellow circle) will teleport player to (8,8,8) if used.
The lever needs to reset itself instantly after use, and must be reuseable for all players.
 
Lua:
local reset, t = function(p)
	doTransformItem(getTileItemById(p, 1946).uid, 1945)
end, {}

function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 1945 and getThingFromPos({x=5, y=5, z=5}) then
		doTeleportThing(cid, {x=8, y=8, z=8})
		doSendMagicEffect({x=8, y=8, z=8}, 10)
		doTransformItem(item.uid, 1946)
		t[item.uid] = addEvent(reset, 4 * 60000, frompos)
	else
		stopEvent(t[item.uid])
		t[item.uid] = nil
		doTransformItem(item.uid, 1945)
	end
	return TRUE
end

Some script Cykotitan did and I edited it, you have to change the time you want the switch to reset, as it is now, it's set to 4 minutes xD
 
Code:
local reset, t = function(p)
	doTransformItem(getTileItemById(p, 1946).uid, 1945)
end, {}
 
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 1945 and getThingFromPos({x=1054, y=1254, z=7}) then
		doTeleportThing(cid, {x=1056, y=1255, z=8})
		doSendMagicEffect({x=1056, y=1255, z=8}, 10)
		doTransformItem(item.uid, 1946)
		t[item.uid] = addEvent(reset, 1 * 1000, frompos)
	else
		stopEvent(t[item.uid])
		t[item.uid] = nil
		doTransformItem(item.uid, 1945)
	end
	return TRUE
end

getThingFromPos({x=1054, y=1254, z=7}) is the playerpos?

and

doTeleportThing(cid, {x=1056, y=1255, z=8})
doSendMagicEffect({x=1056, y=1255, z=8}, 10) is the teleportpos?

I need player to stand on x=1054, y=1254, z=7 and get teleported to 1056, y=1255, z=8.. Action ID 7999

don't got it to work yet.
 
getThingFromPos = player position
doTeleportThing = where to be teleported
doSendMagicEffect = what pos to send magic effect
 
Code:
local reset, t = function(p)
	doTransformItem(getTileItemById(p, 1946).uid, 1945)
end, {}
 
function onUse(cid, item, frompos, item2, topos)
	if item.uid == 7999 and item.itemid == 1945 then
		doTeleportThing(cid, {x=1056, y=1255, z=8})
		doSendMagicEffect({x=1056, y=1255, z=8}, 10)
		doTransformItem(item.uid, 1946)
		t[item.uid] = addEvent(reset, 1 * 1000, frompos)
	else
		stopEvent(t[item.uid])
		t[item.uid] = nil
		doTransformItem(item.uid, 1945)
	end
	return TRUE
end


Removed playerpos because it's somehow didn't work, but still the lever don't reset. This should work on old-school server?

If you see something wrong please give me a hand:)
 
No, I ain't no lua scripter. All I know is that you don't need to declare item.uid in the script. Could just aswell be:
Lua:
if item.itemid == 1945 then
 
Back
Top