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

[DELETED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadowless
Member
Join Date: May 2018
Old 02-25-2019 , 14:23   [DELETED]
Reply With Quote #1

--

Last edited by Shadowless; 05-19-2019 at 05:46.
Shadowless is offline
Send a message via ICQ to Shadowless
PartialCloning
Senior Member
Join Date: Dec 2015
Old 02-25-2019 , 14:46   Re: Server say /uptime
Reply With Quote #2

PHP Code:
#include <amxmodx>
#pragma semicolon 1

new g_MaxClients;

public 
plugin_init()
{
    
register_concmd("say /uptime""Command_Time");
    
g_MaxClients get_maxplayers();
}

public 
Command_Time(client)
{
    new 
Float:theTime get_gametime();
    new 
days          floatround(theTime 86400floatround_tozero);
    new 
hours         floatround( (theTime-days) / 3600floatround_tozero);
    new 
minutes       floatround( (theTime-days-hours)/60floatround_tozero);
    new 
seconds       floatround(theTime days hours minutesfloatround_tozero);
    new 
milli         floatround( (theTime days hours minutes seconds) * 1000floatround_tozero);

    if(
client && client <= g_MaxClients && is_user_connected(client))
    {
        
client_print(clientprint_chat"Uptime: %d days %d hours %d minutes %d seconds and %d milliseconds"dayshoursminutessecondsmilli);
    }
    else if(
client == 0)
    {
        
server_print("Uptime: %d days %d hours %d minutes %d seconds and %d milliseconds"dayshoursminutessecondsmilli);
    }

    return 
PLUGIN_HANDLED;


Last edited by PartialCloning; 02-25-2019 at 14:48.
PartialCloning is offline
Old 02-25-2019, 14:57
Shadowless
This message has been deleted by Shadowless.
PartialCloning
Senior Member
Join Date: Dec 2015
Old 02-25-2019 , 15:05   Re: Server say /uptime
Reply With Quote #3

That was a port of the code you asked for.

You can try https://forums.alliedmods.net/showpo...42&postcount=6

Last edited by PartialCloning; 02-25-2019 at 15:06.
PartialCloning is offline
Old 02-25-2019, 15:57
Shadowless
This message has been deleted by Shadowless.
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 02-25-2019 , 22:03   Re: Server say /uptime
Reply With Quote #4

Quote:
Originally Posted by Shadowless View Post
that shows msg --> * [AMXX] Total server uptime: 13.542778

What's wrong with that? In what format do you want it?
Moody92 is offline
Old 02-27-2019, 08:42
Shadowless
This message has been deleted by Shadowless.
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 02-28-2019 , 04:21   Re: Server say /uptime
Reply With Quote #5

Quote:
Originally Posted by Shadowless View Post
client_print(client, print_chat, "Uptime: %d days %d hours %d minutes %d seconds and %d milliseconds", days, hours, minutes, seconds, milli);


more better format
I really suck at math, but here's a modified version of Ywa's plugin with the help of geeksforgeeks. There's no milliseconds though.

You can modify your uptime by using
Code:
amx_uptime
PHP Code:
/* Plugin generated by AMXX-Studio 

ServerUptime
------------
A simple plugin on a request.
Returns server uptime
*/

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "ServerUptime"
#define VERSION "1.0"
#define AUTHOR "Ywa"

new iDays;
new 
iHours;
new 
iMinutes;
new 
iSeconds;
new 
lasttime;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_concmd("say /uptime""get");

    
register_cvar("amx_uptime""0")

    
lasttime get_cvar_num("amx_uptime");
}

public 
get(id) {
    new 
totalup lasttime floatround(halflife_time(),floatround_ceil);

    
//Credits: https://www.geeksforgeeks.org/converting-seconds-into-days-hours-minutes-and-seconds/
    
iDaystotalup/(24*3600);
    
totalup =totalup % (24*3600);
    
iHours=totalup/3600;
    
totalup %=3600;

    
iMinutes=totalup/60;

    
totalup %= 60;
    
iSeconds totalup;


    
client_print(idprint_chat"* [AMXX] Total server uptime:%d Days, %d Hours, %d Minutes, %d Seconds"iDaysiHoursiMinutesiSeconds);
}


public 
plugin_end() {
    new 
totalup lasttime;
    new 
mapup floatround(halflife_time(),floatround_ceil);
    new 
up totalup mapup;
    
set_cvar_num("amx_uptime"up);


EDIT: You have to realize that what this plugin does is update amx_uptime at the end of the map until server crash/shutdown. If you change amx_uptime manually, it'll pickup from the time you changed it to.

EDIT 2: Admins can no longer change up time using the cvar.

Last edited by Moody92; 03-05-2019 at 18:31.
Moody92 is offline
Old 03-05-2019, 13:55
Shadowless
This message has been deleted by Shadowless.
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 03-05-2019 , 18:33   Re: Server say /uptime
Reply With Quote #6

Quote:
Originally Posted by Shadowless View Post
TNX... works great <3
You're welcome, I just made a slight edit. It can be problematic if admins play with 'amx_uptime' cvar if you want the uptime to always be real-time. So I made it that admins can no longer modify uptime using the cvar.
Moody92 is offline
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 03-15-2019 , 03:28   Re: Server say /uptime
Reply With Quote #7

Upon a request from lantimilan, I have modified the plugin to not show when chat commands are executed.

Quote:
Chat commands:
say /uptime
say .uptime
say_team /uptime
say_team .uptime
PHP Code:
/* Plugin generated by AMXX-Studio 

ServerUptime
------------
A simple plugin on a request.
Returns server uptime
*/

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "ServerUptime"
#define VERSION "1.0"
#define AUTHOR "Ywa & FL00D"

new iDays;
new 
iHours;
new 
iMinutes;
new 
iSeconds;
new 
lasttime;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_cmd("uptime""get"0);
    
register_clcmd("say""cmdSay");
    
register_clcmd("say_team""cmdSay");

    
register_cvar("amx_uptime""0");

    
lasttime get_cvar_num("amx_uptime");
}

public 
get(id) {
    new 
totalup lasttime floatround(halflife_time(),floatround_ceil);

    
//Credits: https://www.geeksforgeeks.org/converting-seconds-into-days-hours-minutes-and-seconds/
    
iDaystotalup/(24*3600);
    
totalup =totalup % (24*3600);
    
iHours=totalup/3600;
    
totalup %=3600;

    
iMinutes=totalup/60;

    
totalup %= 60;
    
iSeconds totalup;


    
client_print(idprint_chat"* [AMXX] Total server uptime:%d Days, %d Hours, %d Minutes, %d Seconds"iDaysiHoursiMinutesiSeconds);
}

//Credits to Effx
public cmdSay(id)
{
    new 
szWords[20];
    
read_argv(1szWordscharsmax(szWords));
    
remove_quotes (szWords);

    if(
equal(szWords"/uptime")  || equal(szWords".uptime"))
    {
         return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}
//Credits to nucLeaR & p4ddY
stock register_cmd(const saycommand[], const function[], flags
{
    new 
temp[64]
    
formatex(temp63"say /%s"saycommand)
    
register_clcmd(temp, function, flags)
    
formatex(temp63"say .%s"saycommand)
    
register_clcmd(temp, function, flags)
    
formatex(temp63"say_team /%s"saycommand)
    
register_clcmd(temp, function, flags)
    
formatex(temp63"say_team .%s"saycommand)
    
register_clcmd(temp, function, flags)
}

public 
plugin_end() {
    new 
totalup lasttime;
    new 
mapup floatround(halflife_time(),floatround_ceil);
    new 
up totalup mapup;
    
set_cvar_num("amx_uptime"up);



Last edited by Moody92; 03-15-2019 at 04:46.
Moody92 is offline
lantimilan
Senior Member
Join Date: May 2016
Old 03-15-2019 , 03:35   Re: Server say /uptime
Reply With Quote #8

Quote:
Originally Posted by Moody92 View Post
Upon a request from lantimilan, I have modified the plugin to not show when chat commands are executed.



PHP Code:
/* Plugin generated by AMXX-Studio 

ServerUptime
------------
A simple plugin on a request.
Returns server uptime
*/

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "ServerUptime"
#define VERSION "1.0"
#define AUTHOR "Ywa & FL00D"

new iDays;
new 
iHours;
new 
iMinutes;
new 
iSeconds;
new 
lasttime;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_cmd("uptime""get"0);
    
register_clcmd("say""cmdSay");
    
register_clcmd("say_team""cmdSayTeam");

    
register_cvar("amx_uptime""0");

    
lasttime get_cvar_num("amx_uptime");
}

public 
get(id) {
    new 
totalup lasttime floatround(halflife_time(),floatround_ceil);

    
//Credits: https://www.geeksforgeeks.org/converting-seconds-into-days-hours-minutes-and-seconds/
    
iDaystotalup/(24*3600);
    
totalup =totalup % (24*3600);
    
iHours=totalup/3600;
    
totalup %=3600;

    
iMinutes=totalup/60;

    
totalup %= 60;
    
iSeconds totalup;


    
client_print(idprint_chat"* [AMXX] Total server uptime:%d Days, %d Hours, %d Minutes, %d Seconds"iDaysiHoursiMinutesiSeconds);
}

//Credits to Effx
public cmdSay(id)
{
    new 
szWords[20];
    
read_argv(1szWordscharsmax(szWords));
    
remove_quotes (szWords);

    if(
equal(szWords"/uptime")  || equal(szWords".thetime"))
    {
         return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
cmdSayTeam(id)
{
    new 
szWords[20];
    
read_argv(1szWordscharsmax(szWords));
    
remove_quotes (szWords);

    if(
equal(szWords"/uptime")  || equal(szWords".thetime"))
    {
         return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}


//Credits to nucLeaR & p4ddY
stock register_cmd(const saycommand[], const function[], flags
{
    new 
temp[64]
    
formatex(temp63"say /%s"saycommand)
    
register_clcmd(temp, function, flags)
    
formatex(temp63"say .%s"saycommand)
    
register_clcmd(temp, function, flags)
    
formatex(temp63"say_team /%s"saycommand)
    
register_clcmd(temp, function, flags)
    
formatex(temp63"say_team .%s"saycommand)
    
register_clcmd(temp, function, flags)
}

public 
plugin_end() {
    new 
totalup lasttime;
    new 
mapup floatround(halflife_time(),floatround_ceil);
    new 
up totalup mapup;
    
set_cvar_num("amx_uptime"up);



Moody thank you very much, its very good
lantimilan is offline
Send a message via MSN to lantimilan
Reply


Thread Tools
Display Modes

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 19:58.


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