Jump to content

Metin2 When statement and auto event logic ?


Recommended Posts

I'm working on a quest file that automatically starts and ends events based on server time.I have a few points that I do not understand, what can I use with when?
I can not find the definition of this statement in the server source code, I have at least a chance to examine where it is stored. The other problem I'm dealing with right now is;

I did with when login, there is a logic error. Each time login is done, clear_server_timer() runs and then server_loop_timer() function is running.
When in my_oto_event.server_loop_timer the clocks are only checked with full equality(An example time == "13.00:00") the player will never catch it,
 

How can we follow a solution path?


If you need to explain what I'm trying to do with a small sample code, you can look down.

when login or enter begin -- Can we keep this part constantly ?
  clear_server_timer("my_oto_event")
  server_loop_timer("my_oto_event",1)
end

when my_oto_event.server_timer begin
  if os.date("%X") == "13:00:00" then
    game.set_event_flag("test_event1",1)
  end
  if os.date("%X") == "16:00:00" then --end
    game.set_event_flag("test_event1",0)
  end
end

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Premium

No need to check for it every millisecond, use a login or letter statement, which updates every time a player logins, changes map or runs a quest letter, it will occur every ~5 seconds.

or, if you need more, use kill.

Of course, those are all workarounds, but they do the job, it's Metin2 after all so this is the best you can get without looking like a madman.

when login or letter or kill begin
	local machine_time = os.date("%X");
	if (machine_time == "13:00:00") then
		game.set_event_flag("test_event1", 1);

	elseif (machine_time == "16:00:00") then
		game.set_event_flag("test_event1", 0);
	end -- if/elseif
end -- when

or again, you could calculate the exact time and make a server_timer with the exact seconds so when it triggers it means it's 13:00 and start another server_timer upon that so after 3 hours (16:00) it disables the event

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.