• 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 Movement Script to teleport player if he doesn't move in 15 seconds.

ArkSeyonet

Chancho
Joined
Nov 11, 2008
Messages
201
Reaction score
11
(Firstly, if anyone notices the similarity between this script, and the script for the svargrond arena made by Gesior, it's because I based the script from that. It was a great script, so I didn't see why not =].)

Okay. So I have the script almost complete. But, I can't seem to figure out only one thing, because I'm not used to working with movements scripts. This is the files I have:


data/movements/scripts/protectedtiles.lua

Code:
function onStepIn(cid, item, position, fromPosition)
	if InitTileScript == 0 then
		InitTileScript = 1
	end
end

function onStepIn(cid, item, pos, fromPosition)
local storage = getPlayerStorageValue(cid, 42355)
local citizen = {1,2,3,4,9,10,11,12,17,18,19,20,25,26,27,28}
local savage = {5,6,7,8,13,14,15,16,21,22,23,24,29,30,31,32}
local tiles = {10492, 10493, 10494, 10495, 10496, 10497}
	if(item.actionid == 1501) then
		if isInArray(savage, getPlayerVocation(cid)) then
			if(storage < 1) then
				setPlayerStorageValue(cid, 42355, os.time()+protected_tile_max_time)
				doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,'Hello Savage.')
			end
		end
	elseif(item.actionid == 1500) then
		if isInArray(citizen, getPlayerVocation(cid)) then
			if(storage < 1) then
				setPlayerStorageValue(cid, 42355, os.time()+protected_tile_max_time)
				doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,'Hello Citizen.')
			end
		end
	end
end

function checkPlayerTile(param)
	addEvent(checkPlayerTile, 1000, {})
	if [COLOR="Red"][B]XXXXXXXXXXX[/B][/COLOR] then
		if storage <= os.time() then
			setPlayerStorageValue(cid, 42355, 0)
			doPlayerSendTextMessage(player,MESSAGE_STATUS_CONSOLE_ORANGE,'You cannot stay in enemy territory for more than ' .. protected_tile_max_time .. ' seconds.')
		elseif storage - 10 <= os.time() then
			doPlayerSendTextMessage(player,MESSAGE_EVENT_DEFAULT,'You have ' .. storage - os.time() .. ' seconds to get out of the enemy zone!')
		end
	else
		setPlayerStorageValue(cid, 42355, 0)
	end
end

data/lib/protectedtiles.lua
Code:
-- arena script
InitTileScript = 0
protected_tile_max_time = 15 -- time in seconds player can stand on certain tiles
CitzenPosition = {x=918, y=1240, z=6} -- Citizen gets kicked here after standing too long.
SavagePosition = {x=910, y=1240, z=6} -- Savage gets kicked here after standing too long.

data/lib/data.lua
Code:
dofile(getDataDir() .. "lib/constant.lua")
dofile(getDataDir() .. "lib/class.lua")

dofile(getDataDir() .. "lib/string.lua")
dofile(getDataDir() .. "lib/table.lua")

dofile(getDataDir() .. "lib/database.lua")
dofile(getDataDir() .. "lib/wait.lua")

dofile(getDataDir() .. "lib/vocations.lua")
dofile(getDataDir() .. "lib/position.lua")
dofile(getDataDir() .. "lib/ip.lua")
dofile(getDataDir() .. "lib/exhaustion.lua")

dofile(getDataDir() .. "lib/function.lua")
dofile(getDataDir() .. "lib/compat.lua")

dofile(getDataDir() .. "lib/war.lua")
[COLOR="RoyalBlue"]dofile(getDataDir() .. "lib/protectedtiles.lua")[/COLOR]


To sum it all up, in the first code, the XXXXXXX is what I need to figure out how to do. How do you make the script check to see if the player is still on one of the 9 tiles. And if so, then to continue counting down, and if he's not still on the tiles, to reset his storage value.

x,x,x
x,x,x <---- the tiles with actionid 1500
x,x,x

I mean in Gesiors script, he has global storage value for each room, which makes it work because

Code:
and at the top
function onStepIn(cid, item, position, fromPosition)
	if InitArenaScript == 0 then
		InitArenaScript = 1
		-- make arena rooms free
		for i = 0,9 do
			setGlobalStorageValue(42300+i, 0)
			setGlobalStorageValue(42400+i, 0)
		end
		checkArenaRooms({})
	end

local player = getGlobalStorageValue(i)
if isPlayer(player) == TRUE then
 
Last edited:
I am still having trouble with it, I've tried several more ways of going about it, but the normal ways I would do it, just don't work. Anyone have any clue?...

(Sorry for double post, it wouldn't let me edit.)
 
Sorry, but the way Gesior did Arena just sucks, I had to rewrite most of the scripts. I appreciated his effort and they were working in the first place but I didn't like them.

To sum it all up, in the first code, the XXXXXXX is what I need to figure out how to do. How do you make the script check to see if the player is still on one of the 9 tiles. And if so, then to continue counting down, and if he's not still on the tiles, to reset his storage value.
getSpectators(centerPos, rangex, rangey[, multifloor = false]) ?
 
Back
Top