Raised This Month: $ Target: $400
 0% 

Explain the difference


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 11-19-2013 , 03:03   Explain the difference
Reply With Quote #1

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"); 

Last edited by devWaleed; 11-19-2013 at 05:17.
devWaleed is offline
Send a message via Skype™ to devWaleed
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 11-19-2013 , 05:27   Re: Explain the difference
Reply With Quote #2

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[]="", ... ); 
hornet is offline
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 11-19-2013 , 07:58   Re: Explain the difference
Reply With Quote #3

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?

Last edited by devWaleed; 11-19-2013 at 08:02. Reason: Added my guess
devWaleed is offline
Send a message via Skype™ to devWaleed
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-19-2013 , 23:58   Re: Explain the difference
Reply With Quote #4

Quote:
Originally Posted by devWaleed View Post
but they still do the same thing.
This is incorrect, they do NOT do the same thing.
__________________
fysiks is online now
isotonic
AlliedModders Donor
Join Date: Jun 2011
Location: Moscow, Russia
Old 11-20-2013 , 10:42   Re: Explain the difference
Reply With Quote #5

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
__________________

Last edited by isotonic; 11-20-2013 at 10:43.
isotonic 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:21.


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