Raised This Month: $32 Target: $400
 8% 

Server Auto Restart Help!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
feren02
Senior Member
Join Date: Mar 2012
Old 04-17-2021 , 23:42   Server Auto Restart Help!
Reply With Quote #1

Good day!

Hope you are coping in this difficult times.

Look at my .sma, it is working... However, it restarts the game with ZERO players, which is the default function.

***THE NEEDED HELP - NEED THE PLUGIN TO RESTART EVEN WITH SPECTATORS, e.g. 3 spectators in-game, THE PLUGIN WILL PUSH TO RESTART.***

Here is the .sma I am using:

PHP Code:
/* Sublime AMXX Editor v2.2 */

#pragma semicolon 1

#include <amxmodx>

#define PLUGIN  "Show Players"
#define VERSION "1.0"
#define AUTHOR  "NapoleoN#"

#define MSGID 81045

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32;
#endif

enum _:ePlayerInfo
{
    
iTotalPlayers,
    
iCtPlayers,
    
iCtAlive,
    
iTerPlayers,
    
iTerAlive
};

new 
iInfo[ePlayerInfo];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
}

public 
client_putinserver(id)
{
    
iInfo[iTotalPlayers]++;

    if(!
task_exists(MSGID))
    {
        
set_task(10.0"displayMessage"MSGID);
    }
}


#if AMXX_VERSION_NUM < 183
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    
iInfo[iTotalPlayers]--;

    if(
iInfo[iTotalPlayers] == 0)
    {
        
remove_task(MSGID);
        
server_cmd("sv_restart 1");
    }
}

public 
displayMessage()
{
    if(
task_exists(MSGID))
    {
        new 
iPlayers[MAX_PLAYERS], iNum;

        
get_players(iPlayersiNum"e""TERRORIST");
        
iInfo[iTerPlayers] = iNum;

        
get_players(iPlayersiNum"ae""TERRORIST");
        
iInfo[iTerAlive] = iNum;

        
get_players(iPlayersiNum"e""CT");
        
iInfo[iCtPlayers] = iNum;

        
get_players(iPlayersiNum"ae""CT");
        
iInfo[iCtAlive] = iNum;

        
get_players(iPlayersiNum);

        for(new 
iiNumi++)
        {
            
set_hudmessage(random(255), random(255), random(255), -1.00.000.01.10.10.2, -1);
            
show_hudmessage(iPlayers[i], "Terrorists: %i/%i | Counter-Terrorists: %i/%i",
                              
iInfo[iTerAlive], iInfo[iTerPlayers],
                              
iInfo[iCtAlive], iInfo[iCtPlayers]);
        }
        
set_task(1.0"displayMessage"MSGID);
    }

Looking forward!
feren02 is offline
linly
BANNED
Join Date: Apr 2021
Old 04-22-2021 , 05:21   Re: Server Auto Restart Help!
Reply With Quote #2

There are still many things to do and enjoy in life, don't waste time being sad cookie clicker 3
linly is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 04-22-2021 , 06:03   Re: Server Auto Restart Help!
Reply With Quote #3

try this:
Code:
#include <amxmodx>
#include <cstrike>

#define PLUGIN  "Show Players"
#define VERSION "1.0"
#define AUTHOR  "NapoleoN#"

#define MSGID 81045

#if !defined MAX_PLAYERS
    const MAX_PLAYERS = 32;
#endif

enum _:ePlayerInfo
{
    iTotalPlayers,
    iCtPlayers,
    iCtAlive,
    iTerPlayers,
    iTerAlive
};

new iInfo[ePlayerInfo];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
}

public client_putinserver(id)
{
    iInfo[iTotalPlayers]++;

    if(!task_exists(MSGID))
    {
        set_task(10.0, "displayMessage", MSGID);
    }
}


#if AMXX_VERSION_NUM < 183
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    if( cs_get_user_team( id ) == CS_TEAM_CT )
        iInfo[ iCtPlayers ]--
    else if( cs_get_user_team( id ) == CS_TEAM_T )
        iInfo[ iTerPlayers ]--

    if(iInfo[ iCtPlayers ] + iInfo[ iTerPlayers ] == 0 )
    {
        remove_task(MSGID);
        server_cmd("sv_restart 1");
    }
}

public displayMessage()
{
    if(task_exists(MSGID))
    {
        new iPlayers[MAX_PLAYERS], iNum;

        get_players(iPlayers, iNum, "e", "TERRORIST");
        iInfo[iTerPlayers] = iNum;

        get_players(iPlayers, iNum, "ae", "TERRORIST");
        iInfo[iTerAlive] = iNum;

        get_players(iPlayers, iNum, "e", "CT");
        iInfo[iCtPlayers] = iNum;

        get_players(iPlayers, iNum, "ae", "CT");
        iInfo[iCtAlive] = iNum;

        get_players(iPlayers, iNum);

        for(new i; i < iNum; i++)
        {
            set_hudmessage(random(255), random(255), random(255), -1.0, 0.0, 0, 0.0, 1.1, 0.1, 0.2, -1);
            show_hudmessage(iPlayers[i], "Terrorists: %i/%i | Counter-Terrorists: %i/%i",
                              iInfo[iTerAlive], iInfo[iTerPlayers],
                              iInfo[iCtAlive], iInfo[iCtPlayers]);
        }
        set_task(1.0, "displayMessage", MSGID);
    }
}
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
feren02
Senior Member
Join Date: Mar 2012
Old 04-26-2021 , 21:52   Re: Server Auto Restart Help!
Reply With Quote #4

Hi not working, having errors on line 51 and 54 on if and else..

How to resolve?

Looking forward.
feren02 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-26-2021 , 23:35   Re: Server Auto Restart Help!
Reply With Quote #5

It some compiles just fine for me. You should always post the exact errors that you're getting so we can know what you are actually talking about just in case there is confusion.
__________________

Last edited by fysiks; 04-26-2021 at 23:37.
fysiks is offline
feren02
Senior Member
Join Date: Mar 2012
Old 04-29-2021 , 06:14   Re: Server Auto Restart Help!
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
It some compiles just fine for me. You should always post the exact errors that you're getting so we can know what you are actually talking about just in case there is confusion.
Hi my bad, I put Pragma Semicolon, removed and worked perfectly.
feren02 is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 04-30-2021 , 12:27   Re: Server Auto Restart Help!
Reply With Quote #7

You are welcome!
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
feren02
Senior Member
Join Date: Mar 2012
Old 04-30-2021 , 23:21   Re: Server Auto Restart Help!
Reply With Quote #8

Quote:
Originally Posted by JocAnis View Post
You are welcome!
Thank you for your time.
feren02 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 09:55.


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