SA-MP Forums Archive
Time problem! - 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: Time problem! (/showthread.php?tid=396579)



Time problem! - Baumann - 01.12.2012

hey i got this script
/*
dddddddd
SSSSSSSSSSSSSSS hhhhhhh d::::::d
SS:::::::::::::::Sh:::::h d::::::d
S:::::SSSSSS::::::Sh:::::h d::::::d
S:::::S SSSSSSSh:::::h d:::::d
S:::::S h::::h hhhhh aaaaaaaaaaaaa ddddddddd:::::d
S:::::S h::::hh:::::hhh a::::::::::::a dd::::::::::::::d
S::::SSSS h::::::::::::::hh aaaaaaaaa:::::a d::::::::::::::::d
SS::::::SSSSS h:::::::hhh::::::h a::::ad:::::::ddddd:::::d
SSS::::::::SS h::::::h h::::::h aaaaaaa:::::ad::::::d d:::::d
SSSSSS::::S h:::::h h:::::h aa::::::::::::ad:::::d d:::::d
S:::::S h:::::h h:::::h a::::aaaa::::::ad:::::d d:::::d
S:::::S h:::::h h:::::ha::::a a:::::ad:::::d d:::::d
SSSSSSS S:::::S h:::::h h:::::ha::::a a:::::ad::::::ddddd::::::dd
S::::::SSSSSS:::::S h:::::h h:::::ha:::::aaaa::::::a d:::::::::::::::::d
S:::::::::::::::SS h:::::h h:::::h a::::::::::aa:::a d:::::::::ddd::::d
SSSSSSSSSSSSSSS hhhhhhh hhhhhhh aaaaaaaaaa aaaa ddddddddd ddddd
*/


#include <a_samp>
#define FILTERSCRIPT

new Text:Time, Textate;

forward settime(playerid);

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Updated Version! WORLDCLOCK+DATE By Shadow");
print("--------------------------------------\n");

SetTimer("settime",1000,true);

Date = TextDrawCreate(547.000000,11.000000,"--");

TextDrawFont(Date,3);
TextDrawLetterSize(Date,0.399999,1.600000);
TextDrawColor(Date,0xffffffff);

Time = TextDrawCreate(547.000000,28.000000,"--");

TextDrawFont(Time,3);
TextDrawLetterSize(Time,0.399999,1.600000);
TextDrawColor(Time,0xffffffff);


SetTimer("settime",1000,true);
return 1;
}

public OnFilterScriptExit()
{
print("\n-----------------------------------------------------");
print(" Update Version! WORLDCLOCK+DATE By Shadow !UNLOADED!");
print("-----------------------------------------------------/n");
return 1;
}

public OnPlayerSpawn(playerid)
{
SendClientMessage(playerid, 0xF97804FF, "Kommandid /neon /home /rules /help /work !");
TextDrawShowForPlayer(playerid, Time), TextDrawShowForPlayer(playerid, Date);


return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
TextDrawHideForPlayer(playerid, Time), TextDrawHideForPlayer(playerid, Date);
return 1;
}

public settime(playerid)
{
new string[256],year,month,day,hours,minutes,seconds;
getdate(year, month, day), gettime(hours, minutes, seconds);
format(string, sizeof string, "%d/%s%d/%s%d", day, ((month < 10) ? ("0") : ("")), month, (year < 10) ? ("0") : (""), year);
TextDrawSetString(Date, string);
format(string, sizeof string, "%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (minutes < 10) ? ("0") : (""), minutes, (seconds < 10) ? ("0") : (""), seconds);
TextDrawSetString(Time, string);
}


how i can turn it back 2hours , if i open server clock is the 17.24 but i need turn back it 2 hours and need 15.24


AW: Time problem! - Skimmer - 01.12.2012

Please enter the script as [pawn] BBcode.


Re: Time problem! - Konstantinos - 01.12.2012

Gettime - Get the current server time, which will be stored in the variables &hour, &minute and &second.
pawn Код:
public settime(playerid)
{
    new string[256],year,month,day,hours,minutes,seconds;
    getdate(year, month, day), gettime(hours, minutes, seconds);
    format(string, sizeof string, "%d/%02d%02d", day, month, year);
    TextDrawSetString(Date, string);
    format(string, sizeof string, "%02d:%02d:%02d", hours-2, minutes, seconds);
    TextDrawSetString(Time, string);
}
Guess what? There is a format of %02d and if it's under 10, let's say 9, it uses 09. It's not need to use if/else for 0 or null.


Re: Time problem! - Baumann - 01.12.2012

ty bro it worked!


Re: Time problem! - Baumann - 01.12.2012

now got antorher problem it shows 01/122012 but i need 01/12/2012


Re: Time problem! - InfiniTy. - 01.12.2012

Quote:
Originally Posted by Baumann
Посмотреть сообщение
now got antorher problem it shows 01/122012 but i need 01/12/2012
Instead of this
pawn Код:
format(string, sizeof string, "%d/%02d%02d", day, month, year);
put this
pawn Код:
format(string, sizeof string, "%02d/%02d/%02d", day, month, year);



Re: Time problem! - Konstantinos - 01.12.2012

Quote:
Originally Posted by Adytza.
Посмотреть сообщение
Instead of this
pawn Код:
format(string, sizeof string, "%d/%02d%02d", day, month, year);
put this
pawn Код:
format(string, sizeof string, "%02d/%02d/%02d", day, month, year);
^^

I forgot to use a "/" to separate them.


Re: Time problem! - Baumann - 01.12.2012

Now i got another problem the time is 22:44 but in samp it shows -02:44
and date must 01/12/2012 but in samp it show 02/12/12
code:
public settime(playerid)
{
new string[256],year,month,day,hours,minutes,seconds;
getdate(year, month, day), gettime(hours, minutes, seconds);
format(string, sizeof string, "%02d/%02d/%02d", day, month, year);
TextDrawSetString(Date, string);
format(string, sizeof string, "%02d:%02d:%02d", hours-2, minutes, seconds);
TextDrawSetString(Time, string);
}


Re: Time problem! - dr.lozer - 01.12.2012

your crazy man