.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Registered User Msgs (http://forums.bots-united.com/showthread.php?t=158)

BAStumm 02-01-2004 21:11

Registered User Msgs
 
Hey all, I twas Brian on botmans forums. :)

In my various development related files and notes I came across this file with some info on all the reg user msgs for TFC. I am looking for same for DoD now but can't remember how I got this list. I think I may have ran some exe against the dll file but am not sure if thats right or what this program may have been called... Been searching high and low. Does anyone recognize this piece of info?

Code:


Game registered user msgs:        msgid size
VoiceMask                                        64        8
ReqState                                        65        0
SelAmmo                                        66        4
CurWeapon                                        67        3
Geiger                                        68        1
Flashlight                                69        2
FlashBat                                        70        1
Health                                        71        1
Damage                                        72        12
Battery                                        73        4
SecAmmoVal                                74        2
SecAmmoIcon                                75        -1
Train                                                76        1
Items                                                77        4
Concuss                                        78        1
HudTextPro                                79        -1
HudText                                        80        -1
SayText                                        81        -1
StatusIcon                                82        -1
TextMsg                                        83        -1
SpecHealth                                84        1
StatusText                                85        -1
StatusValue                                86        3
WeaponList                                87        -1
ResetHUD                                        88        1
InitHUD                                        89        0
ViewMode                                        90        0
GameTitle                                        91        1
DeathMsg                                        92        -1
ScoreInfo                                        93        9
TeamInfo                                        94        -1
TeamScore                                        95        -1
GameMode                                        96        1
MOTD                                                97        -1
ServerName                                98        -1
AmmoPickup                                99        2
WeapPickup                                100        1
ItemPickup                                101        -1
HideWeapon                                102        1
SetFOV                                        103        1
ShowMenu                                        104        -1
ScreenShake                                105        6
ScreenFade                                106        10
AmmoX                                        107        2
Bench                                        108        1
Spectator                                109        2
AllowSpec                                110        1
SpecFade                                        111        6
ResetFade                                112        0
ValClass                                        113        10
TeamNames                                114        -1
Feign                                        115        1
Detpack                                        116        1
VGUIMenu                                        117        -1
BuildSt                                        118        2
RandomPC                                        119        1
56 game user msgs


BAStumm 02-01-2004 21:18

Re: Registered User Msgs
 
weird, when you use fixedsys font when posting it shows things line up right but after submitting the post it whacks the formatting... :(

BAStumm 02-01-2004 21:19

Re: Registered User Msgs
 
oh and something tells me PM led me to whatever allowed me to get this info... help me PM :)

Lazy 02-01-2004 21:32

Re: Registered User Msgs
 
Sure, go to where you have pfnRegUserMsg hooked...
int iMessage = REG_USER_MESSAGE( themessagename, thesize );

Write the message number, size and name to the server console/log and return iMessage.

That worked for me a while ago in a metamod plugin but since its been a while you'll have to play around with that info.

Pierre-Marie Baty 02-01-2004 21:42

Re: Registered User Msgs
 
You should forget completely trying to reference network messages by their ID numbers only. Forget the ID numbers, they're not explicit, not readable, complicated etc etc.

Why don't you write a set of functions that would query for you a small database of message name/ID pairs each time you request a message ?

Like metamod's GET_USER_MSG_NAME() and GET_USER_MSG_ID()...

I already have written something like this. The basis is in pfnRegUserMsg() since it's where all messages are registered. First off, the message structure...
Code:

// user message record structure definition
typedef struct
{
  const char *name;
  int id;
} usermsg_t;
 
usermsg_t usermsgs[255]; // max of 256 different network messages

and then the pfnRegUserMsg() function
Code:

int pfnRegUserMsg (const char *pszName, int iSize)
{
  int index = -1;

  int msg = (*g_engfuncs.pfnRegUserMsg) (pszName, iSize); // register the message
 
  // is this message NOT already registered ?
  for (index = 0; index < usermsgs_count; index++)
          if (strcmp (usermsgs[index].name, pszName) == 0)
                break; // cycle through usermsgs types array and break if found
 
  // now keep track (or update if necessary) this user message in our array...
  usermsgs[index].name = pszName; // record this message's name
  usermsgs[index].id = msg; // record this message's index

  // are we certain this message has not been registered in the past ?
  if (index == usermsgs_count)
          usermsgs_count++; // we know now one user message more
 
  return (msg); // ...and return the message ID number the engine gave us
}

