AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   unregister_forward example question (https://forums.alliedmods.net/showthread.php?t=241714)

aron9forever 06-08-2014 04:30

unregister_forward example question
 
Here's the deal, I have a jailbreak daysmenu plugin that uses
PHP Code:

register_forward(FM_PlayerPreThink"fwd_playerprethink"

, but only for two days. At the moment I am using if(checks day) inside it and that's horrible, so I'm asking if I can unregister the forward and only register it while the day starts?

How would that work? Could anyone give an example?

Fill this in for me please
Code:
public plugin_init() { register_forward(FM_PlayerPreThink, "fwd_playerprethink") } public days_start() { switch(day) { case 1: //need it here case 2: //don't need it here } } public days_end() { //??? }

fysiks 06-08-2014 04:45

Re: unregister_forward example question
 
Search for examples. There are a couple threads that use it. You can also look at the documentation for those functions for an idea of how to use them.

After you look at those resources, try some code. If it doesn't work, post your code here.

aron9forever 06-08-2014 04:51

Re: unregister_forward example question
 
Quote:

Originally Posted by fysiks (Post 2148300)
Search for examples. There are a couple threads that use it. You can also look at the documentation for those functions for an idea of how to use them.

After you look at those resources, try some code. If it doesn't work, post your code here.

I've only found documentation in polish, and even there, it's not explained.

by the basic guess from an old amxx glitch thread I guess it's something like this?

Code:
new g_forwardID public plugin_init() { //register_forward(FM_PlayerPreThink, "fwd_playerprethink") } public days_start() { switch(day) { case 1: g_forwardID = register_forward(FM_PlayerPreThink, "fwd_playerprethink")//need it here case 2: //don't need it here } } public days_end() { switch(day) { case 1: unregister_forward(FM_PlayerPreThink, g_forwardID) case 2: //stuff } }

Can you please confirm this as working? I don't have a testing environment set up and I can't test it live at this hour, that's the only reason I ask here, because I can't look at this and tell for sure it will work but others can


All times are GMT -4. The time now is 09:46.

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