AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem on my plugin (https://forums.alliedmods.net/showthread.php?t=244464)

Eviatar Mor 07-18-2014 15:38

Problem on my plugin
 
hey i make this code:
http://pastebin.com/GnyeAkN5

i try to do in start round its say 5
4
3
2
1
but its not work....
sorry about my bad english

fysiks 07-18-2014 15:45

Re: Problem on my plugin
 
You need to delay the execution between each one if you want it to be an a 5 second countdown. I would suggest that you search for other plugins or posts that use/talk about making a countdown.

FYI, you can post your code in your post using the [code][/code] or [php][/php] tags if it is short code like yours.

Eagle07 07-18-2014 16:47

Re: Problem on my plugin
 
PHP Code:

#include <amxmodx>
 
#define TIME 5
#define TASKID 1337

new iTime

public plugin_init() {
    
        
register_logevent("logevent_round_start"2"1=Round_Start")
    
}
public 
logevent_round_startclient )
{  
        
iTime TIME
        
        
// every 1 sec will show the countdown & taskid = when the countdown is 0 don't show countdown again
        
set_task1.0"countdown"TASKID__"a"TIME )
    
        
set_hudmessage(17900, -1.0, -1.020.021.00.010.110)
        
show_hudmessageclient"The Infected Will Start In: 5 Seconds"iTime )

}
// countdown (5 - 4 - 3 - 2 ...)
public countdown()
{
    if( 
iTime >= )
    {    
        
// iTime-- : every 1 sec decrease 1 iTime
        
iTime--
        
        
set_hudmessage(17900, -1.0, -1.020.021.00.010.110)
        
show_hudmessage0"The Infected Will Start In: %i Seconds"iTime )
    }



Flick3rR 07-18-2014 17:13

Re: Problem on my plugin
 
I would suggest using flag "b" and that TASKID is useless. You don't need repeat, just put the "b" flag and the task will be executing untill it's removing. So, you will have to remove it if iTime < 1

fysiks 07-18-2014 19:10

Re: Problem on my plugin
 
Quote:

Originally Posted by Flick3rR (Post 2170132)
I would suggest using flag "b" and that TASKID is useless. You don't need repeat, just put the "b" flag and the task will be executing untill it's removing. So, you will have to remove it if iTime < 1

If you already know the number of executions, it is better to use the definite method rather than the indefinite method. It's the same case with the difference between a for loop and a while loop. You don't use a while loop to loop through an array because the size of the array is ALWAYS known prior to run-time (which is the same case above).

Bladell 07-21-2014 10:00

Re: Problem on my plugin
 
Code:

#include <amxmodx>
 
#define NAME "Infection countdown"
#define VERSION "1.0"
#define AUTHOR "Bladell"

#define TIME 5

public plugin_init()
{
        register_plugin(NAME, VERSION, AUTHOR)
       
        register_logevent("logevent_round_start", 2, "1=Round_Start")
}

public logevent_round_start(client)

        set_task(1.0, "countdown", TIME)
}

public countdown(time)
{
        set_hudmessage(179, 0, 0, -1.0, -1.0, 2, 0.02, 1.0, 0.01, 0.1, 10)
       
        if(time)
        {                       
                show_hudmessage(0, "The Infected Will Start In: %d Seconds", time)
               
                set_task(1.0, "countdown", time - 1)
        }
        else
                show_hudmessage(0, "Infection started")
}


Eagle07 07-21-2014 23:13

Re: Problem on my plugin
 
Bladell -_-
stop double post please :P &&& .. why you add
PHP Code:

#define NAME "Infection countdown"
#define VERSION "1.0"
#define AUTHOR "Bladell" 

.. this code by me ... ( pff )

Bladell 07-22-2014 03:23

Re: Problem on my plugin
 
Sorry for double post, I pressed click button twice.
Change that information if you want... but algorithm of countdown function have nothing same with yours. Mine it is more optimized.


All times are GMT -4. The time now is 13:04.

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