View Full Version : [SOLVED] Playtime in wow

12-24-2013, 05:56 PM
can someone help me ?
i wanna make an script like
who got the most playtime on the server on the end of the week
but i dont have an idea how ..
can someone help me please ?

12-24-2013, 06:03 PM
- Moved to Support. Read what section you're in before creating a thread.

Also, can you give more information? http://emudevs.com/faq.php?faq=forumfaq#faq_givemoreinfofaq

I see that you want to have a script to see who has the most played time at the end of the week, but you never mention how you want to handle it. You also don't mention how will players benefit from this. Meaning, will they get special rewards?

Do you want administrators to have a command that automatically selects the player with the most played time to give them the reward (if there is one)? You should give this more thought. XD

12-24-2013, 06:33 PM
Yeah a reward lol :D
no i wanna it in the database like that and that player ahve the most playtime this week.

12-24-2013, 06:39 PM
Yeah a reward lol :D
no i wanna it in the database like that and that player ahve the most playtime this week.

Okay, you want to give a player a reward. What kind of reward? Gold, items, what?

Also, you never mention how you want it to be handled. Do you want it automatically handled? Looks that way.. I'll see what I can whip up.

12-24-2013, 06:44 PM
An item ^^

12-24-2013, 07:28 PM
Here you go:

class most_played : public PlayerScript
most_played() : PlayerScript("most_played") { }

void OnLogin(Player* player)
time_t now = time(0);
tm* localDateTime = localtime(&now);

if (localDateTime->tm_wday == 5)
QueryResult result = CharacterDatabase.Query("SELECT guid, MAX(totaltime) FROM characters");
if (result)
Field* fields = result->Fetch();
uint64 guid = fields[0].GetUInt64();

if (player->GetGUID() == guid)
player->AddItem(3000, 1); // CHANGE 3000 (ITEMID) and 1 (ITEMCOUNT) to what you want!

void AddSC_reward_most_played()
new most_played;

NOW, the only issue you're going to have is; when it is still 'Friday' (end of the week), it will still tick through once the players login until it isn't Friday anymore. I wasn't quite sure how to bypass this, other than checking the hour / min / seconds of the given day and if the player logs in within that time period they'll get the item. However, that would be kinda hacky though..

Another way I had in mind is adding a new column name (bool) 'receivedTimePlayedItem' in the characters table and checking that (If it's true, don't give the item to the player). Every weekend the value of that column will reset.

I hated to have done this within the Player 'OnLogin' hook, but it seemed easier to get the player's information this way.

But yeah, there's only that flaw with what you want.