Raised This Month: $ Target: $400
 0% 

Auto Restartround


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
feren02
Senior Member
Join Date: Mar 2012
Old 02-18-2022 , 20:13   Auto Restartround
Reply With Quote #1

Hello!

I am using this script to restart round in X round. Working good except that after the restart for the specified round, it will never restart again anymore. Any thoughts?

PHP Code:
/*
*
*
*   *    *    *****   *****        *       *****    *    *    *****   *    *   *       *
*   *    *   *             *      * *      *    *   *   **   *        *   **   * *   * *
*   ******   ******   ******     *   *     ******   *  * *   *        *  * *   *  * *  *
*   *    *   *             *    *******    *    *   * *  *   *        * *  *   *   *   *
*   *    *    *****   *****    *       *   *****    *    *    *****   *    *   *       *
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* AMX Mod X script.                                                 *
* Plugin made by He3aBuCuM(a.k.a. independent).                     *
* Important! You can modify the code, but DO NOT modify the author! *
* Contacts with me:                                                 *
* E-mail: [email protected]                                      *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* * * * * * * * * * * * * * * * * * * * * * * *
* Special thanks to:                          *
[email protected]   -  for the idea    *
* * * * * * * * * * * * * * * * * * * * * * * *
*
*
*/

#include <amxmodx>
#define ARIXR_VERSION "0.3"

new cRoundcvar_roundscvar_timecvar_noticecvar_messagecvar_message_colorcvar_hudcvar_hud_colorcvar_soundcvar_restarthudsynccounter
new prefix[] = "OlagueR.GeyminG"

/*START - From colorchat.inc by Numb */
enum Color {
    
NORMAL 1,
    
GREEN,
    
TEAM_COLOR,
    
GREY,
    
RED,
    
BLUE,
}

new 
TeamName[][] = {
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}
/*END - From colorchat.inc by Numb */

public plugin_init() {
    
register_plugin("Auto Restart In X Round"ARIXR_VERSION"He3aBuCuM")
    
register_logevent("roundStart"2"1=Round_Start")
    
cvar_rounds register_cvar("amx_restart_round""33")
    
cvar_time register_cvar("amx_restart_time""10")
    
cvar_notice register_cvar("amx_restart_notice""3")
//    cvar_message = register_cvar("amx_restart_message", "%round% ROUNDS ENDED! Restarting...")
    
cvar_message register_cvar("amx_restart_message""30 ROUNDS ENDED! Restarting...")
    
cvar_message_color register_cvar("amx_restart_message_color""4")
    
cvar_hud register_cvar("amx_restart_hud""%seconds% seconds until restart!")
    
cvar_hud_color register_cvar("amx_restart_hud_color""0 255 0")
    
cvar_sound register_cvar("amx_restart_sound""1")
    
cvar_restart get_cvar_pointer("sv_restart")
    
register_cvar("arixr_version"ARIXR_VERSIONFCVAR_SERVER FCVAR_SPONLY)
    
hudsync CreateHudSyncObj()
}

public 
roundStart() {
    new 
rounds get_pcvar_num(cvar_rounds)
    
cRound++

    if(
cRound == rounds) {
        switch(
get_pcvar_num(cvar_notice)) {
            case 
0set_task(get_pcvar_float(cvar_time), "restartRound"123457)
            case 
1: {
                
set_task(get_pcvar_float(cvar_time), "show_chat_message"123458)
                
set_task(get_pcvar_float(cvar_time), "restartRound"123457)
            }
            case 
2: {
                
set_task(1.0"hudTimer"123456__"a"get_pcvar_num(cvar_time))
                
set_task(get_pcvar_float(cvar_time), "restartRound"123457)
            }
            case 
3: {
                
set_task(1.0"hudTimer"123456__"a"get_pcvar_num(cvar_time))
                
set_task(get_pcvar_float(cvar_time), "restartRound"123457)
                
set_task(get_pcvar_float(cvar_time), "show_chat_message"123458)
            }
            default: 
set_task(get_pcvar_float(cvar_time), "restartRound"123457)
        }

        if(
get_pcvar_num(cvar_sound))
            
set_task(1.0"spkSound"123456__"a"get_pcvar_num(cvar_time))
    }

    return 
PLUGIN_CONTINUE
}

