AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Explain the difference (https://forums.alliedmods.net/showthread.php?t=230055)

devWaleed 11-19-2013 03:03

Explain the difference
 
EDIT: I know how to hook all 3 events but each event is executed differently (paramaters) in many plugins but they still do the same thing. Can anybody please explain this?

PHP Code:

// HL Death Event
register_event("DeathMsg","death_msg","a");
register_event("DeathMsg""hook_death""a""1>0");

// HL Round Start/Re-Start Event
register_event("TextMsg","Event_RoundRestart","a","2&#Game_w");
register_event("TextMsg","Event_RoundRestart","a","2&#Game_C");

// HL Damage Event
register_event("Damage""on_damage""b""2!0""3=0""4!0");
register_event("Damage","Damage","b"); 


hornet 11-19-2013 05:27

Re: Explain the difference
 
Events are passed with parameters. It's more efficient to specify exactly what you want and allow the engine to filter these for you, rather than hooking the event and then making those checks yourself.

From amxmodx.inc:

PHP Code:

/* Registers event on which a given function will be called
* Flags:
* "a" - global event.
* "b" - specified.
* "c" - send only once when repeated to other players.
* "d" - call if is send to dead player.
* "e" - to alive.
* NOTE: Due to a long-standing bug that would break compatibility with old plugins,
*       the client id should be checked for alive/dead state if you use d or e.
* Examples for conditions:
* "2=c4" - 2nd parameter of message must be sting "c4".
* "3>10" - 3rd parameter must be greater then 10.
* "3!4" - 3rd must be different from 4.
* "2&Buy" - 2nd parameter of message must contain "Buy" substring.
* "2!Buy" - 2nd parameter of message can't contain "Buy" substring. */
native register_event(const event[],const function[],const flags[],const cond[]="", ... ); 


devWaleed 11-19-2013 07:58

Re: Explain the difference
 
So in this:
PHP Code:

register_event("Damage""on_damage""b""2!0""3=0""4!0"

What does "2!0", "3=0", "4!0" mean? Is 2=c4 possible here and how do I use c4 string/paramater?

_____________________________________________ ____________________________________________

EDIT: Let me guess this now.

"2!0", "4!0" in Damage Event mean that

byte DamageSave
byte DamageTake

Should not be 0 or only get value if they are > 0. Am I right or somewhere near it? And 3=0 Defines some damage type?

fysiks 11-19-2013 23:58

Re: Explain the difference
 
Quote:

Originally Posted by devWaleed (Post 2062702)
but they still do the same thing.

This is incorrect, they do NOT do the same thing.

isotonic 11-20-2013 10:42

Re: Explain the difference
 
devWaleed, you are talking about parameters.

2!0 means that 2nd parameter must not be equal to 2,
2&#Game_w means that 2nd parameter must contain #Game_w string
1>0 means that 1st parameter must be greater than 0.

When all conditions for event are met then plugin calls specified function, for example, Event_RoundRestart.
More info about parameters for each event is available here.

For example, Damage event with filter "2!0", "3=0", "4!0":
- damage to player must not be equal to 0
- it is DMG_GENERIC damage type (more info in hlsdk_const.inc)
- origin by X coordinate of damage inflictor must not be equal to 0


All times are GMT -4. The time now is 23:21.

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