Raised This Month: $51 Target: $400
 12% 

[Metamod] Print to all players, get userid, authid,


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rirre
Veteran Member
Join Date: Nov 2006
Old 06-05-2014 , 17:24   [Metamod] Print to all players, get userid, authid,
Reply With Quote #1

- First:
I can't figure out a way to print a message to all players without getting an error.
This works:
Code:
int UTIL_TakeDamage( edict_t *pEdict, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
	if ( pEdict->v.health <= 0 )
	{
		CLIENT_PRINTF( pEdict, print_console, UTIL_VarArgs( "%s was killed by an %s\n",
			STRING( pEdict->v.netname ),
			STRING( pevAttacker->classname ) ) );
	}
}
But I need it to print to all players.
This one just crashing the server with SZ_GetSpace: Tried to write to an uninitialized sizebuf_t: ??? when I or anyone else gets killed:
Code:
int UTIL_TakeDamage( edict_t *pEdict, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
	if ( pEdict->v.health <= 0 )
	{
		for (int i = 1; i <= gpGlobals->maxClients; i++)
		{
			edict_t *pPlayer = INDEXENT(i);

			if( !pPlayer )
			{
				continue;
			}

			CLIENT_PRINTF( pPlayer, print_console, UTIL_VarArgs( "%s was killed by an %s\n",
				STRING( pEdict->v.netname ),
				STRING( pevAttacker->classname ) ) );
		}
	}
}



- Second:
Need some help with this to get a player's index and authid.
My (user)ID is 15 always, which is wrong. It's 1 as you can see yourself on the first line. And I have no idea what's happening with the authid.
Code:
int UTIL_TakeDamage( edict_t *pEdict, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
	if ( pEdict->v.health <= 0 )
	{
		UTIL_LogPrintf( "\"%s\" killed \"%s<%i><%s>\"\n",  
			STRING( pevAttacker->classname ),
			STRING( pEdict->v.netname ) ),
			GETPLAYERUSERID( pEdict ),
			GETPLAYERAUTHID( pEdict );
	}
}

Also, I'm pretty sure CS don't use pev->team for team assignment so I need one for both CS and other mods which use pev->team which I have no clue about how to do.

Last edited by Rirre; 06-05-2014 at 20:08.
Rirre is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 06-06-2014 , 02:28   Re: [Metamod] Print to all players, get userid, authid,
Reply With Quote #2

First:

PHP Code:
#define IsValidPev(pEntity) (!FNullEnt(pEntity) && pEntity->pvPrivateData) 
PHP Code:
    for (int i 1<= gpGlobals->maxClientsi++)
        {
            
edict_t *pPlayer INDEXENT(i);

            if( !
IsValidPevpPlayer ) )
                continue;
    
            
CLIENT_PRINTFpPlayerprint_consoleUTIL_VarArgs"%s was killed by an %s\n",
                
STRINGpVictim->v.netname ),
                
STRINGpevAttacker->classname ) ) );
    } 
Second:

Quote:
UTIL_LogPrintf( "\"%s\" killed \"%s<%i><%s>\"\n",
STRING( pevAttacker->classname ),
STRING( pEdict->v.netname ) ),
GETPLAYERUSERID( pEdict ),
GETPLAYERAUTHID( pEdict );
->

Quote:
UTIL_LogPrintf( "\"%s\" killed \"%s<%i><%s>\"\n",
STRING( pevAttacker->classname ),
STRING( pEdict->v.netname ),
GETPLAYERUSERID( pEdict ),
GETPLAYERAUTHID( pEdict ) );
__________________

Last edited by Bos93; 06-06-2014 at 03:22.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Rirre
Veteran Member
Join Date: Nov 2006
Old 06-06-2014 , 02:53   Re: [Metamod] Print to all players, get userid, authid,
Reply With Quote #3

Thank you, appreciate it

Just the second one left now then.
Rirre is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 06-06-2014 , 03:23   Re: [Metamod] Print to all players, get userid, authid,
Reply With Quote #4

My message is updated
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Rirre
Veteran Member
Join Date: Nov 2006
Old 06-06-2014 , 03:46   Re: [Metamod] Print to all players, get userid, authid,
Reply With Quote #5

Compiles fine without additional parentheses, if I add the additional parentheses:
Code:
Error: expected a ';'

Last edited by Rirre; 06-06-2014 at 03:47.
Rirre is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 06-06-2014 , 05:56   Re: [Metamod] Print to all players, get userid, authid,
Reply With Quote #6

nooo

copypast

PHP Code:
UTIL_LogPrintf"\"%s\" killed \"%s<%i><%s>\"\n"
STRINGpevAttacker->classname ),
STRINGpEdict->v.netname ),
GETPLAYERUSERIDpEdict ),
GETPLAYERAUTHIDpEdict ) ); 
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Rirre
Veteran Member
Join Date: Nov 2006
Old 06-06-2014 , 06:09   Re: [Metamod] Print to all players, get userid, authid,
Reply With Quote #7

Ah now I get it, where was a additional ')' after STRING( pEdict->v.netname ),
Thanks
Rirre is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 06-06-2014 , 06:11   Re: [Metamod] Print to all players, get userid, authid,
Reply With Quote #8

I highlighted with the red color version with the mistake, I hoped you understand
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 06-10-2014 , 08:52   Re: [Metamod] Print to all players, get userid, authid,
Reply With Quote #9

For a much more logical method, you can check for health like that:

PHP Code:
if (!(ent->v.health 0)) { } 
__________________

Last edited by claudiuhks; 06-13-2014 at 19:56.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode