AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with set_task and looping (https://forums.alliedmods.net/showthread.php?t=22298)

Willmaker 12-23-2005 10:06

Help with set_task and looping
 
1 Attachment(s)
This little plugin I made works fine, but I have found a bug that I need help with.

Saying !regen_1 starts the regeneration, and then saying !regen_0 stops it, no problems there. But if I were to say !regen_1 again, I would start regenerating at twice the speed. If I say it again, it would regen at 3 times the speed etc etc. I think it has something to do with the set_task being called more than once without the first one stopping. Can someone help me out with this please?

v3x 12-23-2005 15:22

Code:
// plugin_init() register_event("ResetHUD", "Event_ResetHUD", "b"); new regenerate[33]; public Event_ResetHUD( id ) {   if(task_exists(id))     remove_task(id);   regenerate[id] = 0; } public my_func( id ) {   if(!is_user_alive(id))     return PLUGIN_CONTINUE;   if(task_exists(id))     remove_task(id);   switch( regenerate[id] )   {     case 0: set_task(1.5, "regen", id, _, _, "b");     case 1: set_task(1.0, "regen", id, _, _, "b");     case 2: set_task(0.5, "regen", id, _, _, "b");   }   regenerate[id]++;   return PLUGIN_CONTINUE; }
I think that's what you're talking about.

Willmaker 12-23-2005 21:30

After trying out that code, it still doesnt work. If !regen_1 is said more than once, it will regen faster than it should be. Its like remove_task doesnt like me. :( :?

Fire-Wired 12-24-2005 00:02

lol will sounds like snarkserv.

Willmaker 12-24-2005 00:07

Yeah, I know. Although I am trying not to directly copy it, I am getting the idea of rewards from it. Ive found that it has helped me greatly in making plugins.

Besides, theres nothing wrong having a regen plugin is there?

Fire-Wired 12-24-2005 00:24

well the SnarkServ plugin does !regen by checking to see if the task is already running.

Willmaker 12-24-2005 00:34

You have no idea how stupid I feel right now. All the additions and changes I made to the plugin I saved as regen.sma, but I previously had it under a different name, so whenever I made any changes, I was really running a different plugin which was exactly the same everytime.

And yes, the code v3x provided works.

Man, I feel so stupid :oops: :| :oops:

v3x 12-24-2005 14:14

Ah, good.


All times are GMT -4. The time now is 15:52.

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