Rules FAQ Members List Search Register Login

 Raised This Month: \$45 Target: \$400 11%

Solved Get remain time problem

 Thread Tools Display Modes
Author Message
loiraolhosazul
Member
Join Date: May 2020
 08-21-2021 , 20:28   Get remain time problem #1 I'm trying to get the rest of the hour, but I'm in trouble. HTML Code: ```Now: 20 horas 26 minutos 50 segundos Remain: 0 hora -60 minuto 0 segundo``` Code: ```public xdxd() { new h, m, s, i, mm, d, now, start, discount, remain_time, gethours[3], xfmt[128] time(gethours[0], gethours[1], gethours[2]) start = 22 discount = floatround(float(start - gethours[0]), floatround_ceil) now = get_systime() remain_time = get_systime(3600 * discount) - now UnixToTime(now, i, mm, d, h, m, s, UT_TIMEZONE_SERVER) formatex(xfmt, charsmax(xfmt), "Now: %d hora%s %d minuto%s %d segundo%s", h, h > 1 ? "s" : "", m, m > 1 ? "s" : "", s, s > 1 ? "s" : "") server_print(xfmt) UnixToTime(remain_time, i, mm, d, h, m, s, UT_TIMEZONE_SERVER) formatex(xfmt, charsmax(xfmt), "Remain: %d hora%s %d minuto%s %d segundo%s", h, h > 1 ? "s" : "", m, m > 1 ? "s" : "", s, s > 1 ? "s" : "") server_print(xfmt) }``` Last edited by loiraolhosazul; 08-21-2021 at 21:38.
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 08-21-2021 , 20:58   Re: Get remain time problem #2 Give an example of input and output. Based on your request, you only want the number of minutes remaining in the current hour? __________________
loiraolhosazul
Member
Join Date: May 2020
08-21-2021 , 21:00   Re: Get remain time problem
#3

Quote:
 Originally Posted by Bugsy Give an example of input and output. Based on your request, you only want the number of minutes remaining in the current hour?
I have an event, it starts at 22
I want to get the remaining time until the time of the event
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 08-21-2021 , 21:01   Re: Get remain time problem #4 Is this 22 event stored via unix timestamp? What is the initial value/format I am working with to get remaining time? __________________
loiraolhosazul
Member
Join Date: May 2020
08-21-2021 , 21:02   Re: Get remain time problem
#5

Quote:
 Originally Posted by Bugsy Is this 22 event stored via unix timestamp? What is the initial value/format I am working with to get remaining time?
the value is integer 22 by cvar, but i need to convert everything to unix for me to print 'correctly'
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 08-21-2021 , 21:03   Re: Get remain time problem #6 So the 22 corresponds to the 22nd hour of the current day? __________________
loiraolhosazul
Member
Join Date: May 2020
08-21-2021 , 21:04   Re: Get remain time problem
#7

Quote:
 Originally Posted by Bugsy So the 22 corresponds to the 22nd hour of the current day?
yes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 08-21-2021 , 21:31   Re: Get remain time problem #8 Try this __________________ Last edited by Bugsy; 08-22-2021 at 13:38.
loiraolhosazul
Member
Join Date: May 2020
08-21-2021 , 21:38   Re: Get remain time problem
#9

Quote:
 Originally Posted by Bugsy Try this: PHP Code: ``` public Test()  {     new iActionHour = 22;          new iYear , iMonth , iDay , iHour , iMinute , iSecond;     new iHours , iMinutes , iSeconds;     UnixToTime( get_systime() , iYear , iMonth , iDay , iHour , iMinute , iSecond , UT_TIMEZONE_SERVER );          if ( iHour < iActionHour )     {         iHours = ( iActionHour - iHour ) - 1;      }     else     {         iHours = ( iActionHour + ( 24 - iActionHour ) ) - 1;     }          iMinutes = 60 - iMinute;     iSeconds = 60 - iSecond;          server_print( "%d hour%s, %d minute%s, %d second%s" , iHours , iHours == 1 ? "" : "s" , iMinutes , iMinutes == 1 ? "" : "s", iSeconds , iSeconds == 1 ? "" : "s" ); }  ```
worked, thank you! close
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 08-22-2021 , 01:23   Re: Get remain time problem #10 This needs more work, it will not always be accurate. __________________ Last edited by Bugsy; 08-22-2021 at 02:22.

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TFDodgeball         TF2Items         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

All times are GMT -4. The time now is 23:29.

 DMCA - Archive - Top

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