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

Help Blocking Events - Newbie to SourcePawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
spunkster21
Senior Member
Join Date: Aug 2008
Old 09-29-2009 , 10:55   Help Blocking Events - Newbie to SourcePawn
Reply With Quote #1

Hi,

I’m very new to SourceMod scripting and I’m trying to wrap my head around some basics regarding events.

Using the examples in this tutorial http://wiki.alliedmods.net/Events_%2...d_Scripting%29 I am trying to block the item_pickup event. I’m not trying to do anything fancy, just trying to understand the difference between pre and post hooks.

Here’s my code:

PHP Code:
public OnPluginStart()
 {
              
HookEvent("item_pickup"Event_ItemPickupEventHookMode_Pre);
}
   
public 
Action:Event_ItemPickup (Handle:event, const String:name[], bool:dontBroadcast)
{
              return 
Plugin_Handled;

This doesn’t prevent me from picking up anything in CS:Source, which is what I was expecting. No doubt my lack of understanding is the problem, so I would appreciate some feedback and guidance.

Thanks.
spunkster21 is offline
cmptrwz
Member
Join Date: Dec 2008
Old 09-29-2009 , 12:21   Re: Help Blocking Events - Newbie to SourcePawn
Reply With Quote #2

Blocking the event does not mean blocking the action. In this case, blocking the notifications of the action is most likely all you are doing.

I don't do anything with CS:Source, so I don't know how to go about doing what you want to do though.
cmptrwz is offline
spunkster21
Senior Member
Join Date: Aug 2008
Old 09-29-2009 , 14:34   Re: Help Blocking Events - Newbie to SourcePawn
Reply With Quote #3

Well, that explains why I'm still able to pick things up ;)

I'm not so much trying to block items being picked up as I'm trying to understand what the different hooking modes are used for.

Clearly I've misunderstood the above link. I'll re-read and see if it makes more sense a second time around.
spunkster21 is offline
BrutalGoerge
AlliedModders Donor
Join Date: Jul 2007
Old 09-29-2009 , 14:47   Re: Help Blocking Events - Newbie to SourcePawn
Reply With Quote #4

post= after event fires so you can use its information
pre = before event fires so you can block the message
post_nocopy = after, and doesn't copy any of the event information, so you can use the event to just trigger a function

if no method is specified, i believe it uses post
__________________
My Pluggies If you like, consider to me.
BrutalGoerge is offline
spunkster21
Senior Member
Join Date: Aug 2008
Old 09-29-2009 , 16:34   Re: Help Blocking Events - Newbie to SourcePawn
Reply With Quote #5

Quote:
Originally Posted by BrutalGoerge View Post
post= after event fires so you can use its information
pre = before event fires so you can block the message
post_nocopy = after, and doesn't copy any of the event information, so you can use the event to just trigger a function

if no method is specified, i believe it uses post
Thank you, that's helped make hooking much clearer.
spunkster21 is offline
olj
Veteran Member
Join Date: Jun 2009
Old 10-02-2009 , 08:57   Re: Help Blocking Events - Newbie to SourcePawn
Reply With Quote #6

Quote:
post = after event fires so you can use its information.
I believe in pre hooks the game already knows all key values beforehand. At least i used keyvalues in pre hooks and they were all correct.
__________________
olj is offline
cmptrwz
Member
Join Date: Dec 2008
Old 10-02-2009 , 10:48   Re: Help Blocking Events - Newbie to SourcePawn
Reply With Quote #7

I believe the intent was "You don't care about blocking or changing the event, but want to react to what was finally sent."

Because pre-hooks might change or block the event, and that might change what you want to do after it actually gets sent.
cmptrwz is offline
BrutalGoerge
AlliedModders Donor
Join Date: Jul 2007
Old 10-03-2009 , 00:15   Re: Help Blocking Events - Newbie to SourcePawn
Reply With Quote #8

yeah i didnt mean to insinuate that pre doesn't copy the event kv's
__________________
My Pluggies If you like, consider to me.
BrutalGoerge 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 06:21.


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