Time! - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Time! (
/showthread.php?tid=269423)
Time! -
Setkus - 16.07.2011
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!
Re: Time! -
freshOrange - 16.07.2011
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 Код:
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;
}
Re: Time! -
Setkus - 16.07.2011
Thank you! You really helped me.
Re: Time! -
Setkus - 16.07.2011
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 ?
Re: Time! -
freshOrange - 16.07.2011
You can recalculate if timer is set correctly, 1 second = 1000 for those 5 mins.
Re: Time! -
Jay. - 16.07.2011
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.
Re: Time! -
Setkus - 16.07.2011
And what about time in display ? It doesn't show for me...
Re: Time! -
Setkus - 16.07.2011
Now it works. Thank you very much!
Re: Time! -
freshOrange - 16.07.2011
Ah, sorry.
Thanks Jay.
pawn Код:
TextDrawShowForPlayer(playerid,Timer);
under OnPlayerSpawn
Re: Time! -
Setkus - 16.07.2011
And is there any way to change the time ? For exaple not 5 min but 30 mins ?