• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Teleport to different locations 4

Maniucza

~Lua~ Noob
Joined
Aug 2, 2009
Messages
86
Reaction score
6
Location
Poland / Rzeszów
Hi, I present to you the script that teleports to different locations 4 after 5 seconds, for example, the first position and wait five seconds for the second, etc.

Data/Actions/NAME.lua
Lua:
local config = 
{
    positions =
    {
        [1] = {x = 1000, y = 1000, z = 7},
        [2] = {x = 1002, y = 994, z = 7},
        [3] = {x = 1043, y = 981, z = 7},
        [4] = {x = 1000, y = 1003, z = 7}
    },
    timeToTeleport = 5,
    freezAfterTeleport = false
}

local function teleportAfterTime(cid, i)
    if(i == 0) then
        if(config.freezAfterTeleport == true) then
            doCreatureSetNoMove(cid, false)
        end
        return true
    end
    if(config.freezAfterTeleport == true) then
        doCreatureSetNoMove(cid, true)
    end
    doTeleportThing(cid, config.positions[i])
    addEvent(teleportAfterTime, config.timeToTeleport * 1000, cid, i-1)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(isPlayer(itemEx.uid) == false or getCreatureName(cid) ~= getCreatureName(itemEx.uid)) then
        return false
    end
    teleportAfterTime(cid, #config.positions)
return true
end

Data/actions.xml
Lua:
<action itemid="XXXX" event="script" value="NAME.lua"/>
 
Last edited:
You tested that ??

I can't see any onUse function, which is needed for a action script..
 
You tested that ??

I can't see any onUse function, which is needed for a action script..

Code:
local config =
{
    positions =
    {
        [1] = {x = 1000, y = 1000, z = 7},
        [2] = {x = 1010, y = 1000, z = 7},
        [3] = {x = 1020, y = 1000, z = 7},
        [4] = {x = 1031, y = 1000, z = 7}
    },
    timeToTeleport = 5,
}

local function teleportAfterTime(cid, i, freezAfterTeleport)
		freezAfterTeleport = freezAfterTeleport or false;
		if(freezAfterTeleport) then
			doCreatureSetNoMove(cid, true);
			addEvent(doCreatureSetNoMove, config.timeToTeleport*1000,cid,false);
		end
		return doTeleportThing(cid, config.positions[i]) and true;
end 
function onUse(cid, item, frompos, item2, topos)
	local i = math.random(1,4);
	return teleportAfterTime(cid, i, true) and true;
end
 
Last edited:
You tested that ??

I can't see any onUse function, which is needed for a action script..

.. :p

local config =
{
positions =
{
[1] = {x = 1000, y = 1000, z = 7},
[2] = {x = 1002, y = 994, z = 7},
[3] = {x = 1043, y = 981, z = 7},
[4] = {x = 1000, y = 1003, z = 7}
},
timeToTeleport = 5,
freezAfterTeleport = false
}

local function teleportAfterTime(cid, i)
if(i == 0) then
if(config.freezAfterTeleport == true) then
doCreatureSetNoMove(cid, false)
end
return true
end
if(config.freezAfterTeleport == true) then
doCreatureSetNoMove(cid, true)
end
doTeleportThing(cid, config.positions)
addEvent(teleportAfterTime, config.timeToTeleport * 1000, cid, i-1)
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
if(isPlayer(itemEx.uid) == false or getCreatureName(cid) ~= getCreatureName(itemEx.uid)) then
return false
end
teleportAfterTime(cid, #config.positions)
return true
end


I made quote to make it in color.. xD
 
Lol do you think I am that nooby haha..

Just look at "Last edited by Maniucza; Yesterday at 23:12. "
He just failed to Ctrl+C and Ctrl+V he missed the last part :/ Bad luck..

@Quas
Since when lua is like C or php and need ';' to end functions and such ?? lol
 
@Rhux
sorry, it is just my habit, cuz i write a lot of C++ and PHP (i am studying IT), and i automatically add ';' to end of line xD Anyway i get words 'then, end' like a ' { } ' in c++, so i don't add at end of this a ';' char.

In Lua it is not necessary.
 
when i put the teleport and the script at actions, when i go on the teleport its doesnt do something i dont get tp or errors on the consol -.-
 
doesnt rlly matter if you wrote it with the semicolon or without in lua
 
please somebody help me i give rep++
 
Back
Top Bottom