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

Area with time limit

Krashe

Mapper
Joined
Nov 22, 2008
Messages
184
Reaction score
5
Location
Sweden
Hello otlanders;

I'm posting here because I need some kind of script that will allow a person to stay in a certain place for a limited time. What I've made so far is an island, you use a ticket to come to the island. What I want to be made is, that when you go to the island, you can stay there and hunt for a limited time (4 hours) then your time will run out and you will be teleported back to the temple.

I've thought how this could be made, I guess easiest way would be, when you use the ticket, you get some kind of storage, then after 4 hours you get automaticly teleported to temple.

If there's some really good scripter out there *points at cyko* that could help me I'd be greatful. Please leave a reply here.
 
Should work.

tptimer.lua (data/globalevents/scripts/)
Lua:
local storage = xxxx

function onThink(interval, lastExecution, thinkInterval)
	local v = getSpectators({x= 33272,y= 31116,z= 7}, 50, 50)
	for i = 1, #v do
		if isPlayer(v[i]) and os.difftime(os.time(), getPlayerStorageValue(cid, storage)) >= 14400 then
			doTeleportThing(v[i], {x=33349, y=31412, z=8})
		end
	end
end

globalevents.xml (will make a check for players each 10 minutes.)
XML:
<globalevent name="tptimer" interval="600000" event="script" value="tptimer.lua"/>

Npc.lua
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid)				npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink()						npcHandler:onThink()					end

local config = {
	storage = xxxx,
}

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if (msgcontains(msg, "ticket")) then
		if doPlayerRemoveMoney(cid, 50000) and os.difftime(os.time(), getPlayerStorageValue(cid, storage)) >= 14400 then
			npcHandler:say({'There you go, enjoy the ticket to the city of Retards.'}, cid)
			setPlayerStorageValue(cid, storage, os.time())
		else
			selfSay("You don't have enough money.", cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
		talkState[talkUser] = 0
		selfSay("Bye.", cid)
	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())









_______________________________________________________
Some configs to edit.

Change the
Lua:
local v = getSpectators({x= 33272,y= 31116,z= 7}, 50, 50)
to a central pos and the 50, 50 means the area, 50 sqms radius.

Let the
Lua:
local storage = xxxx
have the same storage in both the globalevents script and the npc script.
 
Im really thankfull that you posted this, I think it will be for a big help, so what I wonder now, I'm using a ticket not a npc. How would I edit it so when you use it you get this storage thing. I do not want to post the ticket script here, I'll pm you it :) Thanks again
 
If you wish to have a way that when people use a document or something (use an item) here is an actionscript as a replacement for a npc script.

document.lua
Lua:
local storage = xxxx
function onUse(cid, item, fromPosition, itemEx, toPosition)
		if os.difftime(os.time(), getPlayerStorageValue(cid, storage)) >= 14400 then
		setPlayerStorageValue(cid, storage, os.time())
		doCreatureSay(cid, "You have gained access to the Retard Isle for 4 hours!", TALKTYPE_ORANGE_1)
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendTextMessage(cid,22,"You still have time left until you can use a new ticket.")
	end
       return true
end
 
I am not as good as Cykotitan unfortantly. There is some weaknesses with my scripts as if they logout and so on. You need an onlogin script ~~. If I find time later, Ill try fix it up for you to a hundred percent.

Ok, I'm already pleased with what you've given me, thank you so much - better then nothing. I would also like to ask, this 50x50 radius, I need that to be + and - floors aswell, how would i edit it then?
 
I am not as good as Cykotitan unfortantly. There is some weaknesses with my scripts as if they logout and so on. You need an onlogin script ~~. If I find time later, Ill try fix it up for you to a hundred percent.

*cought*no-logout zone *cought*

Krashe.
I don't know if this will work, I'm a newbie at scripting.
Lua:
local storage = xxxx
local fromPosition = {x = 100, y = 100, z = 15}
local toPosition = {x = 150, y = 150, z = 0}
 
function onThink(interval, lastExecution, thinkInterval)
	local v = isInRange(getThingPosition(pid), fromPosition, toPosition)
	for i = 1, #v do
		if isPlayer(v[i]) and os.difftime(os.time(), getPlayerStorageValue(cid, storage)) >= 14400 then
			doTeleportThing(v[i], {x=33349, y=31412, z=8})
		end
	end
end
 
