[SOLVED] Normal clock?
#1

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
Reply
#2

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.
Reply
#3

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]);
Reply
#4

My bad, sorry.
Reply
#5

Quote:
Originally Posted by SAWC™
My bad, sorry.
The clock works I think, but can you help me to get it to display?
Reply
#6

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
Reply
#7

Use the textdraw system used on the real clock FS from the sa-mp package.
Reply
#8

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);
Reply
#9

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)