Jump to content
  • 0

pomoc Help s virtuálním časem


PowerCZ

Dotaz

Čus potřeboval bych poradit zakládal sem si FS a potřebuju aby mi šel na serveru stejnej čas jako na san andreas single playeru

 

nějak se mi to povedlo jen to skáče jak .. :d

porosím kdyby mi pomoc

 

//
// 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 = 1 minute real world time)
//
// (c) 2009-2012 SA-MP Team
#include <a_samp>
#pragma tabsize 0
//--------------------------------------------------
new Text:txtTimeDisp;
new hour, minute, seconds;
new timestr[32];
forward UpdateTimeAndWeather();
//--------------------------------------------------
new fine_weather_ids[] = {1,2,3,4,5,6,7,12,13,14,15,17,18,24,25,26,27,28,29,30,40};
new foggy_weather_ids[] = {9,19,20,31,32};
new wet_weather_ids[] = {8};
stock UpdateWorldWeather()
{
new next_weather_prob = random(100);
if(next_weather_prob < 70) SetWeather(fine_weather_ids[random(sizeof(fine_weather_ids))]);
else if(next_weather_prob < 95) SetWeather(foggy_weather_ids[random(sizeof(foggy_weather_ids))]);
else	 SetWeather(wet_weather_ids[random(sizeof(wet_weather_ids))]);
}
//-------------------------------------------------- .
//new last_weather_update=0;
public UpdateTimeAndWeather()
{
// Update time
new sekundy;
gettime(hour, minute, sekundy);
format(timestr,32,"%02d:%02d",minute,seconds);
TextDrawSetString(txtTimeDisp,timestr);
SetWorldTime(sekundy);
}
//--------------------------------------------------
public OnGameModeInit()
{
// Init our text display
txtTimeDisp = TextDrawCreate(605.0,25.0,"00:00");
TextDrawUseBox(txtTimeDisp, 0);
TextDrawFont(txtTimeDisp, 3);
TextDrawSetShadow(txtTimeDisp,0); // no shadow
TextDrawSetOutline(txtTimeDisp,2); // thickness 1
TextDrawBackgroundColor(txtTimeDisp,0x000000FF);
TextDrawColor(txtTimeDisp,0xFFFFFFFF);
TextDrawAlignment(txtTimeDisp,3);
TextDrawLetterSize(txtTimeDisp,0.5,1.5);
UpdateTimeAndWeather();
SetTimer("UpdateTimeAndWeather",1,1);
return 1;
}
//--------------------------------------------------
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid,txtTimeDisp);
gettime(hour, minute, seconds);
SetPlayerTime(playerid,minute,seconds);
return 1;
}
//--------------------------------------------------
public OnPlayerDeath(playerid, killerid, reason)
{
TextDrawHideForPlayer(playerid,txtTimeDisp);
return 1;
}
//--------------------------------------------------
public OnPlayerConnect(playerid)
{
gettime(hour, minute, seconds);
SetPlayerTime(playerid,minute,seconds);
return 1;
}
//--------------------------------------------------

 

je to real time jen sem se pokoušl změnit ty hodnoty....

Link to comment
Share on other sites

5 odpovědí na tuto otázku

Recommended Posts

  • 0

a mužu se zeptat kde ? :d já to nemohl najít :)

Nekde tam uz nevim presne

Funguje to na principu, ze si ten cas musis stejnak pocitat do promenych a vzdy v OnPlayerStateChange(ktery se vyvola pri spawnu - kde se posouva cas) vzdy mu prenastavit cas pomoci SetPlayerTime

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...