SA-MP Forums Archive
gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - 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: gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? (/showthread.php?tid=283113)



gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - OleKristian95 - 13.09.2011

Title explains everything, I would like to have the gl_realtime filterscript but not as realtime i would like to have it as 1 minute is 1 hour.


Re: gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - Stigg - 13.09.2011

Just toggle the ingame clock:

pawn Код:
TogglePlayerClock(playerid, 1);
https://sampwiki.blast.hk/wiki/TogglePlayerClock

It's just like single player time. No need for another fs.


Re: gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - OleKristian95 - 13.09.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Just toggle the ingame clock:

pawn Код:
TogglePlayerClock(playerid, 1);
https://sampwiki.blast.hk/wiki/TogglePlayerClock

It's just like single player time. No need for another fs.
One more question, is it just to add that line? or do I have to do something more?
anddddd will the time change? like will the time be night if the time is 00:00 ?


Re: gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - PowerPC603 - 14.09.2011

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 game-time = 1 second real world time)
//
//  Kye 2009

#include <a_samp>
#pragma tabsize 0

//--------------------------------------------------

// Setup global variables
new ServerMinutes, ServerHours, Text:TimeDisplay, TimeString[32];

public OnFilterScriptInit()
{
    TimeDisplay = TextDrawCreate(605.0, 25.0, "00:00");
    TextDrawUseBox(TimeDisplay, 0);
    TextDrawFont(TimeDisplay, 3);
    TextDrawSetShadow(TimeDisplay, 0); // no shadow
    TextDrawSetOutline(TimeDisplay, 2); // thickness 1
    TextDrawBackgroundColor(TimeDisplay, 0x000000FF);
    TextDrawColor(TimeDisplay, 0xFFFFFFFF);
    TextDrawAlignment(TimeDisplay, 3);
    TextDrawLetterSize(TimeDisplay, 0.5, 1.5);

    // Start a timer that runs every second
    SetTimer("ProcessGameTime", 1000, 1);
}

forward ProcessGameTime();
public ProcessGameTime()
{
    // Increment the minute counter
    ServerMinutes++;

    // One hour has passed
    if(ServerMinutes == 60)
    {
        // Reset the minutes to 0
        ServerMinutes = 0;
        // Increase the hours
        ServerHours++;

        // One day has passed
        if(ServerHours == 24)
            ServerHours = 0;
    }

    // Format the text to be shown on the textdraw
    format(TimeString,32,"%02d:%02d", ServerHours, ServerMinutes);
    TextDrawSetString(TimeDisplay, TimeString);

    // Update the time for every player
    for (new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        // Check if the player is connected
        if (IsPlayerConnected(playerid))
        {
            // Update the time for this player
            SetPlayerTime(playerid, ServerHours, ServerMinutes);
        }
    }
}

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

public OnPlayerDeath(playerid, killerid, reason)
{
    TextDrawHideForPlayer(playerid, TimeDisplay);

    return 1;
}

// This callback gets called when a player disconnects from the server
public OnPlayerDisconnect(playerid, reason)
{
    TextDrawHideForPlayer(playerid, TimeDisplay);

    return 1;
}



Re: gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - Stigg - 14.09.2011

Quote:
Originally Posted by OleKristian95
Посмотреть сообщение
One more question, is it just to add that line? or do I have to do something more?
anddddd will the time change? like will the time be night if the time is 00:00 ?
Just add that 1 line and yes the time changes like single player.


Re: gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - OleKristian95 - 14.09.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Just add that 1 line and yes the time changes like single player.
Didnt work, I saw the clock 1 second right when I joined then it disappeared when I came to class selection and it was constantly nighttime when I spawned.


Re: gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - OleKristian95 - 04.04.2012

I still need help with this, hope someone can


Re: gl_realtime - is it possible to make it like the san andreas (Singleplayer) game time? - Steven82 - 04.04.2012

Remove gl_realtime from your server.cfg if it's still defined in it.