AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Please add a countdown for this restart map code (https://forums.alliedmods.net/showthread.php?t=147271)

GarbageBox 01-07-2011 12:48

Please add a countdown for this restart map code
 
I have try to study the countdown from other people code, but I find that it's not easy...So, I decided to post this code out.
I want a client_print version countdown...
Please help.
Thank
Code:

#include <amxmodx>

public plugin_init()
{       
        register_plugin("Auto-Restart", "1.0", "ToT | V!PER")
        register_event("TextMsg", "restart_time", "a", "2&#Game_C")
        register_cvar("amx_autorestart", "15.0")
        return PLUGIN_CONTINUE
}

public restart_time()       
        set_task (get_cvar_float("amx_autorestart"),"restart_map",0)       

public restart_map()
{       
        set_hudmessage(0, 100, 200, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2)         
        show_hudmessage(0, "Restart Now!")       
        set_cvar_float("sv_restart",1.0)       
        return PLUGIN_HANDLED
}


drekes 01-07-2011 13:57

Re: Please add a countdown for this restart map code
 
change this:
PHP Code:

set_hudmessage(01002000.050.6520.026.00.010.12)      
show_hudmessage(0"Restart Now!"

to
PHP Code:

client_print(0print_chat"Restart Now"); 


GarbageBox 01-08-2011 12:16

Re: Please add a countdown for this restart map code
 
I mean a text countdown
10, 9 , 8 etc

reinert 01-08-2011 12:20

Re: Please add a countdown for this restart map code
 
set_task(1.0, "countdown", _, _, "b")

make an array like counttime, and use counttime--; on countdown :S

GarbageBox 01-09-2011 01:28

Re: Please add a countdown for this restart map code
 
This is what I edit.
But this code won't stop countdown after restart once.
What's wrong?
Code:

#include <amxmodx>

new countdown
new g_SayText
new roundstart

public plugin_init()
{       
        register_plugin("Auto-Restart", "1.0", "ToT | V!PER")
        register_event("TextMsg", "restart_countdown", "a", "2&#Game_C")
        register_cvar("amx_autorestart", "10.0")
        g_SayText = get_user_msgid("SayText")
}

public restart_countdown()
{
        set_task(1.0, "start_countdown", _, _, _, "b")
        set_task(get_cvar_float("amx_autorestart"), "restart_round", _)
}

public start_countdown()
{
        countdown++
        new sec = 11 - countdown
        client_printc(0, "\y[AMXX] After %i sec will restart once", sec)
       
        if(countdown == get_cvar_float("amx_autorestart"))
        {
                countdown = 0
                client_printc(0, "\y[AMXX] Game Start")
        }

        return PLUGIN_HANDLED
}

public restart_round()
{       
        server_cmd("sv_restartround 1")       
        return PLUGIN_HANDLED
}       

stock client_printc(const id, const string[], {Float, Sql, Resul,_}:...) {
       
        new msg[191], players[32], count = 1;
        vformat(msg, sizeof msg - 1, string, 3);
       
        replace_all(msg,190,"\g","^4");
        replace_all(msg,190,"\y","^1");
        replace_all(msg,190,"\t","^3");
       
        if(id)
                players[0] = id;
        else
                get_players(players,count,"ch");
       
        new index;
        for (new i = 0 ; i < count ; i++)
        {
                index = players[i];
                message_begin(MSG_ONE_UNRELIABLE, g_SayText,_, index);
                write_byte(index);
                write_string(msg);
                message_end(); 
        } 
}


drekes 01-09-2011 01:57

Re: Please add a countdown for this restart map code
 
PHP Code:

#define TASKID 452

public restart_countdown()
{
    
set_task(1.0"start_countdown"TASKID);
}

public 
restart_round()
{
    
server_cmd("sv_restartround 1");
    
remove_task(TASKID);



GarbageBox 01-09-2011 02:54

Re: Please add a countdown for this restart map code
 
Quote:

Originally Posted by drekes (Post 1389571)
PHP Code:

#define TASKID 452

public restart_countdown()
{
    
set_task(1.0"start_countdown"TASKID);
}

public 
restart_round()
{
    
server_cmd("sv_restartround 1");
    
remove_task(TASKID);



What does TASKID 452 mean?

I edited the code, but the countdown will only show After 10 sec will restart once.
The countdown text doest show 9, 8, 7...
But after 10 second it still will restart

reinert 01-09-2011 03:18

Re: Please add a countdown for this restart map code
 
you define the task, the number means nothing it can be various ...

Just it needs to match the number on set_task and remove_task to remove the correct one...

GarbageBox 01-09-2011 03:27

Re: Please add a countdown for this restart map code
 
But I when I change
Code:

"set_task(1.0, "start_countdown", _, _, _, "b")"
to
Code:

"set_task(1.0, "start_countdown", TASKID)"
, the countdown doest not show with 9, 8, 7 etc.

reinert 01-09-2011 03:30

Re: Please add a countdown for this restart map code
 
set_task(1.0, "start_countdown", TASKID, _, _, "b")


All times are GMT -4. The time now is 02:08.

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