Raised This Month: $ Target: $400
 0% 

Help with set_task and looping


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 12-23-2005 , 10:06   Help with set_task and looping
Reply With Quote #1

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?
Attached Files
File Type: sma Get Plugin or Get Source (regen.sma - 730 views - 1.6 KB)
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 12-23-2005 , 15:22  
Reply With Quote #2

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.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 12-23-2005 , 21:30  
Reply With Quote #3

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.
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
Fire-Wired
Member
Join Date: May 2005
Location: Maryland
Old 12-24-2005 , 00:02  
Reply With Quote #4

lol will sounds like snarkserv.
Fire-Wired is offline
Send a message via AIM to Fire-Wired Send a message via MSN to Fire-Wired Send a message via Yahoo to Fire-Wired
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 12-24-2005 , 00:07  
Reply With Quote #5

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?
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
Fire-Wired
Member
Join Date: May 2005
Location: Maryland
Old 12-24-2005 , 00:24  
Reply With Quote #6

well the SnarkServ plugin does !regen by checking to see if the task is already running.
Fire-Wired is offline
Send a message via AIM to Fire-Wired Send a message via MSN to Fire-Wired Send a message via Yahoo to Fire-Wired
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 12-24-2005 , 00:34  
Reply With Quote #7

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
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 12-24-2005 , 14:14  
Reply With Quote #8

Ah, good.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x 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 15:52.


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