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

Solved Block event/forward default procedure


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cmndrfello
Junior Member
Join Date: Jan 2022
Old 01-06-2022 , 01:55   Block event/forward default procedure
Reply With Quote #1

Hello!
I've got another feature that I want to work on which blocks the player from switching teams, in a way that doesn't revert him to his old team, rather not switching him teams in the first place.

I found that in DoD, "PTeam" is an event that is called when the player tries to switch teams.

Is there a way to overwrite / block the default procedure of the event? So that a custom function that is registered on the event will block the team switch from happening?

PHP Code:
register_event("PTeam""dod_onswitchteams""""")

public 
dod_onswitchteams(id)
{
   if(
variable == desired_value)
   {
      
//In theory this will stop the event from proceeding and nothing will happen
      
return EVENT_BLOCKED
   
}
   
//If skipped, the event will continue and user will switch teams
   
return EVENT_CONTINUE

Could something like this be even possible with events? or could this be done with forwards? or with hamsandwich?
Because I've noticed that there are return types such as PLUGIN_HANDLED, PLUGIN_CONTINUE but I can't seem to get them to work. (At least with my past attempts) Though I feel like my problem could be solved with those returns values in someway

Last edited by cmndrfello; 01-06-2022 at 16:01.
cmndrfello is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-06-2022 , 02:00   Re: Block event/forward default procedure
Reply With Quote #2

Its not possible to block events because its already been happened.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
cmndrfello
Junior Member
Join Date: Jan 2022
Old 01-06-2022 , 02:12   Re: Block event/forward default procedure
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Its not possible to block events because its already been happened.
Then, is it possible to block a forward from happening? for example with "dod_client_changeteam"? Will returning PLUGIN_HANDLED stop the team switch?

(I'm just not able to check it right now though curious)
cmndrfello is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-06-2022 , 02:22   Re: Block event/forward default procedure
Reply With Quote #4

if its a global forward i don't see a problem but i am not that familiar with the DoD mod so i won't give tips, give a test and you will know!
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-06-2022 at 03:12.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-06-2022 , 03:10   Re: Block event/forward default procedure
Reply With Quote #5

You can use register_message to hook events as pre and block. Fakemeta/hamsandwich hooks can be blocked when hooked as pre.

However, blocking something does not guarantee things will work as you expect them to. For example, blocking DeathMsg event hooked as a message won't prevent the player from being killed as DeathMsg is merely a notification.
__________________

Last edited by HamletEagle; 01-06-2022 at 03:11.
HamletEagle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-06-2022 , 22:37   Re: Block event/forward default procedure
Reply With Quote #6

I think you'd be better off trying to block the jointeam command sent from the client rather than trying to block some random thing that has "team" in the name since there is a high likelihood that you'll mess with some larger more complex operation.

EDIT:

I just tested registering "jointeam" with register_clcmd() and then returning PLUGIN_HANDLED if I want to block joining teams and PLUGIN_CONTINUE if I don't want to block it. I used a global variable to control which return value was used and toggles that value with a chat command for testing.
__________________

Last edited by fysiks; 01-07-2022 at 00:24.
fysiks 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 17:17.


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