SA-MP Forums Archive
[FilterScript] Real Time for each player's Timezone - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Real Time for each player's Timezone (/showthread.php?tid=311464)



Real Time for each player's Timezone - [FAT]Klabauter[LST] - 16.01.2012

Very simple... because i dunno how to do anything hard yet lol. This script will set each players game time to match their REAL time. All you have to do is change the servergmt value to the GMT of your server. I intentionally did it OnPlayerSpawn because in my TDM server players spawn constantly so I did not need to use a timer. If you want, you can put it on a timer yourself quite easily.

I tested, and am using this script on my server. No video since it would be pointless.

Requirements

-GeoIP plugin
-GeoIP include

Code:
// Player Time Zone by Klabauter_Mann
// Please do not remove the credits or claim this script as your own
// You must have GeoIP plugin to use this script
// You must have GeoIP include to compile this script

#include <a_samp>
#include GeoIP_Plugin

#define servergmt 0 // Set the GMT of your server, example: if your server is in New York City change 0 to -5

public OnFilterScriptInit()
{
    print("\n-------------------------------------------------");
    print(" Player Time Zone by Klabauter_Mann");
    print("-------------------------------------------------\n");
    return true;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, 0xC071FFFF, "This server is using Player Time Zone");
    SendClientMessage(playerid, 0xC071FFFF, "Made by Klabauter_Mann");
    return true;
}

public OnPlayerSpawn(playerid)
{
    new Hour, Minute, Second;
    gettime(Hour, Minute, Second);
    new gmt = GetPlayerGMT(playerid);
    new sum = Hour + gmt - servergmt;
    if(sum >= 24 && sum < 48)
        {
        SetPlayerTime(playerid, sum - 24, Minute);
        }
    if(sum >= 48)
        {
        SetPlayerTime(playerid, sum - 48, Minute);
        }
    if(sum < 0)
        {
        SetPlayerTime(playerid, sum + 24, Minute);
        }
    if(sum >= 0 && sum < 24)
	{
	SetPlayerTime(playerid, sum, Minute);
	}
    return true;
}
Updates

- Fixed problem with sums that are less than zero or greater than 23


Re: Real Time for each player's Timezone - JohnDoVaS12345 - 16.01.2012

nice


Re: Real Time for each player's Timezone - Brian_G - 16.01.2012

really nice.


Re: Real Time for each player's Timezone - KeKe98 - 17.01.2012

Cool.


Re: Real Time for each player's Timezone - CoaPsyFactor - 17.01.2012

this is very good, considering that this is your first script post +1


Re: Real Time for each player's Timezone - CAPTAIN.TINTIN - 17.01.2012

Sweet and simple


Re: Real Time for each player's Timezone - SoUrAv - 17.01.2012

Easy and nice.


Re: Real Time for each player's Timezone - [FAT]Klabauter[LST] - 18.01.2012

I fixed the problem that occurs when the sum of "Hour + gmt - servergmt" is greater than 23 or less than zero. I guess that the simplicity of the original script was a bit of wishful thinking.


Re: Real Time for each player's Timezone - AchievementMaster360 - 28.11.2012

Nice ill try it out


Re: Real Time for each player's Timezone - Kontrol - 28.11.2012

Saved me a job cheers dude.


Re: Real Time for each player's Timezone - ProPoint - 15.01.2013

Another Nice One, so simple