Raised This Month: $ Target: $400
 0% 

Loops


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 02-26-2005 , 12:14  
Reply With Quote #9

Yes, that method will work, and is called Recursion (when a functon calls itself).

Here is a simpler example:

Code:
#include <amxmodx> // variable to keep track of each players loop times new g_iLoops[33] = 0 public plugin_init() {     register_clcmd( "do_slap_loop", "SlapLoop" ) } public SlapLoop( id ) {     g_iLoops[id] = 10     new victimID[2]     victimID[0] = id     set_task( 1.0, "MyLoopFunc", 0, victimID, 1 )     return PLUGIN_HANDLED } public MyLoopFunc( aCmdArgs[] ) {     new victimID = aCmdArgs[0]     // do stuff here...     user_slap( victimID, 5 ) // Slap victim with 5 hp     // Minus 1 from loops     --g_iLoops[victimID]     // Call self again in 1 second..     if( g_iLoops[victimID] > 0 )         set_task( 1.0, "MyLoopFunc", 0, aCmdArgs, 2 )     return }
xeroblood is offline
Send a message via MSN to xeroblood
 



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 14:02.


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