06.07.2014, 10:42
Hello, Guyz This is My First Tutorial, and Im Going to Teach You How To Make a Simple Birthday System
And Sorry For My Bad English.
And Sorry For My Bad English.
lets Start.
First Put This On The Top Of Your Script.
First Put This On The Top Of Your Script.
PHP Code:
//This is Just an Exapmle Seconds and Its Not Saving. im just giving an Example.
new PlayerDaysAliveTimer[MAX_PLAYERS];//Timer Variable.
new Seconds[MAX_PLAYERS];
new Minutes[MAX_PLAYERS];
new Hours[MAX_PLAYERS];
new Days[MAX_PLAYERS];
new Years[MAX_PLAYERS];
new BirthdayCount[MAX_PLAYERS];//we will use this with Player Days, B/c When Player Days Reached At 365 And Birthday Count to 365 Server Will Reset Birthday Count = 0; and Start it again for next year count. and days will be countinued and will not get reseted.
Here We will Make Timer. Which Will Count Seconds. we can use this Under OnPlayerConnect. And Also You can Use This In You Gamemode/Filterscript. when player login.
Ok Lets Start Timer.
Ok Lets Start Timer.
PHP Code:
PlayerDaysAliveTimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);//this is timer.
Now Add This In The Center Of You Script.
PHP Code:
forward TimeOnServer(playerid);
public TimeOnServer(playerid)
{
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
Seconds[playerid]++;//here seonds will be counted.
}
}
if(Seconds[playerid] >= 60) //here if seconds more than \'60\' minuts will be +++ And Seconds will be reseted for next minute count
{
Minutes[playerid]++;//minutes plus.
Seconds[playerid] =0;//seconds reset
}
if(Minutes[playerid] >=60)//here if minutes played more than 60. hours will be +++
{
Hours[playerid]++;//hours
Minutes[playerid]=0;//minutes to \'0\'
}
if(Hours[playerid] >=24)//here a day will be counted.
{
Hours[playerid] =0;//hours
Days[playerid]++;//counting days
BirthdayCount[playerid]++;//counting days for birthday. with days.
}
if(BirthdayCount[playerid] >= 365)//here birthday count will be counted with days b/c days will be continue to next birthday like 365 to 720. for new birthday.
{
//Do You Stuff, Here Which u want.
Years[playerid]++;//counting players years alive.
}
Thank You.
Danish.
This Is My First Tutorial. and I Hope It will be Usefull For You. Birthday is very common and it is used in most of roleplay/and cnr servers.
Danish.
This Is My First Tutorial. and I Hope It will be Usefull For You. Birthday is very common and it is used in most of roleplay/and cnr servers.
+REP If it Helped You.