Forum > Serverside Modding
[SOLVED] [QUESTION] TC2. Script executed after loot.
(1/2) > >>
Daweo:
Hi, Modcraft. Is there any function for calling commands for GO after player loots chest? I have chest and I want to execute my script after looting. But the script is executed either before loot or does not work anyway. I used calling OnGossipHello() function and some condition for lootstates but doesnt work. Then I used OnLootStateChanged() function but this one doesnt execute my script (normal loot and then do nothnig). Can You help me please? Sorry for my english...
Ascathos:
I assume you talk about TrinityCore ? Could you please provide your basic code, maybe I have an idea how to do it.
Daweo:
Here you go. I wanna make chest, which will be lootable only once and then will be deleted. I tried this same script only with OnGossipHello() but it will only delete object without any loot.
--- Code: ---#include "ScriptPCH.h" #include "ScriptMgr.h" #include "GameObject.h" #include "LootMgr.h"
class despawn_script : public GameObjectScript { public:
despawn_script() : GameObjectScript("despawn_script") { } bool OnLootStateChanged(GameObject* go, LootState* state, Player* player) { if (go->getLootState() == GO_JUST_DEACTIVATED) { go->SetRespawnTime(0); go->Delete(); go->DeleteFromDB(); } return true; } };
void AddSC_despawn_script() { new despawn_script(); }
--- End code ---
Ascathos:
I reworked that a little. No idea if it works, but it may.
--- Code: ---#include "GameObject.h" #include "LootMgr.h" #include "ScriptPCH.h" #include "ScriptMgr.h"
class despawn_script : public GameObjectScript { public:
despawn_script() : GameObjectScript("despawn_script") { } bool OnLootStateChanged(GameObject* go, LootState* state, Player* player) { if (go->getLootState() == GO_JUST_DEACTIVATED && go->GetGoType() == 3) { go->SetRespawnTime(0); go->Delete(); go->DeleteFromDB(); } return true; } };
void AddSC_despawn_script() { new despawn_script(); } --- End code ---
Try this.
Daweo:
It does not work. I think there is not problem in condition or commands but in calling function... :-/
Navigation
[0] Message Index
[#] Next page
|