Raised This Month: $ Target: $400
 0% 

Timer question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 10-20-2008 , 11:23   Timer question
Reply With Quote #1

For amxx:
PHP Code:
new array[2];
array[
0] = target;
array[
1] = 3;

set_task(5.0,"func",0,array,2,"b");
// or

set_task(3.0,"smth",player); 
How can i make this in source ? or to exec a task on a player ?...
__________________


Last edited by anakin_cstrike; 10-20-2008 at 11:36.
anakin_cstrike is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 10-20-2008 , 13:54   Re: Timer question
Reply With Quote #2

ex 1:
Code:
public func() {     new target;         new Handle:data = CreateDataPack();     WritePackCell(data,target);     WritePackCell(data,3);         CreateTimer(5.0,fn_callTimerFunc,data,TIMER_REPEAT); } public Action:fn_callTimerFunc(Handle:timer,any:data) {     ResetPack(Handle:data);         new target = ReadPackCell(Handle:data);     new anotherThing = ReadPackCell(Handle:data); // that number "3"         PrintToChatAll("target : %d | another thing : %d",target,anotherThing); }

ex 2:
Code:
public my_func(id) {     CreateTimer(3.0,fn_TimerFuncSomething,id); } public Action:fn_TimerFuncSomething(Handle:timer,any:id) {     // do something with 'id' }
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 10-20-2008 , 14:28   Re: Timer question
Reply With Quote #3

Thank you...i forgot...if I want to create a timer that repeats a function only 5 timer how i would that ?
__________________

anakin_cstrike is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 10-20-2008 , 14:34   Re: Timer question
Reply With Quote #4

Code:
new g_count = 0; public func() {     g_count = 0;     CreateTimer(3.0,fn_callTimer,_,TIMER_REPEAT) } public Action:fn_callTimer(Handle:timer) {     if(g_count >= 5)     {         g_count = 0;         return Plugin_Stop;     }             // do something         g_count++;         return Plugin_Continue; }

Last edited by SAMURAI16; 10-20-2008 at 14:36.
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 10-20-2008 , 14:36   Re: Timer question
Reply With Quote #5

Thanks...another question i have to index the variable if i'm using on a player ?
Also....is correct this fuction ? StringToFloat ?
__________________

anakin_cstrike is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 10-20-2008 , 14:36   Re: Timer question
Reply With Quote #6

pass it trough 3rd param of CreateTimer() native
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
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 11:33.


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