Modcraft - The community dedicated to quality WoW modding!
Wrath of the Lich King Modding => Serverside Modding => Topic started by: Everon Mightbane on August 24, 2011, 09:09:53 pm
-
Hey does anyone have or know about a trinity announce system that roughly outputs:
Servername Rank PlayerName: Message
So for example
CoolWoW Admin Bob: Hello world.
Thanks in advance.
-
you can mod the announce command to include the servername. check out the cs_* and level* files.
-
Yeah, I've been able to include the server name but I haven't managed to do the rank part.
-
You could call the player's GMlevel and then based on that level add a rank to the command
for example:
uint32 gmlevel = player->GetSession()->GetSecurity();
std::string rank;
switch (gmlevel)
{
case 1: // gmlevel is 1
rank = "Moderator"; break;
case 2: // gmlevel is 2
rank = "Game Master"; break;
case 3: // gmlevel is 3
rank = "Server Admin"; break;
default: rank = ""; break;
}
that way the 'rank' string has the current playerrank, you can simple add this inside the announce. Adding more ranks should be easy.
-
You could call the player's GMlevel and then based on that level add a rank to the command
for example:
uint32 gmlevel = player->GetSession()->GetSecurity();
std::string rank;
switch (gmlevel)
{
case 1: // gmlevel is 1
rank = "Moderator"; break;
case 2: // gmlevel is 2
rank = "Game Master"; break;
case 3: // gmlevel is 3
rank = "Server Admin"; break;
default: rank = ""; break;
}
that way the 'rank' string has the current playerrank, you can simple add this inside the announce. Adding more ranks should be easy.
I hope their rank variable is enumerated. You may want to use that enumeration instead.
-
I hope their rank variable is enumerated. You may want to use that enumeration instead.
It is, and GetSecurity() returns the value of that. yet you have to put a string with that int yourself.
-
I hope their rank variable is enumerated. You may want to use that enumeration instead.
It is, and GetSecurity() returns the value of that. yet you have to put a string with that int yourself.
Yes, but you shouldn't compare to 1, 2 and 3 then but against the names of the enumeration, to be safe and verbose.
-
I hope their rank variable is enumerated. You may want to use that enumeration instead.
It is, and GetSecurity() returns the value of that. yet you have to put a string with that int yourself.
Yes, but you shouldn't compare to 1, 2 and 3 then but against the names of the enumeration, to be safe and verbose.
Yeah alright :P i wasn't applying code styles eitherway since i wrote this in 10secs.
Yet with your way it would look like this;
case SEC_MODERATOR:
rank = "Moderator"; break;
case SEC_GAMEMASTER:
rank = "Game Master"; break;
case SEC_ADMINISTRATOR:
rank = "Server Admin"; break;
-
Alright, Just compiling now. Lets see how this goes :D Thanks for your help everyone.
-
It didn't work so far but I'm going to tinker with it, one thing though. As trinity only has the account permissions 0-4, 4 being the console, is there anyway to increase the number? Or change it to like az a p - As in alphabetical account permissions?
-
It didn't work so far but I'm going to tinker with it, one thing though. As trinity only has the account permissions 0-4, 4 being the console, is there anyway to increase the number? Or change it to like az a p - As in alphabetical account permissions?
You can add more account permission levels in Common.h atleast if you keep your SEC_CONSOLE as the last one. The security level required to do commands is held in the Command table in your database. so you will probably have to update all those records. (can be done with a few lines of SQL)
-
Thanks :D I'll work on that now. EDIT: Also, can I change them to alphabetic characters so for example:
SEC_ADMINISTRATOR = "az",
Would that work?
-
Thanks :D I'll work on that now. EDIT: Also, can I change them to alphabetic characters so for example:
SEC_ADMINISTRATOR = "az",
Would that work?
No that won't work, you cannot enumerate anything else then integers
-
Yeah, I worked that out after I attempted to compile it, Is there any way I can change that?
-
Yeah, I worked that out after I attempted to compile it, Is there any way I can change that?
I'm afraid there isn't an easy way, no. :P
-
Meh. Well that sucks. Thanks anyway.
-
Sorry for double posting, but could someone take a look at this and tell me why its not working, it compiles just fine, however when I use .announce my worldserver.exe crashes.: [spoiler:2mi2ysll]
#include "Chat.h"
#include "ScriptPCH.h"
class ann_commandscript : public CommandScript
{
public:
ann_commandscript() : CommandScript("ann_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand commandTable[] =
{
{ "announce", SEC_PLAYER, true, &HandleAnnounceCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
};
static bool HandleAnnounceCommand(ChatHandler* handler, const char* args)
{
std::string rank("");
uint32 gmlevel;
WorldPacket data;
std::string name("Console");
if (WorldSession* session = handler->GetSession())
{
Player* player = session->GetPlayer();
gmlevel = player->GetSession()->GetSecurity();
switch (gmlevel)
{
case 0:
rank = "|cff0051FFPlayer|r"; break;
case 1:
rank = "|cff88DC51Voter|r"; break;
case 2:
rank = "|cffF28A00Donator|r"; break;
case 3:
rank = "|cffAD01B0Moderator|r"; break;
case 4:
rank = "|cffAD01B0Administrator|r"; break;
}
}
if (!*args)
return false;
if (WorldSession* session = handler->GetSession())
name = session->GetPlayer()->GetName();
sWorld->SendWorldText(LANG_CUSTOM_ANNOUNCE, rank, name, args);
return true;
}
};
void AddSC_ann_commandscript()
{
new ann_commandscript();
};
[/spoiler:2mi2ysll]
LANG_CUSTOM_ANNOUNCE is linked up in language.h and has the correct reference in my trinity_string table and the script compiles without issue.
-
Please use pastbin!
-
Player* player = session->GetPlayer();
> Not checked for player == NULL.
gmlevel = player->GetSession()->GetSecurity();
> Not checked for GetSessin() == NULL, also this should be the same as session already retrieved earlier.
if (!*args)
> You should check that right away on the top, before doing anything else.
if (WorldSession* session = handler->GetSession())
name = session->GetPlayer()->GetName();
> You're getting the session another time. Also, not checking for player being NULL.
sWorld->SendWorldText(LANG_CUSTOM_ANNOUNCE, rank, name, args);
> sWorld is NULL? Idk.
-
Still not working heres my updated code: http://pastebin.com/FV1rtUP7 (http://pastebin.com/FV1rtUP7" onclick="window.open(this.href);return false;)
-
Still not working heres my updated code: http://pastebin.com/FV1rtUP7 (http://pastebin.com/FV1rtUP7" onclick="window.open(this.href);return false;)
When Trinity is crashing, it produces a crash dump containing information for MSVC++. this even contains the line where it crashed and maybe indicators, why.
Have a look at that.
-
Mine says this:
C:UsersSamDesktopGlorious-WoW CoresrcserverworldserverMaster.cpp:105 in FreezeDetectorRunnable::run ASSERTION FAILED:
false
[0x2dc430]
?invoke@ACE_OS_Thread_Adapter@@UAEKXZ()+0x74 [0x0]
_endthreadex()+0x3a [0x0]
_endthreadex()+0xe4 [0x0]
BaseThreadInitThunk()+0x12 [0x0]
RtlInitializeExceptionChain()+0x63 [0x0]
RtlInitializeExceptionChain()+0x36 [0x0]