Raised This Month: $ Target: $400
 0% 

Hook for task ID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Youcallmedaddy
Junior Member
Join Date: Dec 2018
Old 12-30-2018 , 08:29   Hook for task ID
Reply With Quote #1

Hello everyone.

I would like to make this task for ID (just remove this hook task) because there is remove_task(id) which removes all the id tasks I have.

Code:
code censored
Thanks a lot, guys.

Last edited by Youcallmedaddy; 01-04-2019 at 08:17. Reason: code censored
Youcallmedaddy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-30-2018 , 11:28   Re: Hook for task ID
Reply With Quote #2

Please indent your code, and use php tags.
__________________

Last edited by Bugsy; 12-30-2018 at 15:06.
Bugsy is offline
Youcallmedaddy
Junior Member
Join Date: Dec 2018
Old 12-30-2018 , 11:51   Re: Hook for task ID
Reply With Quote #3

PHP Code:
code censored 
That is a hook plugin inserted to a mod plugin where I have another tasks, but remove_task(id) removes all of them. I was searching and I found something about adding ID to specific task.
(https://forums.alliedmods.net/showthread.php?t=125638)
I hope it's more clear now.

Last edited by Youcallmedaddy; 01-04-2019 at 08:18. Reason: code censored
Youcallmedaddy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-30-2018 , 15:07   Re: Hook for task ID
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
Please indent your code, and use php tags.
__________________
Bugsy is offline
Youcallmedaddy
Junior Member
Join Date: Dec 2018
Old 12-30-2018 , 15:30   Re: Hook for task ID
Reply With Quote #5

PHP Code:
code censored 

Last edited by Youcallmedaddy; 01-04-2019 at 08:18. Reason: code censored
Youcallmedaddy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-30-2018 , 17:46   Re: Hook for task ID
Reply With Quote #6

You can make unique tasks by doing what is in the thread to which you linked (see post #8).
__________________

Last edited by fysiks; 12-30-2018 at 17:47.
fysiks is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 12-31-2018 , 12:31   Re: Hook for task ID
Reply With Quote #7

Here you are an example of how your code should look like:

Code:
public hook_on(id) {     if(!(get_user_flags(id) & ADMIN_BAN) && !g_CanBuild)         return PLUGIN_HANDLED;     if(get_user_team(id) != 2)         return PLUGIN_HANDLED;     if(g_CanBuild || get_user_flags(id) & ADMIN_BAN && !g_CanBuild)     {         get_user_origin(id, gHookOrigins[ id ], 3);         g_bHook[ id ] = true;         set_task(0.1, "hook_task", id, "", 0, "ab");         hook_task(id);     }     return PLUGIN_HANDLED; }

You need to do this to make all your code more readable.
__________________

Last edited by eat1k; 12-31-2018 at 12:32.
eat1k is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 01-01-2019 , 10:34   Re: Hook for task ID
Reply With Quote #8

1. Don't use stocks as ColorChat, etc... we have client_print_color().
2. Use constants:
Code:
new bool:g_bHook[ 33 ]; new gHookOrigins[ 33 ][ 3 ];
->
Code:
new bool:g_bHook[MAX_PLAYERS+1]; new g_iHookOrigins[MAX_PLAYERS+1][3];
3.
Code:
set_task( 0.1, "hook_task", id, "", 0, "ab" );
Why do you put "a" flag if you don't specify how many times it'll be repeated? Also, consider to use set_task_ex()
So:
Code:
set_task_ex(0.1, "hook_task", id, .flags = SetTask_Repeat);
4.
Code:
if( task_exists(id) )
You don't need to check if the task exists, just remove it.
5. Consider to use get_players_ex() instead of get_players().
6. If you're using that code in other plugin (jb mod for example) so you can remove it just like that:
Code:
remove_task(id+TASK_ID_HOOK);
Otherwise, just: remove_task(id);
Moreover, you need to add:
Code:
enum (+= 100) {     TASK_ID_HOOK };
So when you create task:
Code:
set_task_ex(0.1, "hook_task", id+TASK_ID_HOOK, .flags = SetTask_Repeat);
7. Btw finally, I recommend you to use ReAPI, for what using old modules?
__________________

Last edited by eat1k; 01-01-2019 at 10:37.
eat1k is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-01-2019 , 10:48   Re: Hook for task ID
Reply With Quote #9

Quote:
7. Btw finally, I recommend you to use ReAPI, for what using old modules?
1.Not everyone is using regamedll/rehlds and not everyone wants to switch therefore not everyone can use reapi.
2.The "old" modules are perfectly fine. You don't gain anything by replacing them with reapi. It's fakemeta syndrome all over again. Try to understand how things actually work and then you will see that your claim is silly.
3.You don't gain anything, but you actually lose generality by creating unneeded dependencies. If you code only for yourself, yeah, do whatever you want.
If you plan to release plugins here, then you should use default amxx modules where it's possible, so the code works in both default hlds and RE* stuff.
I can understand using reapi and releasing here if you need to hook non virtual functions for example. But if you are replacing set_pev with whatever reapi's equivalent is or ham hooks with reapi hooks, then that's just dumb beyond belief.
__________________

Last edited by HamletEagle; 01-01-2019 at 10:50.
HamletEagle is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 01-01-2019 , 10:53   Re: Hook for task ID
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
1.Not everyone is using regamedll/rehlds and not everyone wants to switch therefore not everyone can use reapi.
2.The "old" modules are perfectly fine. You don't gain anything by replacing them with reapi. It's fakemeta syndrome all over again. Try to understand how things actually work and then you will see that your claim is silly.
3.You don't gain anything, but you actually loose generality by creating unneeded dependencies. If you code only for yourself, yeah, do whatever you want.
If you plan to release plugins here, then you should use default amxx modules where it's possible, so the code works in both default hlds and RE* stuff.
I can understand using reapi and releasing here if you need to hook non virtual functions for example. But if you are replacing set_pev with whatever reapi's equivalent is or ham hooks with reapi hooks, then that's just dumb beyond belief.
They're old. ReAPI is newer and better for using. I don't understand people who still use HLDS, it's already 2019, lol. But yes, there are people who still use old and official not supported AMXX 1.8.2, so, in my opinion, it's better to write plugins using ReAPI if it's possible. So, if someone wants to use that plugin, he/she will must switch to ReHLDS/ReGameDLL. It's like here you want to use only old things. We don't have to use fakemeta, ham or engine if it can be easily be done with ReAPI.
However, there are few things that cannot be done with ReAPI so in some cases that modules are useful, but in other cases, you can do almost everything with ReAPI. IMHO. That's only my recommendation.
__________________

Last edited by eat1k; 01-01-2019 at 11:00.
eat1k is offline
Reply


Thread Tools
Display Modes

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 07:38.


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