Thread: [DELETED]
View Single Post
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