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

[Rashid] Possible?

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,321
Reaction score
18
Location
Sweden - Dalarna
I have Rashid in my server, using Nahruto's script(I think it was Nahruto, correct me if I'm wrong) for changing place
Here's the script;
Lua:
local myNewPos = {
	[1] = {x=32210, y=31157, z=7},
	[2] = {x=32297, y=32831, z=7},
	[3] = {x=32574, y=32752, z=7},
	[4] = {x=33067, y=32880, z=6},
	[5] = {x=33239, y=32483, z=7},
	[6] = {x=33170, y=31810, z=6},
	[7] = {x=32328, y=31782, z=7}
	}
local TpTime = 10800 --secs
local myLastTP = 0
local a = 1
function onThink()
	if myLastTP == 0 then
		myLastTP = os.time()
	end
	if os.difftime (os.time(), myLastTP) >= TpTime then
		myLastTP = os.time()
		doCreatureSay(getNpcCid(), "See you, Now Im going to the next city!", TALKTYPE_SAY)
		doTeleportThing(getNpcCid(), myNewPos[a], FALSE)
		if (a + 1) < 7 then
			a = a + 1
		else
			a = 1
		end			
	end
	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('I don\t got all day!')
  		end
  		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
 	end
		npcHandler:onThink()
end

Now here's my question:
It is possible to make the NPC check what day it is? Like Monday, on mondays in real tibia he's standing in Svargrond.
Example: We say the clock is 23:59 CET(Sunday he's in Carlin), now the time changed to 00:00 so now it's Monday. Now he changes place to Svargrond!
and we say for example the server crashes on Monday 15:39 CET.
I did put Rashid on my mapeditor in Thais for example, so when I start the server Rashid is in Thais! (This is NOT good!)
But then I had some luck - someone of you(otlanders) made a Globalevent script(or something, thanks <3) That will check the time with an interval of 20sec for example.
Then the script recognize that it's monday, then he will change the place on rashid to Svargrond(where rashid should be on mondays).

Well, I explained as good as I could, hope it helps.

THANKS IN ADVANCE AND HOPE THIS IS POSSIBLE!!
Would be AWSOME if an Angel(or maybe more angels) make this script for me(I guess more peoples here on Otland would be gratefull too)

I'm using Cryingdamson 0.3.4pl2
 
Last edited:
@Up,

Thing is, if you could make a script like that,
It would probably reset him everytime you restarted the server.

I think it is possible though. :thumbup:

Regards.
 
You may find it useful:
Code:
-- returns weekday as integer [0-6 = Sunday-Saturday]
os.date("%w")
then use global events eg, every 15 minutes to check if he's at good position and store his position in globalstorage, so u don't have to check where he is every time.
And global storage is cleared every start of TFS, and rashid always appears on the first place from map so it works.

@RTFM http://www.lua.org/pil/22.1.html
 
Well, I suck(cries) I don't know where to add os.date("%w") and I don't know how I have to edit the script to make it listen to that xD (or something)

So I would be greatfull if someone could implement it for me, or try to explain how to do it :p
 
I tried to make it myself in a globalevent out of Nahruto's script, but didn't work-.- I don't even know if anything of it would work...
I get this error:
Lua:
[29/05/2009 13:46:23] Lua Script Error: [GlobalEvent Interface] 
[29/05/2009 13:46:23] data/globalevents/scripts/rashid check.lua:onThink

[29/05/2009 13:46:23] data/globalevents/scripts/rashid check.lua:22: attempt to compare string with number
[29/05/2009 13:46:24] stack traceback:
[29/05/2009 13:46:24] 	data/globalevents/scripts/rashid check.lua:22: in function <data/globalevents/scripts/rashid check.lua:1>
[29/05/2009 13:46:24] [Error - GlobalEvents::onThink] Couldn't execute event: rashid check

and here's the script:
Lua:
function onThink(interval, lastExecution)

local RashidPos = {
	[1] = {x=32210, y=31157, z=7, stackpos=STACKPOS_TOP_CREATURE},
	[2] = {x=32297, y=32831, z=7, stackpos=STACKPOS_TOP_CREATURE},
	[3] = {x=32574, y=32752, z=7, stackpos=STACKPOS_TOP_CREATURE},
	[4] = {x=33067, y=32880, z=6, stackpos=STACKPOS_TOP_CREATURE},
	[5] = {x=33239, y=32483, z=7, stackpos=STACKPOS_TOP_CREATURE},
	[6] = {x=33170, y=31810, z=6, stackpos=STACKPOS_TOP_CREATURE},
	[7] = {x=32328, y=31782, z=7, stackpos=STACKPOS_TOP_CREATURE}
	}

local TpTime = os.date("%w")
local myLastTP = 0
local a = 5
local creaturepos = RashidPos[a]
npc = getThingFromPos(creaturepos)

	if myLastTP == 0 then
		myLastTP = os.date("%w")
	end
	if os.difftime (os.time(), myLastTP) >= TpTime then
		myLastTP = os.date("%w")
		doTeleportThing(npc.uid, RashidPos[a], FALSE)
		if (os.date("%w") + 1) < 7 then
			a = a + os.date("%w")
		else
			a = 5
		end			
	end
return TRUE
end

Help me.. please!
 
Last edited:
I re-done the script:
Lua:
function onThink(interval, lastExecution)

local MondayPos = {x=32210, y=31157, z=7, stackpos=STACKPOS_TOP_CREATURE}
local TuesdayPos = {x=32297, y=32831, z=7, stackpos=STACKPOS_TOP_CREATURE}
local WednesdayPos = {x=32574, y=32752, z=7, stackpos=STACKPOS_TOP_CREATURE}
local ThursdayPos = {x=33067, y=32880, z=6, stackpos=STACKPOS_TOP_CREATURE}
local FridayPos = {x=33239, y=32483, z=7, stackpos=STACKPOS_TOP_CREATURE}
local SaturdayPos = {x=33170, y=31810, z=6, stackpos=STACKPOS_TOP_CREATURE}
local SundayPos = {x=32328, y=31782, z=7, stackpos=STACKPOS_TOP_CREATURE}

local Monday = getThingFromPos(SundayPos)
local Tuesday = getThingFromPos(MondayPos)
local Wednesday  = getThingFromPos(TuesdayPos)
local Thursday = getThingFromPos(WednesdayPos)
local Friday = getThingFromPos(ThursdayPos)
local Saturday = getThingFromPos(FridayPos)
local Sunday = getThingFromPos(SaturdayPos)

local day = 0

	if (os.date("%A")) then
		day = (os.date("%A"))
		doTeleportThing(cid, day, FALSE)
end
end

but he don't teleport! and I get this error!:
Lua:
[29/05/2009 18:14:21] Lua Script Error: [GlobalEvent Interface] 
[29/05/2009 18:14:21] data/globalevents/scripts/rashid check.lua:onThink

[29/05/2009 18:14:21] luaDoTeleportThing(). Thing not found
[29/05/2009 18:14:22] [Error - GlobalEvents::onThink] Couldn't execute event: rashid check

EDIT; Sorry for double post


Please help me!
 
Last edited:
Back
Top