-- Adjusted PrintToServer to use MessageServer so servers with multiple game servers hosting zones will function properly.
----
Fairly customized, but I decided to re-modify/research and with a lot of help From Kj, atom0s, and Demolish, I think we have it pretty awesome now.
First, at the top of lua_baseentity.cpp in the declarations:
Code: Select all
#include"../message.h"
lua_baseentity.cpp
Find: inline int32 CLuaBaseEntity::PrintToPlayer
Remove existing PrintToPlayer and replace with this:
Code: Select all
inline int32 CLuaBaseEntity::PrintToPlayer(lua_State* L)
{
DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL);
DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_PC);
DSP_DEBUG_BREAK_IF(lua_isnil(L, 1) || !lua_isstring(L, 1));
CHAT_MESSAGE_TYPE messageType = (!lua_isnil(L, 2) && lua_isnumber(L, 2) ? (CHAT_MESSAGE_TYPE)lua_tointeger(L, 2) : MESSAGE_SYSTEM_1);
((CCharEntity*)m_PBaseEntity)->pushPacket(new CChatMessagePacket((CCharEntity*)m_PBaseEntity, messageType, (char*)lua_tostring(L, 1)));
return 0;
}
inline int32 CLuaBaseEntity::PrintToServer(lua_State* L)
{
DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL);
DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_PC);
DSP_DEBUG_BREAK_IF(lua_isnil(L, 1) || !lua_isstring(L, 1));
CHAT_MESSAGE_TYPE messageType = (!lua_isnil(L, 2) && lua_isnumber(L, 2) ? (CHAT_MESSAGE_TYPE)lua_tointeger(L, 2) : MESSAGE_SYSTEM_1);
message::send(MSG_CHAT_SERVMES, 0, 0, new CChatMessagePacket((CCharEntity*)m_PBaseEntity, messageType, (char*)lua_tostring(L, 1)));
return 0;
}
LUNAR_DECLARE_METHOD(CLuaBaseEntity,PrintToPlayer),
Add below it:
Code: Select all
LUNAR_DECLARE_METHOD(CLuaBaseEntity,PrintToServer),
Find line: int32 PrintToPlayer(lua_State* L);
Add below it:
Code: Select all
int32 PrintToServer(lua_State* L); // Print to SERVER (Prints to every zone on the server) -- Defaults to System Message, but can be altered with HEX or Integer of type of text
So what does that let you do? A lot! You can now modify any place in Lua files that has "PrintToPlayer" to add some color/special stuff, etc.
Examples:
player.lua -> Under OnGameIn If Not Zoning:
Code: Select all
player:PrintToServer(string.format("The character %s has logged in...", player:getName()), 0x1C);
Code: Select all
player:PrintToServer(" -- Logged In", 8);
--------
We have special Linkshells on our server, so another message a new player will recieve is this:
Code: Select all
player:PrintToPlayer("You are now in the BNETcc Linkshell", 0x10);
I'm planning on adding some more simplified names in status.lua file shortly, to make this simpler instead of having to use hex/numbers, but for now this is functional, and stable. One word of warning, the gmtell chat.. It seems to open up a message box. Not exactly sure what can all be done with it yet.. But it seems cool to play with.
My @test command to check out the colors:
Code: Select all
---------------------------------------------------------------------------------------------------
-- func: @testcolors
-- auth: Tagban
-- desc: Test Command to check colors are working for debugging.
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "s"
};
function onTrigger(player)
player:PrintToPlayer("Say MESSAGE_SAY 0", 0);
player:PrintToPlayer("Shout MESSAGE_SHOUT 1", 1);
player:PrintToPlayer("Emote MESSAGE_EMOTE 8", 8);
player:PrintToPlayer("Yell MESSAGE_YELL 0x1A", 0x1A);
player:PrintToPlayer("Tell MESSAGE_TELL 3", 3);
player:PrintToPlayer("Party/Alliance MESSAGE_PARTY 4", 4);
player:PrintToPlayer("Linkshell 1 MESSAGE_LINKSHELL 5", 5);
player:PrintToPlayer("Linkshell 2 msgTypeLS2 0x1B", 0x1B);
player:PrintToPlayer("Linkshell 3 msgTypeLS3 0x1E", 0x1E);
player:PrintToPlayer("Unity Msg msgTypeUnity 0x21", 0x21);
player:PrintToPlayer("SystemMessage MESSAGE_SYSTEM_1 6", 6);
player:PrintToPlayer("Msg Only (Yellow) msgTypeYellow 0x15", 0x15);
player:PrintToPlayer("Msg Only (White like Say) msgTypeWhite 0xD", 0xD);
player:PrintToPlayer("Msg Only (Pinkish like Shout) msgTypePink 0xE", 0xE);
player:PrintToPlayer("Msg Only (Lime like Linkshell) msgTypeLime 0x10", 0x10);
player:PrintToPlayer("Msg Only (Green) msgTypeGreen 0x1C", 0x1C);
player:PrintToPlayer("Msg Only Generic Yellow 0x1F", 0x1F);
player:PrintToPlayer("Msg Only (Blue) msgTypeBlue 0xF", 0xF);
player:PrintToPlayer("---- Test Complete ----", 8);
end;
-------------------
Hope you enjoy this! There are a few other chat things that atom0s had posted which is what started me on messing with this stuff. Gold/Yellow appear to be the same, so I removed GOLD from this post.
--------------
Thanks again to demolish, atom0s, and kjlotus. You guys helped me get this working, and I greatly GREATLY appreciate it.