SA-MP Forums Archive
Real Time Clock in GM - 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: Real Time Clock in GM (/showthread.php?tid=649554)



Real Time Clock in GM - spyro9696 - 10.02.2018

Hello, if possible, I would like to put this fs about real time clock in my gm.
How do I change this fs in order to put it in my gm? Because there is a part that have to go below public OnFilterScriptInit()

Quote:

#include <a_samp>
#define FILTERSCRIPT

new Text:Clock; new Text:WeekDayg;

forward GetWeekdayNum(d,m,y);
forward settime();
forward weatherchange();

public OnFilterScriptInit()
{
WeekDayg = TextDrawCreate(558.000000,4.000000,"----");
TextDrawAlignment(WeekDayg,0);
TextDrawBackgroundColor(WeekDayg,0x000000ff);
TextDrawFont(WeekDayg,3);
TextDrawLetterSize(WeekDayg,0.500000,1.600000);
TextDrawColor(WeekDayg,0xffff00cc);
TextDrawSetOutline(WeekDayg,1);
TextDrawSetProportional(WeekDayg,1);
TextDrawSetShadow(WeekDayg,10);

Clock = TextDrawCreate(578.0, 17.0, "--:--");
TextDrawLetterSize(Clock, 0.4, 1.;
TextDrawFont(Clock, 3);
TextDrawSetOutline(Clock, 2);

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

public OnFilterScriptExit()
{
return 1;
}

public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid, Clock);
TextDrawShowForPlayer(playerid, WeekDayg);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
TextDrawHideForPlayer(playerid, Clock);
TextDrawHideForPlayer(playerid, WeekDayg);
return 1;
}

public weatherchange(){
SetWeather(random(1);
}

public settime(){
new hour,minute,second;
new string[256];
gettime(hour,minute,second);
if (minute <= 9){format(string,25,"%d:0%d",hour,minute);}
else {format(string,25,"%d:%d",hour,minute);}
TextDrawSetString(Clock,string);
SetWorldTime(hour);
new day, month, year;
new weekday;
getdate(day, month, year);
weekday = GetWeekdayNum(day, month, year);
if(weekday == 1){TextDrawSetString(WeekDayg,"Lunedi");}
if(weekday == 2){TextDrawSetString(WeekDayg,"Martedi");}
if(weekday == 3){TextDrawSetString(WeekDayg,"Mercoledi");}
if(weekday == 4){TextDrawSetString(WeekDayg,"Giovedi");}
if(weekday == 5){TextDrawSetString(WeekDayg,"Venerdi");}
if(weekday == 6){TextDrawSetString(WeekDayg,"Sabato");}
if(weekday == 7){TextDrawSetString(WeekDayg,"Domenica");}
return 1;
}

public GetWeekdayNum(d,m,y) //by d.wine
{
m-=2;
if(m<=0)
{
y--;
m+=12;
}
new cen = y/100;
y=getrem(y,100);
new w = d + ((13*m-1)/5) + y + (y/4) + (cen/4) - 2*cen;
w=getrem(w,7);
if (w==0) w=7;
return w-1;
}

getrem(a,b) //get remnant of division
{
new div = a/b;
new left = a-b*div;
return left;
}




Re: Real Time Clock in GM - Mugala - 10.02.2018

I can't understand what is a problem?


Re: Real Time Clock in GM - PepsiCola23 - 10.02.2018

add the thing from
PHP код:
public OnFilterScriptInit 
in your gamemode at
PHP код:
public OnGameModeInit 



Re: Real Time Clock in GM - spyro9696 - 10.02.2018

@PepsiCola23 thanks, +REP