Epicblood
Epic Member
Just started trying to learn C++ for trinity and am trying to make a script that adds an item, and x amount of honor when someone kills another player, and subtracts x amount of gold from the player being killed.
these are my errors:
- - - Updated - - -
Fixed it, thanks to: philippovitch
Code:
/*
*
*############# ############# ############# ############# ############# ## ############# ############# #############
*## ## ## ## ## ## ## ## ## ## ## ## ## ##
*## ## ## ## ## ## ## ## ## ## ## ## ## ##
*## ## ## ## ## ## ## ## ## ## ## ## ## ##
*############# ############# ## ## ############# ## ## ## ## ## ## ##
*## ## ## ## ## ## ## ## ## ## ## ## ##
*## ## ## ## ## ## ## ## ## ## ## ## ##
*## ## ## ## ## ## ## ## ## ## ## ## ##
*############# ## ############# ############# ############# ############# ############# ############# #############
*
*/
#include "ScriptPCH.h"
enum eNums
{
Reward_Item = 29434, //Insert your reward item here, it will be given each time a player kills another player
Reward_Honor = 1, //The amount of honor given when an enemy player is killed
Death_Cost = 10000, //Insert here how much money is taken whenever a player is killed by another player
};
class pvp_script : public PlayerScript
{
public:
pvp_script() : PlayerScript("PvP Script"){}
void OnPVPKill(Player* killer, Player* dead){
WorldSession * k_session = killer->GetSession();
WorldSession * d_session = dead->GetSession();
std::string deadName = dead->GetName();
std::string killerName = killer->GetName();
std::string deadMessage = "You were just killed by: ";
std::string killerMessage = "You just killed: ";
std::string deadOut = deadMessage += killerName;
std::string killerOut = killerMessage += deadName;
killer->AddItem(Reward_Item, 1);
killer->SetHonorPoints(killer->GetHonorPoints() + Reward_Honor);
if(dead->GetMoney() >= Death_Cost)
dead->ModifyMoney(dead->GetMoney() - Death_Cost);
k_session->SendNotification(killerOut);
d_session->SendNotification(deadOut);
}
};
void AddSC_pvp_test_script()
{
new pvp_script;
}
these are my errors:
1 IntelliSense: no instance of overloaded function "WorldSession::SendNotification" matches the argument list
argument types are: (std::string)
object type is: WorldSession c:\Users\Joris Bolsens\Desktop\Trinity\Build\src\server\scripts\pvp_test.cpp 42 12 scripts
2 IntelliSense: no instance of overloaded function "WorldSession::SendNotification" matches the argument list
argument types are: (std::string)
object type is: WorldSession c:\Users\Joris Bolsens\Desktop\Trinity\Build\src\server\scripts\pvp_test.cpp 43 12 scripts
- - - Updated - - -
Fixed it, thanks to: philippovitch
Code:
ChatHandler(dead->GetSession()).PsendSysMessage("You were killed by: '%u' ", killer->GetName());
ChatHandler(killer->GetSession()).PsendSysMessage("You just killed: '%u' ", dead->GetName());
Last edited: