[Ajuda] Hora da Hospedagem Errada
#6

PHP код:
//
// 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)
//
//  © 2009-2012 SA-MP Team

#include <a_samp>
#pragma tabsize 0

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

new Text:txtTimeDisp;
new 
hourminute;
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 95SetWeather(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
    
gettime(hourminute);
   
       
format(timestr,32,"%02d:%02d",hour,minute);
       
TextDrawSetString(txtTimeDisp,timestr);
       
SetWorldTime(hour);
       
    new 
x=0;
    while(
x!=MAX_PLAYERS) {
        if(
IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE) {
            
SetPlayerTime(x,hour,minute);
         }
         
x++;
    }

    
/* Update weather every hour
    if(last_weather_update == 0) {
        UpdateWorldWeather();
    }
    last_weather_update++;
    if(last_weather_update == 60) {
        last_weather_update = 0;
    }*/
}

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

public OnGameModeInit()
{
    
// Init our text display
    
txtTimeDisp TextDrawCreate(605.0,25.0,"00:00");
    
TextDrawUseBox(txtTimeDisp0);
    
TextDrawFont(txtTimeDisp3);
    
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",1000 60,1);

    return 
1;
}

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

public OnPlayerSpawn(playerid)
{
    
TextDrawShowForPlayer(playerid,txtTimeDisp);
    
    
gettime(hourminute);
    
SetPlayerTime(playerid,hour,minute);
    
    return 
1;
}

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

public OnPlayerDeath(playeridkilleridreason)
{
    
TextDrawHideForPlayer(playerid,txtTimeDisp);
     return 
1;
}

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

public OnPlayerConnect(playerid)
{
    
gettime(hourminute);
    
SetPlayerTime(playerid,hour,minute);
    return 
1;
}

//-------------------------------------------------- 
Reply


Messages In This Thread
Hora da Hospedagem Errada - by OrNot - 13.02.2014, 21:37
Re: Hora da Hospedagem Errada - by ProKillerpa - 13.02.2014, 21:49
Re: Hora da Hospedagem Errada - by pWesley - 13.02.2014, 21:49
Re: Hora da Hospedagem Errada - by Leopawno - 13.02.2014, 22:07
Re: Hora da Hospedagem Errada - by demonneni - 13.02.2014, 22:11
Re: Hora da Hospedagem Errada - by OrNot - 13.02.2014, 22:14
Re: Hora da Hospedagem Errada - by OrNot - 13.02.2014, 22:21
Re: Hora da Hospedagem Errada - by Samuel300 - 13.02.2014, 22:32
Re: Hora da Hospedagem Errada - by OrNot - 13.02.2014, 23:28

Forum Jump:


Users browsing this thread: 1 Guest(s)