Here you go:
Code:
class most_played : public PlayerScript
{
public:
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!
}while(result->NextRow());
}
}
};
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.