|
Post by Werehound Silverfang on Oct 18, 2010 0:10:06 GMT
Is this possible in the windows version? If so, how can one send a [Server] message to a specific player?
|
|
|
Post by FunkySwerve on Oct 20, 2010 0:18:34 GMT
// Send a server message (szMessage) to the oPlayer. void SendMessageToPC(object oPlayer, string szMessage)
Other than the obvious...I'm not sure what you're asking. Surely it wasn't the formatting of the string that's stumping you? If you mean you want to send messages across servers, that requires a database server to pass data from one instance to the other. Something like this, for example:
SendGlobalMessage(oMod, 0, sName, sKey, "Run forming on server " + GetLocalString(oMod, "ServerNumber") + ". Contact " + sName + " (" + GetPCPlayerName(oCPC) + ") if interested: " + sMessage, "Run forming on this server. Contact " + sName + " (" + GetPCPlayerName(oCPC) + ") if interested: " + sMessage);
Here's the global message function:
void SendGlobalMessage (object oMod, int nGuild, string sName, string sKey, string sMessage, string sThisMessage="") { string sTarget, sServer = GetLocalString(oMod, "ServerNumber"); string sGuild = IntToString(nGuild); string sEnc = SQLEncodeSpecialChars(sMessage); string sSQL = "";
sName = SQLEncodeSpecialChars(sName);
SQLExecDirect("SELECT srv_id FROM server_list WHERE srv_utime + 60 >= (UNIX_TIMESTAMP() - srv_btime)");
while (SQLFetch() != SQL_ERROR) { sTarget = SQLGetData(1);
if (nGuild == 0 && sTarget == sServer) { if (sThisMessage != "") AssignCommand(oMod, SpeakString(sThisMessage, TALKVOLUME_SHOUT)); else AssignCommand(oMod, SpeakString(sMessage, TALKVOLUME_SHOUT)); } else { sSQL += (sSQL == "" ? "" : ", ") + "(NULL, '" + sName + "', '" + sKey + "', '*" + sTarget + "', '" + sEnc + "', " + sGuild + ", UTC_TIMESTAMP())"; } }
SQLExecDirect("INSERT INTO user_messages VALUES " + sSQL);
sSQL = "INSERT INTO user_message_history " + "(umh_id, umh_sender_name, umh_sender_cdkey, umh_recipient, umh_text, umh_guild, umh_sent, umh_tstamp) VALUES (NULL, '" + sName + "', '" + sKey + "', '*', '" + sEnc + "', " + IntToString(nGuild) + ", UNIX_TIMESTAMP(), UTC_TIMESTAMP())";
SQLExecDirect(sSQL); }
As you can see, it involves a lot of moving parts, requiring tracking logins and logouts and the like, multiple database tables, setting of certain variables on the mod on load, and other things that are highly interwoven into our setup. Not really something I have time to help you set up.
LMK if this answers your question. If it doesn't, please provide a specific example of what you're hoping to emulate.
Best, Funky
|
|
|
Post by Werehound Silverfang on Oct 20, 2010 1:39:53 GMT
No, the standard function SendMessageToPC sends a message that is filtered out when the combat log is turned off. I want to send a [Server] message, (much like SR is filtered to be sent through the server channel on HG, and similar messages (You have entered a No PVP area, etc)). These are all prefaced with the string "[Server] ", appear in gray (unless color tags are added to the string being sent), and are shown even when Combat Information is excluded.
They also announce when a player enters and leaves the server.
|
|
|
Post by FunkySwerve on Oct 20, 2010 2:18:10 GMT
No, the standard function SendMessageToPC sends a message that is filtered out when the combat log is turned off. No? I didn't contradict that, but then, you didn't ask that. You want to know about System messages. void SendSystemMessage (object oRecipient, string sMessage) { if (!GetIsObjectValid(oRecipient) || FindSubString(sMessage, "¬") >= 0) return;
SetLocalString(oRecipient, "NWNX!CHAT!SPEAK", ObjectToString(oRecipient) + "¬" + ObjectToString(oRecipient) + "¬5¬" + sMessage); }
They just set the server channel as the message's channel (that's what the '5' indicates). You can format them as you like. As to whether your combat log will filter them without additional hacks - not sure, test and see (I'm pretty sure it will work for you). Acaos may or may not have tinkered with that in the engine, but the core functionality is right out of nwnx_chat. Edit: Here's the spell resistance message for reference - the switch is based on how the pc has their messaging preferences set: void SendTurnResistanceMessage (object oTurner, object oTarget, int nRoll, int nTP, int nTR, float fDelay=0.0) { struct SubString ss = GetTurnResistanceMessage(oTurner, oTarget, nRoll, nTP, nTR);
switch (GetPCFilter(oTurner, PCFILTER_SPELLPEN)) { case 0: DelayCommand(fDelay, SendMessageToPC(oTurner, ss.first)); break; case 1: DelayCommand(fDelay, SendSystemMessage(oTurner, ss.first)); break; case 2: DelayCommand(fDelay, FloatingTextStringOnCreature(ss.first, oTurner, FALSE)); break; }
switch (GetPCFilter(oTarget, PCFILTER_SPELLPEN)) { case 0: DelayCommand(fDelay, SendMessageToPC(oTarget, ss.rest)); break; case 1: DelayCommand(fDelay, SendSystemMessage(oTarget, ss.rest)); break; case 2: DelayCommand(fDelay, FloatingTextStringOnCreature(ss.rest, oTarget, FALSE)); break; } }
Funky
|
|
|
Post by Werehound Silverfang on Oct 20, 2010 3:12:10 GMT
Brilliant.
Thank you =). I can get the command to work on my linux machne, but my Vista 32 and win7 64 bit machines crash when the command is executed.
The same thing happens when trying to route tells to players (like the DM channel routing). ntdll.dll mysteriously crashes.
The only commands that crash the nwserver.exe application are SendChatLogMessage and the one you just posted.
Sad, eh? Ah well, my curiosity is now sufficiently sated. TY sir.
|
|
|
Post by FunkySwerve on Oct 20, 2010 3:26:18 GMT
Might want to make sure your win plugins are up to date, by checking on the NWNX forums' Windows Development subforum. Windows had a lot of crash bugs, but I think they're mostly worked out by now.
Funky
|
|
|
Post by Werehound Silverfang on Oct 20, 2010 3:29:01 GMT
Aye, I have, and have even sent private messages to virusman and zebranky. It's just my machines. The SendChatLogMessage function works fine on a friend's XP system. I don't see exceptional Win7 or Vista compatibility being developed either, as the time invested just wouldn't be worth it.
|
|