Converting Milliseconds into Minutes and Seconds?
#8

you forgot to format 'string2' before you get the value from the file.
So put
pawn Code:
format(string2, sizeof(string2), "BestRacerTime_0");
before
pawn Code:
time = dini_Int(rFile, string2);

Edit: Oh and you also shouldn't use that dini_function when you format the message.
...and you also don't need to format the string you want to get from the file. In this case you can get rid of string1 and string2

Here is how it should look:

pawn Code:
CMD:racerecorddebug(playerid, params[])
{
    new time;
    new rFile[256];
    new string3[64];
    new string4[64];
    format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", RaceName);  
    time = dini_Int(rFile, "BestRacerTime_0");
    new minutes = time/60000;
    new seconds = (time%60000)/1000;
    new milliseconds = (time%1000);  
    format(string3, sizeof(string3), "Current Race Record held By: %s. ", dini_Get(rFile, "BestRacer_0"));
    format(string4, sizeof(string4), "Their Time: %02d:%02d.%03d", minutes, seconds, milliseconds);
    SendClientMessage(playerid, GREEN, string3);
    SendClientMessage(playerid, GREEN, string4);
    return 1;
}
Edit 2:
Here's an even shorter version:

pawn Code:
CMD:racerecorddebug(playerid, params[])
{
    new rFile[32], string[64];
    format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", RaceName);  
    new time = dini_Int(rFile, "BestRacerTime_0");  
    format(string, sizeof(string), "Current Race Record held By: %s. ", dini_Get(rFile, "BestRacer_0"));
    SendClientMessage(playerid, GREEN, string);
    format(string, sizeof(string), "Their Time: %02d:%02d.%03d", time/60000, (time%60000)/1000, (time%1000));      
    SendClientMessage(playerid, GREEN, string);
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)