and then each time you're in need for a particular message, for example let's say you want to send a TempEntity message to display a colorful welcome text with hudtextparms and stuff, you use these two nice helper functions :
Code:

int GetUserMsgId (const char *msg_name)
{
  register int i;
 
  // is it a standard engine message (i.e, already registered by engine) ?
  if (strcmp ("TempEntity", msg_name) == 0)
          return (SVC_TEMPENTITY); // return the correct message ID
  else if (strcmp ("Intermission", msg_name) == 0)
          return (SVC_INTERMISSION); // return the correct message ID
  else if (strcmp ("CDTrack", msg_name) == 0)
          return (SVC_CDTRACK); // return the correct message ID
  else if (strcmp ("WeaponAnim", msg_name) == 0)
          return (SVC_WEAPONANIM); // return the correct message ID
  else if (strcmp ("RoomType", msg_name) == 0)
          return (SVC_ROOMTYPE); // return the correct message ID
  else if (strcmp ("Director", msg_name) == 0)
          return (SVC_DIRECTOR); // return the correct message ID
 
  // cycle through our known user message types array
  for (i = 0; i < usermsgs_count; i++)
          if (strcmp (usermsgs[i].name, msg_name) == 0)
                return (usermsgs[i].id); // return the id of the message named msg_name
 
  return (-1); // message not found, wtf?
}

const char *GetUserMsgName (int msg_type)
{
  register int i;
 
  // is it a standard engine message (i.e, already registered by engine) ?
  if (msg_type == SVC_TEMPENTITY)
          return ("TempEntity"); // return the correct message name
  else if (msg_type == SVC_INTERMISSION)
          return ("Intermission"); // return the correct message name
  else if (msg_type == SVC_CDTRACK)
          return ("CDTrack"); // return the correct message name
  else if (msg_type == SVC_WEAPONANIM)
          return ("WeaponAnim"); // return the correct message name
  else if (msg_type == SVC_ROOMTYPE)
          return ("RoomType"); // return the correct message name
  else if (msg_type == SVC_DIRECTOR)
          return ("Director"); // return the correct message name
 
  // cycle through our known user message types array
  for (i = 0; i < usermsgs_count; i++)
          if (usermsgs[i].id == msg_type)
                return (usermsgs[i].name); // return the name of the message having the msg_type id
 
  return (NULL); // unknown user message
}

and it gives you something like this, for example :
Code:

          MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, GetUserMsgId ("TempEntity"), NULL, pClient);
          WRITE_BYTE (TE_TEXTMESSAGE);
          WRITE_BYTE (1); // etc...

Note the use of GetUserMsgId(). So what do you think ? l33t, eh ? 8)

BAStumm 02-01-2004 22:53

Re: Registered User Msgs
 
your code assumes that I know what user msgs exist in the mod, that is the problem I need a list of what those messages are so I can determine which to intercept and what to do with them.

In addition I want to send these messages at other times when I deem fit. In DoD the screen turns redish tint to simulate pain. I want to send that effect as a part of a "slap" admin command. But in order to do so need to know the name of that message. I'm aware of not wanting to use the number, I just need a list of all user msg names for reference...

I'm nearly positive it was some exe file that I ran against the mod dll that produced my list above. But for the life of me can't remember the name of it. I realize I could write my own code to gather this but why reinvent the wheel. Perhaps I'll have to if noone remembers such an app.

BAStumm 02-01-2004 22:56

Re: Registered User Msgs
 
aha, someone from the hlcoders list reminded me DOH!

Its "meta game" to metamod :)

I new it was something simple :)

Lazy 02-01-2004 22:57

Re: Registered User Msgs
 
You wouldn't have been able to since user messages are registered by the engine at runtime ( Almost 100% positive ). You have to get that info while the messages are being registered by the game dll. Both mine and PM's examples showed you how in some way.

Pierre-Marie Baty 02-01-2004 23:38

Re: Registered User Msgs
 
well, nothing prevents you from dumping the whole messages database in a text file or in the console once they've all been registered by pfnRegUserMsg... a couple printf's will do :)

Anyway Lazy's example shows a simple way to go too :)

BAStumm 02-01-2004 23:45

Re: Registered User Msgs
 
Thanks guys, the "meta game" command was all I was looking for :)


All times are GMT +2. The time now is 05:37.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.