use this..
PvPToken.cpp
Code:
#include "StdAfx.h"
#include "Setup.h"
void onPvpKill(Player* plr, Player* victim)
{
int itemID;
uint32 tokenItem = Config.MainConfig.GetInt("NEMESIS_PVP", "PvPTokenID", &itemID);
sLog.outColor(TGREEN,"n[NCDB] (%u)%s killed (%u)%s", plr->getLevel(), plr->GetName(), victim->getLevel(), victim->GetName());
char onkill[1024];
snprintf((char*)onkill, 1024, "|cffFFFF00[PVP]|r |cff00FF00%s|r |cffFFFF00has killed|r |cff00FF00%s|r", plr->GetName(), victim->GetName());
sWorld.SendWorldWideScreenText(onkill);
if(plr->getLevel() >= 70 && victim->getLevel() >= 70 && plr->GetTeam() != victim->GetTeam())
{
sLog.outColor(TGREEN,"n[NCDB] Adding token to %s", plr->GetName());
sLog.outColor(TNORMAL,"n");
ItemPrototype *proto = ItemPrototypeStorage.LookupEntry(itemID);
if(!proto) return;
SlotResult slotresult;
slotresult = plr->GetItemInterface()->FindFreeInventorySlot(proto);
if(!slotresult.Result)
{
plr->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL);
}
else
{
Item *itm = objmgr.CreateItem(itemID, plr);
plr->GetItemInterface()->SafeAddItem(itm,slotresult.ContainerSlot, slotresult.Slot);
itm->m_isDirty = true;
}
}
else
{
sLog.outColor(TRED,"n[NCDB] Not adding token since they both are not level 70");
sLog.outColor(TNORMAL,"n");
}
}
void SetupPvPToken(ScriptMgr * mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, onPvpKill);
}
setup
Code:
#include "StdAfx.h"
#include "Setup.h"
#include <ScriptSetup.h>
extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
{
return SCRIPT_TYPE_MISC;
}
extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
SetupPvPToken(mgr);
}
#ifdef WIN32
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
#endif
setup.h
Code:
#ifndef PVP_TOKEN_SETUP_H
#define PVP_TOKEN_SETUP_H
void SetupPvPToken(ScriptMgr * mgr);
#endif
.vcproj
Code:
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="PVPToken"
ProjectGUID="{2062C149-6029-44A9-94D4-964CF2D914F2}"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="......bindebugscript_bin"
IntermediateDirectory="2003_int_debug_PVPToken"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaultsUpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
Optimization="0"
AdditionalIncludeDirectories="....ascent-shared;....ascent-world;......depinclude;......depsrc"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SCRIPTLIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ascent-world.lib"
OutputFile="../../../bin/debug/script_bin/PVPToken.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="......bindebug"
GenerateDebugInformation="true"
ProgramDatabaseFile="../../../bin/debug/script_bin/PVPToken.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/PVPToken.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMa****ol"
/>
<Tool
Name="VCBscMa****ol"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="......binreleasescript_bin"
IntermediateDirectory="2003_int_release_PVPToken"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaultsUpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
ExcludedFromBuild="true"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="....ascent-shared;....ascent-world;......depinclude;......depsrc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPTLIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ascent-world.lib"
OutputFile="../../../bin/release/script_bin/PVPToken.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="......binrelease"
GenerateDebugInformation="true"
ProgramDatabaseFile="../../../bin/release/script_bin/PVPToken.pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/PVPToken.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMa****ol"
/>
<Tool
Name="VCBscMa****ol"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Main Resources"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..srcPVPTokenSetup.cpp"
>
</File>
<File
RelativePath="..srcPVPTokenSetup.h"
>
</File>
</Filter>
<Filter
Name="Scripts"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..srcPVPTokenPVPToken.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>