#1

Hey, guys!
I have one more problem... I dont know how to use time. Well I want that the time go back. For example 5 minutes and after 5 minutes for example game mode change. And is it possible that the display show the time and as it moves back ? Well, i hope you understand me. Have a nice day!
Reply
#2

On very top

pawn Код:
forward GMChange(playerid);
Under OnGameModeInit

pawn Код:
SetTimer("GMChange",3000000,false); // 5 minutes
pawn Код:
public GMChange(playerid)
{
    SendRconCommand("changemode YOURGMNAME");
    return 1;
}
--------------------------------------------------------------------------
Visual (author:Jeffry)

Very top

pawn Код:
forward UpdateTime();
pawn Код:
new Time, TimeM, TimeS;
new Text:Timer;
Under OnGameModeInit

pawn Код:
Timer = TextDrawCreate(550.000000, 30.000000, "5:00");
    TextDrawFont(Timer, 3);
    TextDrawLetterSize(Timer, 0.600000, 1.100000);
    TextDrawSetOutline(Timer, 1);
    TextDrawSetShadow(Timer, 0);

    TimeM = 5;
    TimeS = 0;
    Time = SetTimer("UpdateTime", 1000, true);
pawn Код:
public UpdateTime()
{
    new Str[34];
    TimeS --;
    if(TimeM == 0 && TimeS == 0)
    {
        KillTimer(Time);
    }
    if(TimeS == -1)
    {
        TimeM--;
        TimeS = 59;
    }
    format(Str, sizeof(Str), "%02d:%02d", TimeM, TimeS);
    TextDrawSetString(Timer, Str);
    return 1;
}
Reply
#3

Thank you! You really helped me.
Reply
#4

Well, it doesn't work. The mode doesn't change and there is no time in display. But after i pressing f5 there is no errors. What is it wrong ?
Reply
#5

You can recalculate if timer is set correctly, 1 second = 1000 for those 5 mins.
Reply
#6

Thats not the problem.
you forgot alot of obvious things.
pawn Код:
//top
forward UpdateTime();
new Time, TimeM, TimeS;
new Text:Timer;

//Under OnGameModeInit

    Timer = TextDrawCreate(550.000000, 30.000000, "5:00");
    TextDrawFont(Timer, 3);
    TextDrawLetterSize(Timer, 0.600000, 1.100000);
    TextDrawSetOutline(Timer, 1);
    TextDrawSetShadow(Timer, 0);

    TimeM = 5;
    TimeS = 0;
    Time = SetTimer("UpdateTime", 1000, true);

public UpdateTime()
{
    new Str[34];
    TimeS --;
    if(TimeM == 0 && TimeS == 0)
    {
        KillTimer(Time);
        SendRconCommand("gmx"); // restart server
       //perform other functions
    }
    if(TimeS == -1)
    {
        TimeM--;
        TimeS = 59;
    }
    format(Str, sizeof(Str), "%02d:%02d", TimeM, TimeS);
    TextDrawSetString(Timer, Str);
    return 1;

}
pawn Код:
TextDrawShowForPlayer(playerid,Timer);
//Add this under onplayerspawn
Credits to Jeffry for making the script.
And freshorange for the post, i just added some things to make it work.
Reply
#7

And what about time in display ? It doesn't show for me...
Reply
#8

Now it works. Thank you very much!
Reply
#9

Ah, sorry.

Thanks Jay.

pawn Код:
TextDrawShowForPlayer(playerid,Timer);
under OnPlayerSpawn
Reply
#10

And is there any way to change the time ? For exaple not 5 min but 30 mins ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)