Y_Ini - Reading string (i tried..)
#5

There's no need to write such a complex loader for something like this alone. There's a much much more complex unformatting function for that... sscanf 2.0.

This would be very simple:
pawn Код:
sscanf(value, "p<:>ddd", PlayerInfo[playerid][pOnlineHours], PlayerInfo[playerid][pOnlineMinutes], PlayerInfo[playerid][pOnlineSeconds]);
Edit
To save some memory, you could make pOnlineMinutes and pOnlineSeconds char arrays. This reduces the size by half and would be usable since minutes and seconds never go near 255.
pawn Код:
new pOnlineHours[MAX_PLAYERS], pOnlineMinutes[MAX_PLAYERS char], pOnlineSeconds[MAX_PLAYERS char];
// In your 1-second loop...
pOnlineSeconds{playerid} ++;
if(pOnlineSeconds{playerid} == 60)
{
    pOnlineSeconds{playerid} = 0, pOnlineMinutes{playerid} ++;
    if(pOnlineMinutes{playerid} == 60)
    {
        pOnlineMinutes{playerid} = 0, pOnlineHours[playerid] ++;
    }
}
Reply


Messages In This Thread
Y_Ini - Reading string (i tried..) - by Riddick94 - 30.08.2011, 14:46
Re: Y_Ini - Reading string (i tried..) - by [MWR]Blood - 30.08.2011, 14:56
Re: Y_Ini - Reading string (i tried..) - by Jeffry - 30.08.2011, 14:59
Re: Y_Ini - Reading string (i tried..) - by Riddick94 - 30.08.2011, 15:07
Re: Y_Ini - Reading string (i tried..) - by AndreT - 30.08.2011, 15:08

Forum Jump:


Users browsing this thread: 5 Guest(s)