Raised This Month: $ Target: $400
 0% 

Event_DeathMsg if server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-27-2013 , 13:30   Event_DeathMsg if server
Reply With Quote #1

PHP Code:
iKiller read_data);
g_iKillsiKiller ] ++; 
How to return if iKiller is SERVER?
Debesėlis is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-27-2013 , 13:37   Re: Event_DeathMsg if server
Reply With Quote #2

Add in register_event filter "1>0" so you won't collect when killer is 0
In callback, check killer against maxplayers value
PHP Code:
new g_iMaxPlayers;

public 
plugin_init()
{
    
register_event("DeathMsg""Event_DeathMsg""a""1>0");
    
g_iMaxPlayers get_players();
}
    
public 
Event_DeathMsg()
{
    new 
killer read_data(1);
    if( 
killer g_iMaxPlayers )
    {
        return;
    }

    
g_iKillskiller ] ++;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-27-2013 , 13:41   Re: Event_DeathMsg if server
Reply With Quote #3

What if i use this?

PHP Code:
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

    
if ( IsPlayeriKiller ) )
    {
        if ( 
g_iKillsiKiller ] == 99 )
        {
             
// do something
        
}
    } 
What is doing this one?
PHP Code:
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers ) 
Debesėlis is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-27-2013 , 15:40   Re: Event_DeathMsg if server
Reply With Quote #4

Quote:
Originally Posted by Debesėlis View Post
What if i use this?

PHP Code:
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

    
if ( IsPlayeriKiller ) )
    {
        if ( 
g_iKillsiKiller ] == 99 )
        {
             
// do something
        
}
    } 
What is doing this one?
PHP Code:
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers ) 
It is same as checking : if( 1 <= iKiller <= g_iMaxPlayers )

But, since we added filter 1>0 in register_event, we already know iKiller is >= 1, so we only need to check if iKiller <= g_iMaxPlayers
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
lein
Junior Member
Join Date: Mar 2013
Location: China
Old 10-27-2013 , 13:57   Re: Event_DeathMsg if server
Reply With Quote #5

#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
we call it 预编译。 \(^o^)/

PreProcessor
You can buy a book about C,then you'll konw these:
#include
#define
#if、#else、#endif
......
Lexical preprocessors are the lowest-level of preprocessors, in so far as they only require lexical analysis, that is, they operate on the source text, prior to any parsing, by performing simple substitution of tokenized character sequences for other tokenized character sequences, according to user-defined rules. They typically perform macro substitution, textual inclusion of other files, and conditional compilation or inclusion.
C preprocessor[edit]
Main article: C preprocessor
The most common example of this is the C preprocessor, which takes lines beginning with '#' as directives. Because it knows nothing about the underlying language, its use has been criticized and many of its features built directly into other languages. For example, macros replaced with aggressive inlining and templates, includes with compile-time imports (this requires the preservation of type information in the object code, making this feature impossible to retrofit into a language); conditional compilation is effectively accomplished with if-then-else and dead code elimination in some languages.
lein is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 10-27-2013 , 14:55   Re: Event_DeathMsg if server
Reply With Quote #6

Code:
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )
In hlds , players get a number (id). This id can be 1,2, ..., max players (32 is max on HLDS).

So, this function check if iKiller (id) is player and not something else (fall, world , etc).
Than to write
Code:
if( 1 <= iKiller <= g_iMaxPlayers )
, with this function can write
Code:
if( IsPlayer( iKiller ) )
.

You understand ?
DWIGHTpN is offline
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-27-2013 , 16:59   Re: Event_DeathMsg if server
Reply With Quote #7

Ok i understand. Thanks guys.
Debesėlis is offline
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 23:20.


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