Clock Time In-Game.. - 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: Clock Time In-Game.. (
/showthread.php?tid=301751)
Clock Time In-Game.. -
Dokins - 05.12.2011
How does it work or how do I go about it? As in, How do I make the clock hours instead of seconds(i'm guessing a timer, but would someone explain?) It's always confused me.
+ rep for best answer.
Re: Clock Time In-Game.. -
bartje01 - 05.12.2011
I'm not sure if you're looking for this but this is included when you download a samp server.
gl_realtime
pawn Код:
//
// Keeps the in game time synced to the server's time and
// draws the current time on the player's hud using a textdraw/
// (1 minute = 1 minute real world time)
//
// Kye 2009
#include <a_samp>
#pragma tabsize 0
//--------------------------------------------------
new Text:txtTimeDisp;
new hour, minute;
new timestr[32];
forward UpdateTime();
//--------------------------------------------------
public UpdateTime()
{
gettime(hour, minute);
format(timestr,32,"%02d:%02d",hour,minute);
TextDrawSetString(txtTimeDisp,timestr);
SetWorldTime(hour);
new x=0;
while(x!=MAX_PLAYERS) {
if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE) {
SetPlayerTime(x,hour,minute);
}
x++;
}
}
//--------------------------------------------------
public OnGameModeInit()
{
// Init our text display
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);
UpdateTime();
SetTimer("UpdateTime",1000 * 60,1);
return 1;
}
//--------------------------------------------------
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid,txtTimeDisp);
gettime(hour, minute);
SetPlayerTime(playerid,hour,minute);
return 1;
}
//--------------------------------------------------
public OnPlayerDeath(playerid, killerid, reason)
{
TextDrawHideForPlayer(playerid,txtTimeDisp);
return 1;
}
//--------------------------------------------------
public OnPlayerConnect(playerid)
{
gettime(hour, minute);
SetPlayerTime(playerid,hour,minute);
return 1;
}
//--------------------------------------------------
Re: Clock Time In-Game.. -
Dokins - 05.12.2011
Perfect, thanks!
Re: Clock Time In-Game.. -
Dokins - 05.12.2011
Actually, not sure what I do with this, Do I include it or what?
Re: Clock Time In-Game.. -
bartje01 - 05.12.2011
Put everything on the right place in your gamemode