AlliedModders

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

crnova 05-08-2016 07:29

Question!
 
Why do most people use this:

Code:
#include <amxmodx> new g_iCountDown public plugin_init() {     set_task( 60.0, "task_countdown", _, _, "b") } public task_countdown() {     g_iCountDown = 61         set_task( 1.0, "countdown", _, _, "a", g_iCountDown) } public countdown() {     g_iCountDown--     client_print( 0, print_chat, "%d", g_iCountDown) }

While they can just do this

Code:
#include <amxmodx> new g_iCountDown public plugin_init() {     set_task( 60.0, "task_countdown", _, _, "b") } public task_countdown() {     g_iCountDown = 61         while( g_iCountDown != 0 )     {         g_iCountDown--         client_print( 0, print_chat, "%d", g_iCountDown)     } }

Bugsy 05-08-2016 07:56

Re: Question!
 
Your first code will start the 60-0 countdown after 60 seconds and there will be a 1 second delay between each print.

Your second code will also start the countdown after 60 seconds, except there will not be a 1 second delay between each print--it will be instantaneous.

So it is ok to use either based on what the purpose is.

crnova 05-08-2016 11:14

Re: Question!
 
Oh, thank you!


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

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