• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Help with easy script

merfus

Member
Joined
Dec 27, 2011
Messages
214
Reaction score
5
Location
Poland
I got bug in this script:

PHP:
local before, after = {x = 738, y = 700, z = 7}, {x = 743, y = 696, z = 7}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k = item.itemid == 1945 then
	if k then
		local thing = getThingFromPos(before, false).uid
		if isPlayer(thing) then
			doTeleportThing(thing, after, true)
			doSendMagicEffect(after, CONST_ME_ENERGYAREA)
			doSendMagicEffect(before, CONST_ME_POFF)
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end

Code:
[28/01/2012 13:54:15] [Error - LuaScriptInterface::loadFile] data/actions/scripts/quests/levertp1.lua:3: unexpected symbol near 'then'
[28/01/2012 13:54:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/quests/levertp1.lua)
[28/01/2012 13:54:15] data/actions/scripts/quests/levertp1.lua:3: unexpected symbol near 'then'

This script should tp player when he use lever.
 
Last edited:
LUA:
local beforePos = {x = 738, y = 700, z = 7},
local afterPos = {x = 743, y = 696, z = 7}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 and item.actionid == 1234567 and getTopCreature(beforePos) == isPlayer(cid) then
	doTransformItem(item.uid, 1946, 1)
        doTeleportThing(getTopCreature(beforePos), afterPos)
        doSendMagicEffect(beforePos, CONST_ME_TELEPORT)
        doSendMagicEffect(afterPos, CONST_ME_TELEPORT)
        doTransformItem(item.uid, 1945, 1)
    end
    return true
end
 
LUA:
local beforePos = {x = 738, y = 700, z = 7},
local afterPos = {x = 743, y = 696, z = 7}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 and item.actionid == 1234567 and getTopCreature(beforePos) == isPlayer(cid) then
	doTransformItem(item.uid, 1946, 1)
        doTeleportThing(getTopCreature(beforePos), afterPos)
        doSendMagicEffect(beforePos, CONST_ME_TELEPORT)
        doSendMagicEffect(afterPos, CONST_ME_TELEPORT)
        doTransformItem(item.uid, 1945, 1)
    end
    return true
end

Doesnt work i can't do use on Lever.
 
LUA:
local before, after = {x = 738, y = 700, z = 7}, {x = 743, y = 696, z = 7}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1945) then
		if(getTopCreature(before).type == 1) then
			doTeleportThing(cid, after, false)
			doSendMagicEffect(after, CONST_ME_ENERGYAREA)
			doSendMagicEffect(before, CONST_ME_POFF)
		end
	end
	
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Last edited:
LUA:
local before, after = {x = 738, y = 700, z = 7}, {x = 743, y = 696, z = 7}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1945) then
		if(getTopCreature(before).type == 1) then
			doTeleportThing(thing, after, false)
			doSendMagicEffect(after, CONST_ME_ENERGYAREA)
			doSendMagicEffect(before, CONST_ME_POFF)
		end
	end
	
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end

I got bug in console when i pull the lever.
[03/02/2012 12:21:44] [Error - Action Interface]
[03/02/2012 12:21:44] data/actions/scripts/quests/levertp1.lua:onUse
[03/02/2012 12:21:44] Description:
[03/02/2012 12:21:44] (luaDoTeleportThing) Thing not found
 
Here it is , rep++ plx :
Code:
-- annihilator lever
 
function onUse(cid, item, frompos, item2, topos)
 
   	if item.uid == 34001 and item.itemid == 1945 then
		player1pos = {x=858, y=538, z=7, stackpos=253}
		player1 = getThingfromPos(player1pos)
 
		if player1.itemid > 0 then
 
		      	nplayer1pos = {x=858, y=533, z=7}

				doSendMagicEffect(player1pos,2)

				doTeleportThing(player1.uid,nplayer1pos)

				doSendMagicEffect(nplayer1pos,10)

				doTransformItem(item.uid,item.itemid+1)
 
		else
			doPlayerSendCancel(cid,"The player is not standing in correct position.")
		end
 
	elseif item.uid ==34001 and item.itemid == 1946 then
		if getPlayerAccess(cid) > -1 then
			doTransformItem(item.uid,item.itemid-1)
		else
			doPlayerSendCancel(cid,"Sorry, not possible.")
		end
	else
		return 0
	end
 
	return 1
end
if item.uid == 34001 and item.itemid == 1945 then
Change the item.uid == to the unique id you have registered in actions.xml,,
player1pos = {x=858, y=538, z=7, stackpos=253}
nplayer1pos = {x=858, y=533, z=7}
Change the first one to the teleported player's first position.
Change the second one to the position of the teleported player.

REP++

*EDIT*: Tested on 0.3.6pl1 and works perfectly.
 
Last edited:
LUA:
local before, after = {x = 738, y = 700, z = 7}, {x = 743, y = 696, z = 7}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		local pid = getTopCreature(before).uid
		if isPlayer(pid) then
			doTeleportThing(pid, after, false)
			doSendMagicEffect(after, CONST_ME_ENERGYAREA)
			doSendMagicEffect(before, CONST_ME_POFF)
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
here it is , rep++ plx :
Code:
-- annihilator lever
 
function onuse(cid, item, frompos, item2, topos)
 
   	if item.uid == 34001 and item.itemid == 1945 then
		player1pos = {x=858, y=538, z=7, stackpos=253}
		player1 = getthingfrompos(player1pos)
 
		if player1.itemid > 0 then
 
		      	nplayer1pos = {x=858, y=533, z=7}

				dosendmagiceffect(player1pos,2)

				doteleportthing(player1.uid,nplayer1pos)

				dosendmagiceffect(nplayer1pos,10)

				dotransformitem(item.uid,item.itemid+1)
 
		else
			doplayersendcancel(cid,"the player is not standing in correct position.")
		end
 
	elseif item.uid ==34001 and item.itemid == 1946 then
		if getplayeraccess(cid) > -1 then
			dotransformitem(item.uid,item.itemid-1)
		else
			doplayersendcancel(cid,"sorry, not possible.")
		end
	else
		return 0
	end
 
	return 1
end
if item.uid == 34001 and item.itemid == 1945 then
change the item.uid == to the unique id you have registered in actions.xml,,
player1pos = {x=858, y=538, z=7, stackpos=253}
nplayer1pos = {x=858, y=533, z=7}
change the first one to the teleported player's first position.
Change the second one to the position of the teleported player.

Rep++

*edit*: Tested on 0.3.6pl1 and works perfectly.

finally works perfect!!!!!!! Rep+++++
 
Back
Top