• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Making an Online Training System use Offline Time?

Extrodus

|| Blazera.net ||
Joined
Dec 22, 2008
Messages
2,691
Solutions
7
Reaction score
549
Location
Canada
So I recently had an idea to create a different styled online training system for Aragon, and I looked around for examples of where I could some ideas of how to do it. So from this example of an online trainer system, I could accomplish what I want to do with the same methods.

So the idea is, player steps on the tile; from the example it uses a globalevent to check all players for the storage every 60 seconds but I wonder if in TFS 1.2 there would be a way to just add a timer to the player in the script instead of needing a global event/extra processing. But again thats why I am here, so anyways; every 1 minute, instead of soul points it would remove 1 minute of offline training time and train the skills by 1 try depending on the vocation.

So my questions here are:
1. If I update that script to TFS 1.X, and kept it default with the global event. What function would I use to remove 1 minute of offline training time?
2. Is it possible to remove the global event and use a timer instead that begins when the player steps on the tile?

Thanks for your time, I'm sure theres a way; I just have been very busy with doctor appointments, etc so I figured asking to get more ideas so when I sit down and I can do it with everything already figured out.
 
Offline training is stored in database, as minutes. So i would just make somehow (to limit queries, so there wont be thousands of them) "cache" storing it in script, then just do
just an example
PHP:
local current_off_time = 1000 // you would get that from storage
while (true) do
    current_off_time = current_off_time - 1
    delay(60000)
end
 
Offline training is stored in database, as minutes. So i would just make somehow (to limit queries, so there wont be thousands of them) "cache" storing it in script, then just do
just an example
PHP:
local current_off_time = 1000 // you would get that from storage
while (true) do
    current_off_time = current_off_time - 1
    delay(60000)
end
Shouldn't really concern yourself with limiting queries just about every function / method makes a request to the database :p
However using a loop to check time can cause issues, onThink would be a better solution as opposed to a user defined iterator as the timing may be off where as onThink is using the server's internal timer.
 
Shouldn't really concern yourself with limiting queries just about every function / method makes a request to the database :p
However using a loop to check time can cause issues, onThink would be a better solution as opposed to a user defined iterator as the timing may be off where as onThink is using the server's internal timer.
That's why i'm not an expert in LUA :D what you say is probably better solution. Anyway, getting data from database and then just substract each minute or even second from the offline training time.
 
Perfect, so I'll post back in an hour or so after I try to create it. I'm going to do my best to use the removeOfflineTrainingTime function in the globalevent to remove 1 minute of time instead of soul points and see if it works.
 
Back
Top