AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Timer (https://forums.alliedmods.net/showthread.php?t=136201)

fabrizio guespe 08-23-2010 21:36

Timer
 
I want to execute a

while(){

}

but after a determined time. Like a minute or two.


Is this possible?

Hunter-Digital 08-23-2010 21:53

Re: Timer
 
see set_task() in funcwiki (http://www.amxmodx.org/funcwiki.php)

fabrizio guespe 08-24-2010 00:52

Re: Timer
 
I can't make it work. I want to flash the victim after 4 seconds repitedly.

PHP Code:

public admin_flash(id,level,cid) { 
    if (!
cmd_access(id,level,cid,2)) { 
        return 
PLUGIN_HANDLED 
    

    
    new 
victim[32
    
read_argv(1,victim,31
    new 
player cmd_target(id,victim,0
    if (!
player) return PLUGIN_HANDLED
    
    set_task
(2.0,"Flash",player,"b")



public 
Flash(id) {
    
message_begin(MSG_ONE,gMsgScreenFade,{0,0,0},id
    
write_short1<<15 
    
write_short1<<10 )
    
write_short1<<12 )
    
write_byte255 
    
write_byte255 
    
write_byte255 
    
write_byte255 
    
message_end()
    
emit_sound(id,CHAN_BODY"weapons/flashbang-2.wav"1.0ATTN_NORM0PITCH_HIGH)



Kreation 08-24-2010 01:20

Re: Timer
 
You have the parameters wrong for set_task().

fabrizio guespe 08-24-2010 01:24

Re: Timer
 
I make it work. Also i make the posibiliy of making the user to set the speed and the times to repeat. But i have a problem, it doesn't works with numbers higher than 9. If i put 10, it takes 1 instead of 10


PHP Code:

public admin_flash(id,level,cid) { 
    if (!
cmd_access(id,level,cid,2)) { 
        return 
PLUGIN_HANDLED 
    

    
    new 
n[32], n1[2], n2[2]
    
read_argv(1,n,31)
    
read_argv(2,n1,1
    
read_argv(3,n2,1)
    new 
player cmd_target(id,n,0
    if (!
player) return PLUGIN_HANDLED
    
new ids[2]
    
ids[0] = player
    set_task
(str_to_float(n1), "Flash"0ids1"a",str_to_num(n2))
    return 
PLUGIN_HANDLED


public 
Flash(ids[]) {
    new 
id=ids[0]
    
message_begin(MSG_ONE,gMsgScreenFade,{0,0,0},id
    
write_short1<<15 
    
write_short1<<10 )
    
write_short1<<12 )
    
write_byte255 
    
write_byte255 
    
write_byte255 
    
write_byte255 
    
message_end()
    
emit_sound(id,CHAN_BODY"weapons/flashbang-2.wav"1.0ATTN_NORM0PITCH_HIGH)
    return 
PLUGIN_CONTINUE



Kreation 08-24-2010 01:30

Re: Timer
 
You don't have to return on Flash(), and on cmd_target(), if you're going to just use 0 just don't put it. I'm pretty sure it defaults to 0 if left blank.

fysiks 08-24-2010 18:06

Re: Timer
 
Quote:

Originally Posted by Kreation (Post 1280303)
You don't have to return on Flash(), and on cmd_target(), if you're going to just use 0 just don't put it. I'm pretty sure it defaults to 0 if left blank.

cmd_target flags default to 1 (CMDTARGET_OBEY_IMMUNITY).

Kreation 08-24-2010 21:51

Re: Timer
 
Oh, nevermind that part then.


All times are GMT -4. The time now is 22:00.

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