PDA

View Full Version : TrinityCore 3.3.5 Custom command for displayed respawn timers



Jeremiassen1
08-23-2016, 09:04 PM
Hey.

I was wondering if someone could help me out with a little script for a custom command on a 3.3.5a trinity server. The command is supposed to display remaining respawntime for a creature to respawn in the players chat. Would be neat if someone here could help me out

Djundead
08-23-2016, 09:50 PM
i think if u do .npc info it displays the respawn time

Vitrex
08-24-2016, 01:57 PM
i think if u do .npc info it displays the respawn time
https://www.reaper-x.com/2009/01/01/trinity-core-gm-commands/



Syntax: .npc info Display a list of details for the selected creature.
The list includes:
– GUID, Faction, NPC flags, Entry ID, Model ID,
– Level,
– Health (current/maximum),
– Field flags, dynamic flags, faction template,
– Position information,
– and the creature type, e.g. if the creature is a vendor.


What exactly help do you need? don't know where to start or stucked somewhere ?

slp13at420
08-25-2016, 03:05 AM
these would be the 4 lines I would look at in \src\server\scripts\Commands\cs_npc.cpp in `static bool HandleNpcInfoCommand(ChatHandler* handler, char const* /*args*/)`
:



Creature* target = handler->getSelectedCreature();

int64 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL);

if (curRespawnDelay < 0)
curRespawnDelay = 0;


create pointer called `target` for creature , and get respawn timer left and set to 0 if it math's out to a negative integer.

probably these 2 lines too:



std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);



so you can post `respawn timer` and `respawn timer left`.




handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());



I added this idea to the EmuDevs Community Premium System --> http://emudevs.com/showthread.php/5708-CPP-EmuDevs-Community-Premium-System