How to change it to minutes & seconds?
#1

I wanted to change this time:
pawn Code:
format(string, sizeof(string), ""COL_LYELL"Musisz poczekać jeszcze: "COL_RED"%d, "COL_LIMON"aby zmienić status.", (GetPVarInt(playerid, "LastZW") - GetTickCount()) / 1000 + MINUTES(10));
to something like that:
pawn Code:
format(string, sizeof(string), ""COL_LYELL"Musisz poczekać jeszcze: "COL_RED"%dminutes %d seconds, "COL_LIMON"aby zmienić status.", minutes?, seconds?);
Please?
Reply
#2

Try now

pawn Code:
new Hour, Minute, Second;
gettime(Hour, Minute, Second);

format(string, sizeof(string), ""COL_LYELL"Musisz poczekać jeszcze: "COL_RED"%dHours%dminutes %d seconds, "COL_LIMON"aby zmienić status.",Hour, Minute, Second);
Reply
#3

Quote:
Originally Posted by leonardo1434
View Post
Try now

pawn Code:
new Hour, Minute, Second;
gettime(Hour, Minute, Second);

format(string, sizeof(string), ""COL_LYELL"Musisz poczekać jeszcze: "COL_RED"%dHours%dminutes %d seconds, "COL_LIMON"aby zmienić status.",Hour, Minute, Second);


This should work:
Code:
new minutes, seconds = (GetPVarInt(playerid, "LastZW") - GetTickCount()) / 1000 + MINUTES(10);
while (seconds >= 60)
{
	minutes++;
	seconds -= 60;
}
format(string, sizeof(string), ""COL_LYELL"Musisz poczekac jeszcze: "COL_RED"%d minutes %d seconds, "COL_LIMON"aby zmienic status.", minutes, seconds);
Reply
#4

You can replace this

pawn Code:
while (seconds >= 60)
{
    minutes++;
    seconds -= 60;
}
with

pawn Code:
minutes = seconds/60;
seconds %= 60;
Reply
#5

Damn, where i made a mistake? Because it shows me it's 9999min and 59sec left. I wanted 10minutes.. xd
pawn Code:
if(GetPVarInt(playerid, "LastZW") != 0 && (GetTickCount() - GetPVarInt(playerid, "LastZW")) < MINUTES(10))
    {
        new string[128], minutes, seconds = (GetPVarInt(playerid, "LastZW") - GetTickCount()) / 1000 + MINUTES(10);
        minutes = seconds / 60;
        seconds %= 60;
        format(string, sizeof(string), ""COL_LYELL"Musisz poczekać jeszcze: "COL_RED"%dmin %dsek, "COL_LIMON"aby zmienić status.", minutes, seconds);
        return ShowInfo(playerid, "Błąd - status", string);
    }
edit://
By the way, some time ago i have used that:
pawn Code:
minuty = PlayerInfo[playerid][pJailTime] / 60;
sekundy = PlayerInfo[playerid][pJailTime] % 60;
As i've noticed it's preety similar to yours Mademan.
Reply
#6

I think it should be

pawn Code:
(GetTickCount() - GetPVarInt(playerid, "LastZW"))
Reply
#7

To the 'seconds' variable? not working. Everytime when i use again this command then it shows me a bigger time, lol.
Reply
#8

Add this print and see what you get

pawn Code:
printf("ticks: %d   pvar: %d", GetTickCount(), GetPVarInt(playerid, "LastZW"));
Can you explain a bit, what is this code all about?
Reply
#9

To use this command only one per 10 minutes.

pawn Code:
// --- Mini-system z/w ---
CMD:testcmd(playerid, params[])
{
    if(GetPVarInt(playerid, "LastZW") != 0 && (GetTickCount() - GetPVarInt(playerid, "LastZW")) < MINUTES(10))
    {
        new string[128], minutes, seconds = (GetTickCount() - GetPVarInt(playerid, "LastZW"));
        //(GetPVarInt(playerid, "LastZW") - GetTickCount()) / 1000 + MINUTES(10);
        minutes = seconds / 60;
        seconds %= 60;
        format(string, sizeof(string), ""COL_LYELL"Musisz poczekać jeszcze: "COL_RED"%dmin %dsek, "COL_LIMON"aby zmienić status.", minutes, seconds);
        return ShowInfo(playerid, "Błąd - status", string);
    }
   
    if(PlayerInfo[playerid][pStatus])
    {
        ShowInfo(playerid, "Błąd", ""COL_RED"Jesteś już na statusie 'zaraz wracam'. "COL_LYELL"Zmień go na 'już jestem'");
        return true;
    }

    new string[64];
    PlayerInfo[playerid][pStatus] = true;
    TogglePlayerControllable(playerid, false);
    SetPVarInt(playerid, "LastZW", GetTickCount());
    GetPlayerHealth(playerid, PlayerInfo[playerid][pStatusHealth]);
    SetPlayerHealth(playerid, 9999.9);
   
    format(string, sizeof(string), ""COL_LBLUE"%s "COL_LYELL"zaraz wraca!", PlayerName(playerid));
    SendClientMessageToAll(-1, string);
    return true;
}
Reply
#10

Try this one

pawn Code:
new string[128], minutes, seconds = MINUTES(10) - (GetTickCount() - GetPVarInt(playerid, "LastZW")) / 1000;
Reply
#11

9999 min 59 sek. Maybe here?
pawn Code:
if(GetPVarInt(playerid, "LastZW") != 0 && (GetTickCount() - GetPVarInt(playerid, "LastZW")) < MINUTES(10))
MINUTES(10)
Reply
#12

What about this one?
Code:
new string[128], minutes, seconds = 600 - ((GetTickCount() - GetPVarInt(playerid, "LastZW")) / 1000);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)