View Full Version : [SOLVED] itemscript errors :(

12-13-2013, 07:57 AM
ok so my friend gave me a script that is supposed to spawn a npc when it is used but im getting compile errors that i cant seem to understand. he says it should work but its not.

#include "ScriptPCH.h"
#include "Chat.h"

class item_npc_spawner : public ItemScript
item_npc_spawner() : ItemScript("item_npc_spawner") { }

bool OnUse(Player* player, Item* item) // error here
player->SummonCreature(12524,player->GetPositionX() ,player->GetPositionY(), player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,30000);
return true;


void AddSC_item_npc_spawner()
new item_npc_spawner();

so i went to the deffinition of the onuse function and found this code:

virtual bool OnUse(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/) { return false; }

how can i get this to work? SpellCastTargets??? did he leave something out here?
hes missing a param? lol i dont know what to do to fix it :/

im getting 2 errors and dont understand why. here are the errors im getting

Error 1 error C4263: 'bool item_npc_spawner::OnUse(Player *,Item *)' : member function does not override any base class virtual member function C:\build\src\server\scripts\TSummonstone.cpp 9 1 scripts

Error 2 error C4264: 'bool ItemScript::OnUse(Player *,Item *,const SpellCastTargets &)' : no override available for virtual member function from base 'ItemScript'; function is hidden C:\build\src\server\scripts\TSummonstone.cpp 16 1 scripts

You got to remember im a complete nob at this so it might be 1 small simple edit to fix but i don't understand it lol

12-13-2013, 08:50 AM
ok so after hours of trying a few different things i finnaly got it to work :D

OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/)

is what i changed and now its working :D


12-13-2013, 09:15 AM
Glad you fixed it, marking as solved :smile: