• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] WorldScript timed event issues

Status
Not open for further replies.

slp13at420

Mad Scientist
so i have this script I have been trying to get-to work:
Code:
[COLOR="#808080"]class GGW_RankTimer : public WorldScript
{
public:
	GGW_RankTimer() : WorldScript("GGW_RankTimer")
	{
		TC_LOG_INFO("server.loading", "RE-RANK TIMER START"); // fires once

		events.ScheduleEvent(1, 5000);
	}

	void OnUpdate(uint32 diff) override
	{
		uint32 id = events.ExecuteEvent();
		TC_LOG_INFO("server.loading", "1ST RE-RANK TIMER UPDATE AI ID:%u", id); // allways returns a 0....

		while (uint32 id = events.ExecuteEvent())
		{
			TC_LOG_INFO("server.loading", "2ND RE-RANK TIMER UPDATE AI ID:%u", id); // never
			switch (id)
			{
			case 1:
				CreateRankList();
				break;
			}
		}
	}
	EventMap events;
};
[/COLOR]

the objective of this is every 30 minutes it will call the function `CreateRankList();`.

I have it added to the list at the end of the script:
Code:
[COLOR="#808080"]
void AddSC_Grunboz_Guild_Warz()
{
	new GGW_RankTimer;
[/COLOR]

I gets called for the first time during config load:
Code:
[COLOR="#808080"]
virtual void OnConfigLoad(bool /*reload*/)
{
	new GGW_RankTimer();
[/COLOR]

the timer starts fine after getting called.
Code:
[COLOR="#808080"]
RE-RANK TIMER START
[/COLOR]
but never executes.
the variable `id` is always 0 and never calls `CreateRankList()`
Code:
[COLOR="#808080"]
1ST RE-RANK TIMER UPDATE AI ID:0
[/COLOR]

I do have another timed event that is a player timed event and it works fine.
Code:
[COLOR="#808080"]
class GGW_PigPayz : public BasicEvent
{
public:
	GGW_PigPayz(Player* _player) : player(_player)
	{
		_player->m_Events.AddEvent(this, _player->m_Events.CalculateTime(GUILDWARZ_PIGPAYZ_TIMER)); // 1000 = 1 second  // 60000 = 1 minute
	}

	bool Execute(uint64, uint32) override
	{
		PigPayz(player);

		new GGW_PigPayz(player);

		return true;
	}

	Player* player;
};
[/COLOR]

ugh any ideas what im missing?
 
Last edited:

Rochet2

Moderator / Eluna Dev
Its not really clear if you looked at your logs and checked that EVERY print of "1ST RE-RANK TIMER UPDATE AI ID:0" has 0 and not 1 in it.
Note that out of the whole time there is only one time the 1 is printed as the event is never repeated.

I gets called for the first time during config load:
Why isnt the code you present there in the first snippet? What is that code anyways? It looks as if you put it to the scriptmgr.h :S or something other suspicious.

Ok I found the problem. You dont update your events ever.
You are supposed to call something like events.Update(diff);
and you never do. The events dont automagically update themselves :)

here is a quick reference I fetched just now:
https://github.com/TrinityCore/Trin...untain/MoltenCore/boss_ragnaros.cpp#L140-L142
 
Last edited:

slp13at420

Mad Scientist
Its not really clear if you looked at your logs and checked that EVERY print of "1ST RE-RANK TIMER UPDATE AI ID:0" has 0 and not 1 in it.
Note that out of the whole time there is only one time the 1 is printed as the event is never repeated.

I did go thru the whole Server.txt file to see if I got any responses from the CreateRankList() function.
but I never saw any of its responses.

Why is the code you present there in the first snippet? What is that code anyways? It looks as if you put it to the scriptmgr.h :S or something other suspicious.

im adding something to Guild Warz :D

Ok I found the problem. You dont update your events ever.
You are supposed to call something like events.Update(diff);
and you never do. The events dont automagically update themselves :)

here is a quick reference I fetched just now:
https://github.com/TrinityCore/Trin...untain/MoltenCore/boss_ragnaros.cpp#L140-L142

lol n added events.Update(diff) to OnUpdate:
Code:
	void OnUpdate(uint32 diff) override
	{
		events.Update(diff);

		uint32 id = events.ExecuteEvent();
		TC_LOG_INFO("server.loading", "1ST RE-RANK TIMER UPDATE AI ID:%u", id); // allways returns a 0....

and poof:
Code:
1ST RE-RANK TIMER UPDATE AI ID:0
1ST RE-RANK TIMER UPDATE AI ID:1
CREATE RANK LIST UPDATE VALUES:8
CREATE RANK LIST UPDATE VALUES:9
CREATE RANK LIST UPDATE VALUES:1
CREATE RANK LIST UPDATE VALUES:3
CREATE RANK LIST UPDATE VALUES:7

end product :D
Code:
[COLOR="#808080"]
bool rank_binary_ticker = false;

class GGW_RankTimer : public WorldScript
{
public:
	GGW_RankTimer() : WorldScript("GGW_RankTimer")
	{
		events.ScheduleEvent(1, GUILDWARZ_RANKING_TIMER);
	};

	void OnUpdate(uint32 diff) override
	{
		events.Update(diff);

		uint8 id = events.ExecuteEvent();

		if (rank_binary_ticker == true)
			rank_binary_ticker = false;
		else
		{
			switch (id)
			{
			case 1:
				events.CancelEvent(1);
				CreateRankList();
				new GGW_RankTimer();
				rank_binary_ticker = true;
				break;
			};
		};
	};
EventMap events;
};
[/COLOR]


Tnx Rochet2 :D
 
Last edited:
Status
Not open for further replies.
Top