Convert seconds into minutes.
#1

Is it possible to convert seconds into minutes? and how would i do this?

This will display seconds:
PHP код:
format(str,sizeof(str),"{FFFFFF}Ban expire: {FF0000}in %d seconds\n\n",iDump-gettime());
              
strcat(string2,str); 
Seconds are selected from SQLlite db.

PHP код:
db_get_field_assoc(qHandle"banlength"szDumpsizeof(szDump));
        
iDump strval(szDump); 
Reply
#2

i thought of giving an idea that might help better than waiting too long for someone to reply, comment will be removed.
Reply
#3

why did you ignore rowdyrider lol he told you exactly what you needed... ex: if iDump-gettime() returns seconds then if you want it to return minutes
PHP код:
format(str,sizeof(str),"{FFFFFF}Ban expire: {FF0000}in %d seconds\n\n",iDump-gettime()/60); 
              
strcat(string2,str); 
see that /60 divide by 60 to return minutes , minute = 60 seconds
But if iDump-gettime() returns MS then you do /60*1000 which is /60000
Reply
#4

PHP код:
stock TimeConvert(seconds)
{
    new 
MS;
    new 
string[128];
    
    
seconds 60 ;
    
seconds 60 ;
    
60 ;
    
    
format(stringsizeof string"%02d:%02d"MS); 
    return 
string;

Example:

PHP код:
new time[32];
format(time32"%s"TimeConvert(200));
SendClientMessage(playerid, -1time); 
Reply
#5

return seconds/60;

Can set the method framework up yourself.

If you're actually asking how to alter the string to contain minutes, then the quickest way would be to identify the number at a specified index (assuming the sentence is always the same length). If not, find the index of the substring "seconds", and work backwards I guess.
Reply
#6

PHP код:
stock convertTime(time, &days, &hours, &minutes, &seconds)
{
    if (
time 0)
        return 
0;

    
hours time 3600;
    
minutes = ((time 60) - (hours 60));
    
seconds time 60;
    if(
hours 23)
    {
        
days hours 24;
        
hours hours 24;
    }
    return 
1;

Reply
#7

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
why did you ignore rowdyrider lol he told you exactly what you needed... ex: if iDump-gettime() returns seconds then if you want it to return minutes
PHP код:
format(str,sizeof(str),"{FFFFFF}Ban expire: {FF0000}in %d seconds\n\n",iDump-gettime()/60); 
              
strcat(string2,str); 
see that /60 divide by 60 to return minutes , minute = 60 seconds
But if iDump-gettime() returns MS then you do /60*1000 which is /60000
I believe he wanted the exact code not how to make it lol, anyways.
Reply
#8

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
PHP код:
stock TimeConvert(seconds)
{
    new 
MS;
    new 
string[128];
    
    
seconds 60 ;
    
seconds 60 ;
    
60 ;
    
    
format(stringsizeof string"%02d:%02d"MS); 
    return 
string;

Example:

PHP код:
new time[32];
format(time32"%s"TimeConvert(200));
SendClientMessage(playerid, -1time); 
Why do you want to format something is already formatted?


PHP код:
)
SendClientMessage(playerid, -1TimeConvert(200)); 
would work perfectly.
Reply
#9

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Why do you want to format something is already formatted?


PHP код:
)
SendClientMessage(playerid, -1TimeConvert(200)); 
would work perfectly.
It's an example; that's how you would do it to use it with other text as well obviously.
Reply
#10

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Why do you want to format something is already formatted?


PHP код:
)
SendClientMessage(playerid, -1TimeConvert(200)); 
would work perfectly.
Could someone explain me the code a little?? i don't really understand.. why 200 seconds? TimeConvert(200)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)