12.06.2017, 15:49
(
Last edited by bencesz; 14/06/2017 at 07:39 PM.
)
Hey guys, I want to show you how to fast forward timelapse In-Game as I haven't found any tutorials according this. This is my first tutorial, I'll hope you can understand and make a use of it. It's just a simple use of timers and variables.
What can you use it for?
-It can be useful on roleplay servers (you can pay realistic amounts for players for 6-,8-,12 hours of in-game work - which can be 1 or 2 hours in real life for example).
-You can make a slowed down timelapse (compared to singleplayer, like GTA 4's or 5's).
In this tutorial I'll show you how to make 1 In-Game hour pass by 15 minutes in real life with the use of a variable and a simple timer.
First off, we have to declare 2 variables on the top of our script:
After this, we have to set the world time under OnGameModeInit. Basically, this will be the starting time of our server.
Now we are forwarding and using a public function:
Finally, kill the timer under OnGameModeExit()
In one piece:
What can you use it for?
-It can be useful on roleplay servers (you can pay realistic amounts for players for 6-,8-,12 hours of in-game work - which can be 1 or 2 hours in real life for example).
-You can make a slowed down timelapse (compared to singleplayer, like GTA 4's or 5's).
In this tutorial I'll show you how to make 1 In-Game hour pass by 15 minutes in real life with the use of a variable and a simple timer.
First off, we have to declare 2 variables on the top of our script:
PHP Code:
new worldtime; //we will use this to set and increase worldtime with the help of our timer
new timelapseTimer; //timer
PHP Code:
public OnGameModeInit()
{
worldtime = 6; // giving the value of the variable -> the starting time to be set
SetWorldTime(worldtime); // will set the in-game time to the previously given value ^
timelapseTimer = SetTimer("Timelapse", 1000 * 900, 1); // a 15-minute (900 sec) timer, repeating true (1) to continue and provide later timelapse. A higher interval will slow down, a lower one will fasten timelapse.
return 1;
}
PHP Code:
forward Timelapse();
public Timelapse()
{
worldtime++; // after 15 minutes, our variable's value is increased by 1
if(worldtime == 24) worldtime = 0; // we have to reset worldtime, because the SA:MP world time ranges from 0 to 23
SetWorldTime(worldtime); // success! with 15 minutes spent in real life, in game we already spent 1 hour.
SendClientMessageToAll(0xFFFFFFAA, "One hour has passed.");
return 1; // return 1, to continue
}
PHP Code:
public OnGameModeExit()
{
KillTimer(timelapseTimer);
return 1;
}
PHP Code:
#include <a_samp>
new worldtime;
new timelapseTimer;
forward Timelapse();
public Timelapse()
{
worldtime++;
if(worldtime == 24) worldtime = 0;
SetWorldTime(worldtime);
SendClientMessageToAll(0xFFFFFFAA, "One hour has passed.");
return 1;
}
public OnGameModeInit()
{
worldtime = 6;
SetWorldTime(worldtime);
timelapseTimer = SetTimer("Timelapse", 1000 * 900, 1);
return 1;
}
public OnGameModeExit()
{
KillTimer(timelapseTimer);
return 1;
}