hello!! friend all good when your file will add it in the core git warns that line 130 corrupted this is how you help me
I thank you!!
3>..\..\..\..\TrinityCore\src\server\scripts\Custom\gossipitem.cpp(15): error C2065: 'DEFAULT_GOSSIP_MENU' : undeclared identifier
3>..\..\..\..\TrinityCore\src\server\scripts\Custom\gossipitem.cpp(16): error C2562: 'PlayerGossipTest::OnPlayerLeaveCombat' : 'void' function returning a value
3> ..\..\..\..\TrinityCore\src\server\scripts\Custom\gossipitem.cpp(8) : see declaration of 'PlayerGossipTest::OnPlayerLeaveCombat'
Hi, i'm new here .
Is there a way to do the same thing but with WorldScript, like using gossip with OnUpdate hook for example ?
Ok, thanks rochet, i'll try so
Edit : I added your patch, then tried to add gossip in my OnUpdate hook but I always get this error when i connect
WorldSocket::SendPacket enqueue_tail failed
Are you familiar with it ?
#include "ScriptMgr.h"
#define TIME 30 //total time played you want for the reward. (in seconds)
#define ITEM_ID_1 6256 //the item id you want as a reward.
#define ITEM_QUANTITY_1 1 //the quantity you want for your reward.
#define ITEM_ID_2 44050 //the item id you want as a reward.
#define ITEM_QUANTITY_2 1 //the quantity you want for your reward.
uint32 HasItem = 0;
class totaltimeplayed_reward : public WorldScript
{
public :
totaltimeplayed_reward() : WorldScript("totaltimeplayed_reward") { }
void OnUpdate(uint32 /*diff*/)
{
SessionMap ss = sWorld->GetAllSessions();
for(SessionMap::iterator itr = ss.begin(); itr != ss.end(); ++itr)
{
if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
continue;
Player* player = itr->second->GetPlayer();
uint32 total_played_time = player->GetTotalPlayedTime();
if (total_played_time >= TIME)
{
while (HasItem != 1)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(0, "Choisir l'item 1", GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM(0, "Choisir l'item 2", GOSSIP_SENDER_MAIN, 2);
player->PlayerTalkClass->GetGossipMenu().SetMenuId(123);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, player->GetGUID());
}
}
}
}
void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action)
{
if(menu_id != 123)
return;
player->PlayerTalkClass->ClearMenus();
switch(action)
{
case 1 :
player->AddItem(ITEM_ID_1, ITEM_QUANTITY_1);
player->SaveToDB();
++HasItem;
break;
case 2 :
player->AddItem(ITEM_ID_2, ITEM_QUANTITY_2);
player->SaveToDB();
++HasItem;
break;
}
player->CLOSE_GOSSIP_MENU();
}
};
void AddSC_totaltimeplayed_reward()
{
new totaltimeplayed_reward();
}
I'm a wery begginer in c++ coding, so it may not be perfect code at all ^^
Code:#include "ScriptMgr.h" #define TIME 30 //total time played you want for the reward. (in seconds) #define ITEM_ID_1 6256 //the item id you want as a reward. #define ITEM_QUANTITY_1 1 //the quantity you want for your reward. #define ITEM_ID_2 44050 //the item id you want as a reward. #define ITEM_QUANTITY_2 1 //the quantity you want for your reward. uint32 HasItem = 0; class totaltimeplayed_reward : public WorldScript { public : totaltimeplayed_reward() : WorldScript("totaltimeplayed_reward") { } void OnUpdate(uint32 /*diff*/) { SessionMap ss = sWorld->GetAllSessions(); for(SessionMap::iterator itr = ss.begin(); itr != ss.end(); ++itr) { if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld()) continue; Player* player = itr->second->GetPlayer(); uint32 total_played_time = player->GetTotalPlayedTime(); if (total_played_time >= TIME) { while (HasItem != 1) { player->PlayerTalkClass->ClearMenus(); player->ADD_GOSSIP_ITEM(0, "Choisir l'item 1", GOSSIP_SENDER_MAIN, 1); player->ADD_GOSSIP_ITEM(0, "Choisir l'item 2", GOSSIP_SENDER_MAIN, 2); player->PlayerTalkClass->GetGossipMenu().SetMenuId(123); player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, player->GetGUID()); } } } } void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action) { if(menu_id != 123) return; player->PlayerTalkClass->ClearMenus(); switch(action) { case 1 : player->AddItem(ITEM_ID_1, ITEM_QUANTITY_1); player->SaveToDB(); ++HasItem; break; case 2 : player->AddItem(ITEM_ID_2, ITEM_QUANTITY_2); player->SaveToDB(); ++HasItem; break; } player->CLOSE_GOSSIP_MENU(); } }; void AddSC_totaltimeplayed_reward() { new totaltimeplayed_reward(); }
while (HasItem != 1)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(0, "Choisir l'item 1", GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM(0, "Choisir l'item 2", GOSSIP_SENDER_MAIN, 2);
player->PlayerTalkClass->GetGossipMenu().SetMenuId(123);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, player->GetGUID());
}
I'm a wery begginer in c++ coding, so it may not be perfect code at all ^^
Code:#include "ScriptMgr.h" #define TIME 30 //total time played you want for the reward. (in seconds) #define ITEM_ID_1 6256 //the item id you want as a reward. #define ITEM_QUANTITY_1 1 //the quantity you want for your reward. #define ITEM_ID_2 44050 //the item id you want as a reward. #define ITEM_QUANTITY_2 1 //the quantity you want for your reward. uint32 HasItem = 0; class totaltimeplayed_reward : public WorldScript { public : totaltimeplayed_reward() : WorldScript("totaltimeplayed_reward") { } void OnUpdate(uint32 /*diff*/) { SessionMap ss = sWorld->GetAllSessions(); for(SessionMap::iterator itr = ss.begin(); itr != ss.end(); ++itr) { if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld()) continue; Player* player = itr->second->GetPlayer(); uint32 total_played_time = player->GetTotalPlayedTime(); if (total_played_time >= TIME) { while (HasItem != 1) { player->PlayerTalkClass->ClearMenus(); player->ADD_GOSSIP_ITEM(0, "Choisir l'item 1", GOSSIP_SENDER_MAIN, 1); player->ADD_GOSSIP_ITEM(0, "Choisir l'item 2", GOSSIP_SENDER_MAIN, 2); player->PlayerTalkClass->GetGossipMenu().SetMenuId(123); player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, player->GetGUID()); } } } } void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action) { if(menu_id != 123) return; player->PlayerTalkClass->ClearMenus(); switch(action) { case 1 : player->AddItem(ITEM_ID_1, ITEM_QUANTITY_1); player->SaveToDB(); ++HasItem; break; case 2 : player->AddItem(ITEM_ID_2, ITEM_QUANTITY_2); player->SaveToDB(); ++HasItem; break; } player->CLOSE_GOSSIP_MENU(); } }; void AddSC_totaltimeplayed_reward() { new totaltimeplayed_reward(); }
while (HasItem != 1)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(0, "Choisir l'item 1", GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM(0, "Choisir l'item 2", GOSSIP_SENDER_MAIN, 2);
player->PlayerTalkClass->GetGossipMenu().SetMenuId(123);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, player->GetGUID());
}
I'll try to fix that, thanks again
Edit : It works like a charm ! But you're right, I don't have a single idea how to do this, but i need to execute the script like every 5 seconds, otherwise it creates a bit of lags.
Should i use diff variable to do this ?
I suggest you create a support thread.
In there you should show the current script you have so far.
You should also tell, in detail, what you want to do.
Then it will not bloat this topic and you may get more replies. Also telling what you are after may give ideas of different approaches etc.
And yes. You could use the diff variable.