Ok, I'm already pleased with what you've given me, thank you so much - better then nothing. I would also like to ask, this 50x50 radius, I need that to be + and - floors aswell, how would i edit it then?

Lua:
getCreatureFromRadius = function(from, to)
local players = {}
	for x = from.x, to.x do
		for y = from.y, to.y do
			for z = from.z, to.z do
				local pid = getThingFromPos({x = x, y = y, z = z, stackpos = STACKPOS_TOP_CREATURE}).uid
				table.insert(players, pid)
					--
					--
			end
		end
	end	
return players
end
 
multifloor=true, 4th param

What about that, could you add that to the script maybe? I don't want to do it wrong.

Code:
local storage = 6356
 
function onThink(interval, lastExecution, thinkInterval)
	local v = getSpectators({x= 33272,y= 31116,z= 7}, 50, 50)
	for i = 1, #v do
		if isPlayer(v[i]) and os.difftime(os.time(), getPlayerStorageValue(cid, storage)) >= 14400 then
			doTeleportThing(v[i], {x=33349, y=31412, z=8})
		end
	end
end
 
If you wish to have a way that when people use a document or something (use an item) here is an actionscript as a replacement for a npc script.

document.lua
Lua:
local storage = xxxx
function onUse(cid, item, fromPosition, itemEx, toPosition)
		if os.difftime(os.time(), getPlayerStorageValue(cid, storage)) >= 14400 then
		setPlayerStorageValue(cid, storage, os.time())
		doCreatureSay(cid, "You have gained access to the Retard Isle for 4 hours!", TALKTYPE_ORANGE_1)
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendTextMessage(cid,22,"You still have time left until you can use a new ticket.")
	end
       return true
end

This also I do not really understand, how would I edit that so the document will teleport you to a diffrent place, ex 1000,1000,7?
 
Sorry for double post, I've test the first script sent to me this;
Lua:
local storage = 6356
 
function onThink(interval, lastExecution, thinkInterval)
	local v = getSpectators({x= 33272,y= 31116,z= 7}, 50, 50)
	for i = 1, #v do
		if isPlayer(v[i]) and os.difftime(os.time(), getPlayerStorageValue(cid, storage)) >= 14400 then
			doTeleportThing(v[i], {x=33349, y=31412, z=8})
		end
	end
end

And I get this weird error;
16jsdi.jpg


How can I fix this?
 
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<globalevents>  
	<globalevent name="save" interval="900" event="script" value="save.lua"/>
	<globalevent name="clean" interval="1800" event="script" value="clean.lua"/>	
    <globalevent name="shop" interval="30" event="script" value="shop.lua"/>
	<globalevent name="tptimer" interval="60" event="script" value="tptimer.lua"/>
	

	<globalevent name="serverstart" type="start" event="script" value="start.lua"/>

	<!-- <globalevent name="timer_example" time="21:35" event="script" value="my_script.lua"/> -->
</globalevents>

Tptimer is the one
 
Last edited:
I've been testing alot, and got help from Bogart alot aswell. We've tested and tested but seems like we cant get it working. Here's the scripts I'm using now(that do not work for some reason);
This is the teleport that is suppose to teleport you to the island + give you storage (6356). It does teleport but I'm not sure if it adds the storage.
Lua:
local storage = 6356
function onUse(cid, item, fromPosition, itemEx, toPosition)
		if os.difftime(os.time(), getPlayerStorageValue(cid, storage)) >= 2 then
		setPlayerStorageValue(cid, storage, os.time())
		doCreatureSay(cid, "You have gained access to the Azria for 4 hours!", TALKTYPE_ORANGE_1)
		doTeleportThing(cid, {x=1110, y=1320, z=6})
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendTextMessage(cid,22,"You still have time left until you can use a new ticket.")
	end
       return true
end

Here's the timer checker, I'm not sure if the TPscrolls is wroking and this is bugging. I'm getting no errors from either of the scripts but it wont work :S
Lua:
local storage = 6356
local fromPosition = {x = 1232, y = 1399, z = 15}
local toPosition = {x = 1015, y = 1250, z = 0}
 
function onThink(interval, lastExecution, thinkInterval)
		if isPlayer(pid) and isInRange(getThingPosition(pid), fromPosition, toPosition) and os.time() - getCreatureStorage(cid, storage) >= 2 then
			doTeleportThing(pid, {x=1000, y=1000, z=7})
end
return TRUE
end

If you know whats wrong please help me >;
 
Back
Top