How can I add clock to my gamemode? -
cleanboy - 03.05.2014
my gamemode doesn't have a clock in it, it is possible to add a clock in my gamemode?? and i want that to be continue its time even i quit.. thanks
Re: How can I add clock to my gamemode? -
Dignity - 03.05.2014
In the SA-MP root server (the one you download from
http://www.sa-mp.com), there's a filterscript called "gl_realtime". It does exactly what you want it to do.
If you're persistant on making one yourself though, make a textdraw and update it using timers and a variable. I can emphasize more if you want and can give you an example.
Re: How can I add clock to my gamemode? -
cleanboy - 03.05.2014
hey bro the i dont want realtime, because it is Hours:Minutes irl right, i want my clock in my server to be Minutes:Seconds something like that... example the time is, 07:00 after 1 second its now, 07:01 after a second again, 07:02 and after a second again 07:03 and so on...
Re: How can I add clock to my gamemode? -
Dignity - 03.05.2014
I edited gl_realtime for you in that case. I went over it very hastily, but it should print minutes

econds instead of hour:minutes. Please tell me if I forgot to do something or if something doesn't work.
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)
//
// © 2009-2012 SA-MP Team
#include <a_samp>
#pragma tabsize 0
//--------------------------------------------------
new Text:txtTimeDisp;
new hour, minute, seconds;
new timestr[32];
forward UpdateTimeAndWeather();
//--------------------------------------------------
new fine_weather_ids[] = {1,2,3,4,5,6,7,12,13,14,15,17,18,24,25,26,27,28,29,30,40};
new foggy_weather_ids[] = {9,19,20,31,32};
new wet_weather_ids[] = {8};
stock UpdateWorldWeather()
{
new next_weather_prob = random(100);
if(next_weather_prob < 70) SetWeather(fine_weather_ids[random(sizeof(fine_weather_ids))]);
else if(next_weather_prob < 95) SetWeather(foggy_weather_ids[random(sizeof(foggy_weather_ids))]);
else SetWeather(wet_weather_ids[random(sizeof(wet_weather_ids))]);
}
//--------------------------------------------------
//new last_weather_update=0;
public UpdateTimeAndWeather()
{
// Update time
gettime(hour, minute, seconds);
if(minute > 24) minute = 0;
format(timestr,32,"%02d:%02d",minute, seconds);
TextDrawSetString(txtTimeDisp,timestr);
SetWorldTime(minute);
new x=0;
while(x!=MAX_PLAYERS) {
if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE) {
SetPlayerTime(x,minute, seconds);
}
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);
UpdateTimeAndWeather();
SetTimer("UpdateTimeAndWeather",1000 * 60,1);
return 1;
}
//--------------------------------------------------
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid,txtTimeDisp);
gettime(hour, minute, seconds);
SetPlayerTime(playerid,minute,seconds);
return 1;
}
//--------------------------------------------------
public OnPlayerDeath(playerid, killerid, reason)
{
TextDrawHideForPlayer(playerid,txtTimeDisp);
return 1;
}
//--------------------------------------------------
public OnPlayerConnect(playerid)
{
gettime(hour, minute, seconds);
SetPlayerTime(playerid,minute,seconds);
return 1;
}
//--------------------------------------------------
Re: How can I add clock to my gamemode? -
cleanboy - 03.05.2014
Ok bro, let me try it
Re: How can I add clock to my gamemode? -
cleanboy - 03.05.2014
bro still not works, its still stuck on 18:50 , and the "50" is minutes, i want it to be "seconds" bro..
Re: How can I add clock to my gamemode? -
cleanboy - 03.05.2014
oh bro now i got abnormal time in game, its kinda teleporting time, example it was 24:24, and i died, when i respawn its 00:31 lol
Re: How can I add clock to my gamemode? -
Dignity - 03.05.2014
Lol. I'm sorry, I'll look in to it later. See
https://sampforum.blast.hk/showthread.php?tid=257071 though.
Re: How can I add clock to my gamemode? -
cleanboy - 03.05.2014
ok....