public 
show_chat_message() {
    if(
get_playersnum(1) == 0)
        return 
PLUGIN_HANDLED

    
new message[190], rounds[10]
    
get_pcvar_string(cvar_messagemessagecharsmax(message))
    
format(roundscharsmax(rounds), "%d"cRound)

    
replace_all(messagecharsmax(message), "%round%"rounds)

    switch(
get_pcvar_num(cvar_message_color)) {
        case 
1ColorChat(0GREEN"[%s] %s"prefixmessage)
        case 
2ColorChat(0RED"[%s] %s"prefixmessage)
        case 
3ColorChat(0GREY"[%s] %s"prefixmessage)
        case 
4ColorChat(0BLUE"[%s] %s"prefixmessage)
        case 
5ColorChat(0NORMAL"[%s] %s"prefixmessage)
        case 
6ColorChat(0TEAM_COLOR"[%s] %s"prefixmessage)
        default: 
ColorChat(0NORMAL"[%s] %s"prefixmessage)
    }

    return 
PLUGIN_CONTINUE
}

public 
hudTimer() {
    if(
get_playersnum(1) == 0)
        return 
PLUGIN_HANDLED

    counter
++
    new 
hud[190], rounds[10], seconds[10], redgreenblue
    get_pcvar_string
(cvar_hudhudcharsmax(hud))
    
format(roundscharsmax(rounds), "%d"cRound)
    
format(secondscharsmax(seconds), "%d"get_pcvar_num(cvar_time) - counter)
    
get_hud_color(redgreenblue)

    
replace_all(hudcharsmax(hud), "%round%"rounds)
    
replace_all(hudcharsmax(hud), "%seconds%"seconds)
    
replace_all(hudcharsmax(hud), "/n""^n")

    
set_hudmessage(redgreenblue0.050.6000.011.00.00.0, -1)
    
ShowSyncHudMsg(0hudsynchud)

    return 
PLUGIN_CONTINUE
}

public 
spkSound() {
    if(
get_playersnum(1) == 0)
        return 
PLUGIN_HANDLED

    
new sound[32]
    
num_to_word(get_pcvar_num(cvar_time) - countersoundcharsmax(sound))
    
client_cmd(0"spk ^"vox/%s^""sound)

    return 
PLUGIN_CONTINUE
}

public 
restartRound()
    
set_pcvar_num(cvar_restart2)

get_hud_color(&r, &g, &b) {
    new 
color[20]
    static 
red[5], green[5], blue[5]
    
get_pcvar_string(cvar_hud_colorcolorcharsmax(color))
    
parse(colorredcharsmax(red), greencharsmax(green), bluecharsmax(blue))

    
str_to_num(red)
    
str_to_num(green)
    
str_to_num(blue)
}

/*START - From colorchat.inc by Numb */
ColorChat(idColor:type, const msg[], {FloatSqlResult,_}:...) {
    new 
message[256]

    switch(
type) {
        case 
NORMALmessage[0] = 0x01
        
case GREENmessage[0] = 0x04
        
default: message[0] = 0x03
    
}

    
vformat(message[1], 251msg4)

    
message[192] = '^0'

    
new teamColorChangeindexMSG_Type

    
if(id) {
        
MSG_Type MSG_ONE
        index 
id
    
} else {
        
index FindPlayer()
        
MSG_Type MSG_ALL
    
}

    
team get_user_team(index)
    
ColorChange ColorSelection(indexMSG_Typetype)

    
ShowColorMessage(indexMSG_Typemessage)

    if(
ColorChange)
        
Team_Info(indexMSG_TypeTeamName[team])
}

ShowColorMessage(idtypemessage[]) {
    static 
bool:saytext_used
    
static get_user_msgid_saytext

    
if(!saytext_used) {
        
get_user_msgid_saytext get_user_msgid("SayText")
        
saytext_used true
    
}

    
message_begin(typeget_user_msgid_saytext_id)
    
write_byte(id)
    
write_string(message)
    
message_end()
}

Team_Info(idtypeteam[]) {
    static 
bool:teaminfo_used
    
static get_user_msgid_teaminfo

    
if(!teaminfo_used) {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo")
        
teaminfo_used true
    
}

    
message_begin(typeget_user_msgid_teaminfo_id)
    
write_byte(id)
    
write_string(team)
    
message_end()

    return 
1
}

ColorSelection(indextypeColor:Type) {
    switch(
Type) {
        case 
RED: return Team_Info(indextypeTeamName[1])
        case 
BLUE: return Team_Info(indextypeTeamName[2])
        case 
GREY: return Team_Info(indextypeTeamName[0])
    }

    return 
0
}

FindPlayer() {
    new 
= -1

    
while(<= get_maxplayers()) {
        if(
is_user_connected(++i))
            return 
i
    
}

    return -
1
}
/*END - From colorchat.inc by Numb */ 

Looking forward and thank you!
feren02 is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 02-18-2022 , 22:00   Re: Auto Restartround
Reply With Quote #2

