Hello fellow MMOwned users. I have been "afk" for a while, had to deal with the FrostTeam's website problems and all.
For some time now, I have been stepping into C# and C++ and I will present my first C++ Script now.
A BIG Thank You to Link_S, for helping me with some doubts ^^
Code:
/*
Author: Edude
Date: 02/01/09
Reason: Making a global announcement every time a player levels;
BUNCH OF ERRORS SORTED OUT BY: Link_S
*/
#include "StdAfx.h"
#include "Setup.h"
#include <ScriptSetup.h>
#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument: truncation from 'double' to 'float'
#endif
void Charlvl(Player * Plr)
{
char levelStr[1024];
uint32 plr_level = Plr->getLevel(); //Gets the new player level
switch(plr_level)
{
case 80:
snprintf(levelStr, "|cff00ccff%s|r is now level |cffff0000%s|r!", Plr->GetName(), Plr->getLevel());
sWorld.SendWorldText(levelStr);
Plr->BroadcastMessage("Congratulations! You are now level %s", Plr->GetLevel());
uint32 plr_money = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
if (Plr->getLevel() == 80)
{
uint32 player_money_gain = plr->getLevel() * 5000000; // 500 gold
Plr->SetUInt32Value(PLAYER_FIELD_COINAGE, player_money + player_money_gain);
}
break;
case 70:
snprintf(levelStr, "|cff00ccff%s|r is now level |cffff0000%s|r|", Plr->GetName(), Plr->getLevel());
sWorld.SendWorldText(levelStr);
Plr->BroadcastMessage("Congratulations! You are now level %s", Plr->GetLevel());
break;
case 55:
snprintf(levelStr, "|cff00ccff%s|r is now level |cffff0000%s|r| and can now create a Death Knight", Plr->GetName(), Plr->getLevel());
sWorld.SendWorldText(levelStr);
Plr->BroadcastMessage("Congratulations! You are now level %s", Plr->GetLevel());
break;
}
}
void SetupCharlvl(ScriptMgr * mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_POST_LEVELUP, &Charlvl);
}
Remember, this is my FIRST C++ Script, so be nice with me.
Happy New Year folks =)