SA-MP Forums Archive
Help! How to change the timer format? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help! How to change the timer format? (/showthread.php?tid=587509)



SOLVED - Ercha - 31.08.2015

SOLVED


Re: Help! How to change the timer format? - Rodri99 - 31.08.2015

#define MAX_MAPTIME 250
#define MAX_MAPUPDATE_TIME 1450

function OnMapUpdate(playerid)
{
time -= 1;

new str[64], jtime;
jtime=time*1000*60;
format(str,sizeof(str),"%d",jtime);
TextDrawSetString(TimeLeft,str);

if(time <= 0) TextDrawSetString(TimeLeft," ..."),KillTimer(mapvar),KillTimer(balvar),SetTimer ("ShowCheckpoint",MAX_SHOW_CP_TIME,false);
if(time <= 0) GameTextForPlayer(playerid,"~b~Humans~n~ ~w~Go To Evacuation!",5000,6);//
return 1;
}

+REP ME PLEASE


Re: Help! How to change the timer format? - Ercha - 31.08.2015

Is that even correct?

And it gives me a warning:

Код:
symbol is assigned a value that is never used: "jtime"
EDIT: That didn't changed anything, but thanks for trying to help.


Re: Help! How to change the timer format? - Rodri99 - 31.08.2015

#define MAX_MAPTIME 250
#define MAX_MAPUPDATE_TIME 1450

new jtime=true;

function OnMapUpdate(playerid)
{
time -= 1;

new str[64];
jtime=time*1000*60;
format(str,sizeof(str),"%d",jtime);
TextDrawSetString(TimeLeft,str);

if(time <= 0) TextDrawSetString(TimeLeft," ..."),KillTimer(mapvar),KillTimer(balvar),SetTime r ("ShowCheckpoint",MAX_SHOW_CP_TIME,false);
if(time <= 0) GameTextForPlayer(playerid,"~b~Humans~n~ ~w~Go To Evacuation!",5000,6);//
return 1;
}


Re: Help! How to change the timer format? - Ercha - 31.08.2015

It's even more worse.

Код:
C:\ZL\gamemodes\zma.pwn(338) : warning 219: local variable "jtime" shadows a variable at a preceding level
C:\ZL\gamemodes\zma.pwn(339) : warning 204: symbol is assigned a value that is never used: "jtime"
C:\ZL\gamemodes\zma.pwn(4846) : warning 203: symbol is never used: "jtime"
I think your option is not correct..


Re: Help! How to change the timer format? - xVIP3Rx - 31.08.2015

a timer is :
Quote:

to call a function after some time. Can be set to repeat.

the 'time' is the second parameter in 'SetTimer', so decide which timer you want to increase/decrease the time it takes to do the function and change it, notice it's in milliseconds so 1000 = 1 second
also if you want to call the function instantly, don't use the timer at all, just type the function
example:
pawn Код:
//Call 'function' after 1000 milliseconds
public OnGameModeInit()
{
    SetTimer("function", 1000, false); // Set a timer of 1000 miliseconds (1 second), non repeatable
}
forward function();
public function()
{
    print("1 second has passed.");
}
//Instantly call the public
public OnGameModeInit()
{
    function();
}
forward function();
public function()
{
    print("game mode has started");
}
EDIT: after rereading I understood you wanna change the format itself, not the timer so I apologize and here you go.
pawn Код:
#define MAX_MAPTIME 250
#define MAX_MAPUPDATE_TIME 1450

function OnMapUpdate(playerid)
{
    time -= 1;

    TextDrawSetString(TimeLeft,whatevername(time));//this will change

    if(time <= 0) TextDrawSetString(TimeLeft," ..."),KillTimer(mapvar),KillTimer(balvar),SetTimer("ShowCheckpoint",MAX_SHOW_CP_TIME,false);
    if(time <= 0) GameTextForPlayer(playerid,"~b~Humans~n~ ~w~Go To Evacuation!",5000,6);//
    return 1;
}

whatevername(seconds)
{
    new vstr[8], minutes = floatround(seconds / 60, floatround_floor);
    format(vstr, sizeof(vstr), "%02d:%02d", minutes, seconds - (minutes * 60));
    return vstr;
}



Re: Help! How to change the timer format? - Rodri99 - 31.08.2015

It is correct, if you test it works, warnings need to be solved only, but the script would work


Re: Help! How to change the timer format? - Rodri99 - 31.08.2015

He doesn't want to make a timer, he wants to display on the string the time on minutes and not in milliseconds.


Re: Help! How to change the timer format? - xVIP3Rx - 31.08.2015

Quote:
Originally Posted by Rodri99
Посмотреть сообщение
He doesn't want to make a timer, he wants to display on the string the time on minutes and not in milliseconds.
Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
EDIT: after rereading I understood you wanna change the format itself, not the timer so I apologize and here you go.
pawn Код:
#define MAX_MAPTIME 250
#define MAX_MAPUPDATE_TIME 1450

function OnMapUpdate(playerid)
{
    time -= 1;

    TextDrawSetString(TimeLeft,whatevername(time));//this will change

    if(time <= 0) TextDrawSetString(TimeLeft," ..."),KillTimer(mapvar),KillTimer(balvar),SetTimer("ShowCheckpoint",MAX_SHOW_CP_TIME,false);
    if(time <= 0) GameTextForPlayer(playerid,"~b~Humans~n~ ~w~Go To Evacuation!",5000,6);//
    return 1;
}

whatevername(seconds)
{
    new vstr[8], minutes = floatround(seconds / 60, floatround_floor);
    format(vstr, sizeof(vstr), "%02d:%02d", minutes, seconds - (minutes * 60));
    return vstr;
}
Also, your code is no way near right, please be sure of what you're posting and if you could even test it would be better, cause you're making the problem worse for scripters


Re: Help! How to change the timer format? - Ercha - 31.08.2015

@xVIP3Rx, Thanks man! It's exactly what I wanted and it works fine.

+Rep.