AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Loopin a function? (https://forums.alliedmods.net/showthread.php?t=24721)

NeverDie 03-01-2006 14:54

Loopin a function?
 
I was wonding how you can make a function loop for a few seconds then stop for a few then loop again etc over and over?

Greenberet 03-01-2006 15:12

you mean something like an sleep method?
if yes:
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
if you say e.g. sleep for 5 seconds, then the FULL game will sleep for 5 seconds


Regards
Greenberet

NeverDie 03-01-2006 15:16

1. I fault there was no sleep function in amxx

2. I said i need a loop eg while function not a sleep function

Ramono 03-01-2006 15:22

Code:
#include <amxmodx> #define PLUGIN "looptime" #define VERSION "1.0" #define AUTHOR "NL)Ramon(NL" #define ONSECONDS 5.0   // must be a float #define OFFSECONDS 5.0  // must be a float new on = 0 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(OFFSECONDS,"seton")     set_task(0.1,"code",0,"",0,"b") } public seton(){     set_task(ONSECONDS,"setoff")     on = 1 } public setoff(){     set_task(OFFSECONDS,"seton")     on = 0 } public code() {     if(on == 1)         {         //code here     } }

UNTESTED test it yourself ( i think it should work )
It redoes the code every 0.1 if it is on

wouter 03-01-2006 15:25

i read about it.
0.1 is the minimum :D

Ramono 03-01-2006 15:29

Quote:

Originally Posted by wouter
i read about it.
0.1 is the minimum :D

I think the minimum must be set to 0.01, can be very usefull.

Greenberet 03-01-2006 15:49

Quote:

Originally Posted by NeverDie
1. I fault there was no sleep function in amxx

where's the problem, it is easy to code. So it doesn't realy matter if it exists or not( but it is still bad

Quote:

2. I said i need a loop eg while function not a sleep function
well
Quote:

make a function loop for a few seconds
sounds like an sleep function

MaximusBrood 03-01-2006 16:57

Quote:

Originally Posted by Ramono
Quote:

Originally Posted by wouter
i read about it.
0.1 is the minimum :D

I think the minimum must be set to 0.01, can be very usefull.

Sure, lets do that... and let amxmodx take even more CPU!

---

http://www.amxmodx.org/funcwiki.php?search=set_task


All times are GMT -4. The time now is 20:18.

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