[SOLVED] Normal clock? - 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: [SOLVED] Normal clock? (
/showthread.php?tid=131454)
[SOLVED] Normal clock? -
FreddeN - 03.03.2010
Sup, I've been using the RealTime filterscript for 0.3 but some players want the normal clock from singleplayer so they dont have to wait so long before it gets dark etc.
Any suggestions on how to put in the normal clock/time?
Thanks
Re: [HELP] Normal clock? -
Miguel - 03.03.2010
pawn Код:
new time[2]; // 0 hours, 1 minutes
pawn Код:
public OnGameModeInit()
{
time[0] = random(24), time[1] = random(60);
SetTimer("ChangeTime", 1000, true);
return 1;
}
pawn Код:
forward ChangeTime();
public ChangeTime()
{
time[1] ++;
if(time[1] > 59) time[1] = 0, time[0] ++;
if(time[0] > 23) time[0] = 0, time[1] = 0;
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i)) SetPlayerTime(i, time[0], time[1]);
}
return 1;
}
That's a 24 minutes/days and 60 seconds/hour. Don't forget to use TogglePlayerClock to disable the single player clock.
Re: [HELP] Normal clock? -
FreddeN - 03.03.2010
Quote:
Originally Posted by SAWC™
pawn Код:
new time[2]; // 0 hours, 1 minutes
pawn Код:
public OnGameModeInit() { time[0] = random(24), time[1] = random(60); SetTimer("ChangeTime", 1000, true); return 1; }
pawn Код:
forward ChangeTime(); public ChangeTime() { time[1] ++; if(time[1] > 59) time[1] = 0, time[0] ++; if(time[0] > 23) time[0] = 0, time[1] = 0; for(new i = 0; i < MAX_PLAYERS; i ++) { if(IsPlayerConnected(i)) SetPlayerTime(i, time[0], time[1]); } return 1; }
That's a 24 minutes/days and 60 seconds/hour. Don't forget to use TogglePlayerClock to disable the single player clock.
|
Thanks, but I get this error:
Код:
undefined symbol "playerid"
At this line:
Код:
if(IsPlayerConnected(i)) SetPlayerTime(playerid, time[0], time[1]);
Re: [HELP] Normal clock? -
Miguel - 03.03.2010
My bad, sorry.
Re: [HELP] Normal clock? -
FreddeN - 03.03.2010
Quote:
Originally Posted by SAWC™
My bad, sorry.
|
The clock works I think, but can you help me to get it to display?
Re: [HELP] Normal clock? -
MaykoX - 03.03.2010
Quote:
Originally Posted by FreddeN
Quote:
Originally Posted by SAWC™
My bad, sorry.
|
The clock works I think, but can you help me to get it to display?
|
https://sampwiki.blast.hk/wiki/TextDrawCreate
Re: [HELP] Normal clock? -
Miguel - 03.03.2010
Use the textdraw system used on the real clock FS from the sa-mp package.
Re: [HELP] Normal clock? -
FreddeN - 03.03.2010
Quote:
Originally Posted by SAWC™
Use the textdraw system used on the real clock FS from the sa-mp package.
|
I gont get it to work, it just says 00:00 if I puts in the textdraw lines...
Код:
//Top
new Text:txtTimeDisp;
// OnGameModeInit
txtTimeDisp = TextDrawCreate(605.0,25.0,"00:00");
TextDrawUseBox(txtTimeDisp, 0);
TextDrawFont(txtTimeDisp, 3);
TextDrawSetShadow(txtTimeDisp,0); // no shadow
TextDrawSetOutline(txtTimeDisp,2); // thickness 1
TextDrawBackgroundColor(txtTimeDisp,0x000000FF);
TextDrawColor(txtTimeDisp,0xFFFFFFFF);
TextDrawAlignment(txtTimeDisp,3);
TextDrawLetterSize(txtTimeDisp,0.5,1.5);
// OnPlayerSpawn
TextDrawShowForPlayer(playerid,txtTimeDisp);
// OnPlayerDeath
TextDrawHideForPlayer(playerid,txtTimeDisp);
Re: [HELP] Normal clock? -
Miguel - 03.03.2010
Ok good, :
pawn Код:
forward ChangeTime();
public ChangeTime()
{
new
string[6];
time[1] ++;
if(time[1] > 59) time[1] = 0, time[0] ++;
if(time[0] > 23) time[0] = 0, time[1] = 0;
format(string, sizeof(string), "%02d:%02d", time[0], time[1]);
TextDrawSetString(txtTimeDisp, string);
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i)) SetPlayerTime(i, time[0], time[1]);
}
return 1;
}
That should update the text draw.
Re: [HELP] Normal clock? -
FreddeN - 03.03.2010
Quote:
Originally Posted by SAWC™
Ok good, :
pawn Код:
forward ChangeTime(); public ChangeTime() { new string[6];
time[1] ++; if(time[1] > 59) time[1] = 0, time[0] ++; if(time[0] > 23) time[0] = 0, time[1] = 0; format(string, sizeof(string), "%02d:%02d", time[0], time[1]); TextDrawSetString(txtTimeDisp, string); for(new i = 0; i < MAX_PLAYERS; i ++) { if(IsPlayerConnected(i)) SetPlayerTime(i, time[0], time[1]); } return 1; }
That should update the text draw.
|
Thanks man, works