IRCCMD !uptime ( need help ) -
JeaSon - 19.04.2014
title say all
! its not working as i want its showing like this
pawn Код:
It's been up since 19/04/2014 at 16:48
but i want ! < server has been online for (house,Min,second)
pawn Код:
enum eDateTimeInfo
{
dayx,
monthx,
yearx,
hoursx,
minutesx,
secondsx
};
new gVeryFirstTimestamp = 0; // This will be a reference.
new gWhenDidItStart[eDateTimeInfo]; // This will be an actual date-time.
public OnGameModeInit( )
{
gVeryFirstTimestamp = gettime();
getdate(gWhenDidItStart[yearx], gWhenDidItStart[monthx], gWhenDidItStart[dayx]);
gettime(gWhenDidItStart[hoursx], gWhenDidItStart[minutesx], gWhenDidItStart[secondsx]);
// You could store these variables in a file and just load it everytime the server start
return 1;
}
IRCCMD:uptime(botid, channel[], user[], host[], params[])
{
if (IRC_IsVoice(botid, channel, user))
{
new stringx[128];
new uptime = gettime() - gVeryFirstTimestamp;
format(stringx, sizeof(stringx), "The server has been up for %i seconds.", uptime);
format(stringx, sizeof(stringx), "It's been up since %02i/%02i/%i at %02i:%02i", gWhenDidItStart[dayx], gWhenDidItStart[monthx], gWhenDidItStart[yearx],gWhenDidItStart[hoursx], gWhenDidItStart[minutesx]);
IRC_GroupSay(groupID, channel, stringx);
}
return 1;
}
Re: IRCCMD !uptime ( need help ) -
xVIP3Rx - 19.04.2014
You're formatting the string correctly, Then you format it again and erase the old one.. Try this
pawn Код:
IRCCMD:uptime(botid, channel[], user[], host[], params[])
{
if (IRC_IsVoice(botid, channel, user))
{
new stringx[128];
new uptime = gettime() - gVeryFirstTimestamp;
format(stringx, sizeof(stringx), "The server has been up for %i seconds.", uptime);
//format(stringx, sizeof(stringx), "It's been up since %02i/%02i/%i at %02i:%02i", gWhenDidItStart[dayx], gWhenDidItStart[monthx], gWhenDidItStart[yearx],gWhenDidItStart[hoursx], gWhenDidItStart[minutesx]);
IRC_GroupSay(groupID, channel, stringx);
}
return 1;
}
Re: IRCCMD !uptime ( need help ) -
JeaSon - 19.04.2014
but it will show only Seconds
but i want like
after 60 seconds i want to show 1min 0sec ! and after 60min i want to show 1hour 0min 0 second
Re: IRCCMD !uptime ( need help ) -
xVIP3Rx - 19.04.2014
Use this stock
pawn Код:
IRCCMD:uptime(botid, channel[], user[], host[], params[])
{
if (IRC_IsVoice(botid, channel, user))
{
new stringx[128];
new hour, min, sec = gettime() - gVeryFirstTimestamp;
format(stringx, sizeof(stringx), "The server has been up for %i seconds.", ConvertTime(sec,min,hour));
//format(stringx, sizeof(stringx), "It's been up since %02i/%02i/%i at %02i:%02i", gWhenDidItStart[dayx], gWhenDidItStart[monthx], gWhenDidItStart[yearx],gWhenDidItStart[hoursx], gWhenDidItStart[minutesx]);
IRC_GroupSay(groupID, channel, stringx);
}
return 1;
}
stock ConvertTime(&cts, &ctm=-1,&cth=-1,&ctd=-1,&ctw=-1,&ctmo=-1,&cty=-1) //Thanks to Kyosaur
{
#define PLUR(%0,%1,%2) (%0),((%0) == 1)?((#%1)):((#%2))
#define CTM_cty 31536000
#define CTM_ctmo 2628000
#define CTM_ctw 604800
#define CTM_ctd 86400
#define CTM_cth 3600
#define CTM_ctm 60
#define CT(%0) %0 = cts / CTM_%0; cts %= CTM_%0
new strii[128];
if(cty != -1 && (cts/CTM_cty))
{
CT(cty); CT(ctmo); CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(cty,"year","years"),PLUR(ctmo,"month","months"),PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctmo != -1 && (cts/CTM_ctmo))
{
cty = 0; CT(ctmo); CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(ctmo,"month","months"),PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctw != -1 && (cts/CTM_ctw))
{
cty = 0; ctmo = 0; CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctd != -1 && (cts/CTM_ctd))
{
cty = 0; ctmo = 0; ctw = 0; CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, and %d %s",PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(cth != -1 && (cts/CTM_cth))
{
cty = 0; ctmo = 0; ctw = 0; ctd = 0; CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, and %d %s",PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctm != -1 && (cts/CTM_ctm))
{
cty = 0; ctmo = 0; ctw = 0; ctd = 0; cth = 0; CT(ctm);
format(strii, sizeof(strii), "%d %s, and %d %s",PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
cty = 0; ctmo = 0; ctw = 0; ctd = 0; cth = 0; ctm = 0;
format(strii, sizeof(strii), "%d %s", PLUR(cts,"second","seconds"));
return strii;
}
Re: IRCCMD !uptime ( need help ) -
JeaSon - 19.04.2014
errors alot
pawn Код:
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20346) : error 017: undefined symbol "ConvertTime"
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20345) : warning 204: symbol is assigned a value that is never used: "secx"
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20344) : warning 203: symbol is never used: "minx"
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20343) : warning 203: symbol is never used: "hourx"
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20354) : error 001: expected token: "-identifier-", but found "new"
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20369) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20373) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20375) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20379) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20381) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20385) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20387) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20391) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20393) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20397) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20399) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20403) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(20407) : error 010: invalid function or declaration
E:\Sami\Build 28 -\gamemodes\WOS.pwn(30143) : warning 203: symbol is never used: "strii"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
Re: IRCCMD !uptime ( need help ) -
xVIP3Rx - 19.04.2014
Erase the stock and make sure it's correctly written.
pawn Код:
stock ConvertTime(&cts, &ctm=-1,&cth=-1,&ctd=-1,&ctw=-1,&ctmo=-1,&cty=-1) //Thanks to Kyosaur
{
#define PLUR(%0,%1,%2) (%0),((%0) == 1)?((#%1)):((#%2))
#define CTM_cty 31536000
#define CTM_ctmo 2628000
#define CTM_ctw 604800
#define CTM_ctd 86400
#define CTM_cth 3600
#define CTM_ctm 60
#define CT(%0) %0 = cts / CTM_%0; cts %= CTM_%0
new strii[128];
if(cty != -1 && (cts/CTM_cty))
{
CT(cty); CT(ctmo); CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(cty,"year","years"),PLUR(ctmo,"month","months"),PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctmo != -1 && (cts/CTM_ctmo))
{
cty = 0; CT(ctmo); CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(ctmo,"month","months"),PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctw != -1 && (cts/CTM_ctw))
{
cty = 0; ctmo = 0; CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctd != -1 && (cts/CTM_ctd))
{
cty = 0; ctmo = 0; ctw = 0; CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, and %d %s",PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(cth != -1 && (cts/CTM_cth))
{
cty = 0; ctmo = 0; ctw = 0; ctd = 0; CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, and %d %s",PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctm != -1 && (cts/CTM_ctm))
{
cty = 0; ctmo = 0; ctw = 0; ctd = 0; cth = 0; CT(ctm);
format(strii, sizeof(strii), "%d %s, and %d %s",PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
cty = 0; ctmo = 0; ctw = 0; ctd = 0; cth = 0; ctm = 0;
format(strii, sizeof(strii), "%d %s", PLUR(cts,"second","seconds"));
return strii;
}