Quote:
Code:
public restartRound()
    set_pcvar_num(cvar_restart, 2)
->>

Quote:
PHP Code:
public restartRound(){
    
cRound 0;
    
set_pcvar_num(cvar_restart2) } 
you never reset the variable that counts the rounds.
so when you actually increment it and it auto restarts the round, it never actually resets the counter... so therefore it just keeps incrementing it thus never being equal to cvar_rounds
__________________

Last edited by deprale; 02-18-2022 at 22:03.
deprale is offline
feren02
Senior Member
Join Date: Mar 2012
Old 02-24-2022 , 22:47   Re: Auto Restartround
Reply With Quote #3

Quote:
Originally Posted by deprale View Post
->>



you never reset the variable that counts the rounds.
so when you actually increment it and it auto restarts the round, it never actually resets the counter... so therefore it just keeps incrementing it thus never being equal to cvar_rounds
Definitely WORKED! Thanks a lot.

However another problem arises. During restart on 31st round after 30 rounds, there is a count down timer with HUD - e.g. 10 seconds before restart, instead of counting backwards like 10, 9, 8, 7, 6, 5, 4 , 3, 2, 1 --- AFTER the restart round counts -1, -2, -3, -4, -5, -6, -7, -8, -9, -10 ---- when server runs long it counts even -100, -101, -102 and so on...

What might be the issue? THANKS!
feren02 is offline
Software15
Junior Member
Join Date: Feb 2022
Old 02-25-2022 , 03:07   Re: Auto Restartround
Reply With Quote #4

Quote:
Originally Posted by feren02 View Post
Definitely WORKED! Thanks a lot.

However another problem arises. During restart on 31st round after 30 rounds, there is a count down timer with HUD - e.g. 10 seconds before restart, instead of counting backwards like 10, 9, 8, 7, 6, 5, 4 , 3, 2, 1 --- AFTER the restart round counts -1, -2, -3, -4, -5, -6, -7, -8, -9, -10 ---- when server runs long it counts even -100, -101, -102 and so on...

What might be the issue? THANKS!
I didn't read the code, but you can fix this bug with setting your counter value, like when your counter
is finished, set it's value.

Example:
public Countdown()
{
timer--
if(timer=0)
{
hud message The countdown has fiinished
timer = 10 // You have to reset your timer
}
}
Software15 is offline
feren02
Senior Member
Join Date: Mar 2012
Old 02-25-2022 , 03:52   Re: Auto Restartround
Reply With Quote #5

Quote:
Originally Posted by Software15 View Post
I didn't read the code, but you can fix this bug with setting your counter value, like when your counter
is finished, set it's value.

Example:
public Countdown()
{
timer--
if(timer=0)
{
hud message The countdown has fiinished
timer = 10 // You have to reset your timer
}
}
Can't really understand what to do hehehe.
feren02 is offline
Software15
Junior Member
Join Date: Feb 2022
Old 02-25-2022 , 07:55   Re: Auto Restartround
Reply With Quote #6

Quote:
Originally Posted by feren02 View Post
Can't really understand what to do hehehe.
Code:
public restartRound(){
   cRound = 0;
   set_pcvar_num(cvar_restart, 2)
   server_cmd("amx_cvar amx_restart_time 10")
  }
Try this.
Software15 is offline
feren02
Senior Member
Join Date: Mar 2012
Old 02-26-2022 , 03:41   Re: Auto Restartround
Reply With Quote #7

Quote:
Originally Posted by Software15 View Post
Code:
public restartRound(){
   cRound = 0;
   set_pcvar_num(cvar_restart, 2)
   server_cmd("amx_cvar amx_restart_time 10")
  }
Try this.
Hi this does not reset the HUD counting. The 10 second countdown works, however the HUD on the screen still continues to count wrongly - it should display on screen 10, 9, 8, 7, 6, 5, 4, 3, 2, 1.
feren02 is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-26-2022 , 13:37   Re: Auto Restartround
Reply With Quote #8

Quote:
Originally Posted by feren02 View Post
Hi this does not reset the HUD counting. The 10 second countdown works, however the HUD on the screen still continues to count wrongly - it should display on screen 10, 9, 8, 7, 6, 5, 4, 3, 2, 1.
Add "remove_task"
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
feren02
Senior Member
Join Date: Mar 2012
Old 02-26-2022 , 19:23   Re: Auto Restartround
Reply With Quote #9

Quote:
Originally Posted by Supremache View Post
Add "remove_task"
noted. but really not know where....looking forward.
feren02 is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 03-03-2022 , 13:55   Re: Auto Restartround
Reply With Quote #10

When the countdown end or when the new round start or when the round end etc..
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
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 16:39.


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