[Consulta] Como Fijar El Tiempo como en el video
#8

pawn Код:
#include <a_samp>

#define Hora_Inicial (3)
#define Minutos_Inicial (30)
#define Segundos_Inicial (0)
/*
  El Reloj iniciara en  : 03:30:00 y ira bajando hasta llegar a 00:00:00
*/

new
   Text:Tiempo
;
new
   Horas=Hora_Inicial,
   Minutos=Minutos_Inicial,
   Segundos=Segundos_Inicial
;

public OnFilterScriptInit()
{
    Tiempo = TextDrawCreate(605.0,25.0,"_");
    TextDrawUseBox(Tiempo, 0);
    TextDrawFont(Tiempo, 3);
    TextDrawSetShadow(Tiempo,0);
    TextDrawSetOutline(Tiempo,2);
    TextDrawBackgroundColor(Tiempo,-1);
    TextDrawColor(Tiempo,-1);
    TextDrawAlignment(Tiempo,3);
    TextDrawLetterSize(Tiempo,0.5,1.5);
    SetTimer("UpdateTime",1000*60,true);
    return 1;
}

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

forward UpdateTime();
public UpdateTime()
{
    Segundos++;
    if(Segundos >= 60)
    {      
        Minutos--;
                Segundos=0;
    }
    if(Minutos >= 60)
    {
        Horas--;
                Segundos=0;
    }
    if(Horas == 0 && Minutos == 0 && Segundos == 0)
    {
           Segundos=0;
       //Aca Funcion al quedar el reloj en 00:00:00
    }
    new str[30];
    format(str,32,"%02d:%02d:%02d",Horas,Minutos,Segundos);
    TextDrawSetString(Tiempo,str);
    return 1;
}
pawn Код:
#include <a_samp>

#define Hora_Inicial (3)
#define Minutos_Inicial (30)
#define Segundos_Inicial (0)
/*
  El Reloj iniciara en  : 03:30:00 y ira bajando hasta llegar a 00:00:00
*/

new
   Text:Tiempo[MAX_PLAYERS]
;
new
   ChauTiempo[MAX_PLAYERS]
;
new
   Horas[MAX_PLAYERS]=Hora_Inicial,
   Minutos[MAX_PLAYERS]=Minutos_Inicial,
   Segundos[MAX_PLAYERS]=Segundos_Inicial
;

public OnPlayerConnect(playerid)
{
    Tiempo[playerid] = TextDrawCreate(605.0,25.0,"_");
    TextDrawUseBox(Tiempo[playerid], 0);
    TextDrawFont(Tiempo[playerid], 3);
    TextDrawSetShadow(Tiempo[playerid],0);
    TextDrawSetOutline(Tiempo[playerid],2);
    TextDrawBackgroundColor(Tiempo[playerid],-1);
    TextDrawColor(Tiempo[playerid],-1);
    TextDrawAlignment(Tiempo[playerid],3);
    TextDrawLetterSize(Tiempo[playerid],0.5,1.5);
    ChauTiempo[playerid] = SetTimerEx("UpdateTime", 1000*60, true, "i", playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid,Tiempo[playerid]);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    TextDrawHideForPlayer(playerid,Tiempo[playerid]);
    TextDrawDestroy(Tiempo[playerid]);
    KillTimer(ChauTiempo[playerid]);
    return 1;
}

forward UpdateTime(playerid);
public UpdateTime(playerid)
{
    Segundos[playerid]++;
    if(Segundos[playerid] >= 60)
    {
        Minutos[playerid]--;
                Segundos[playerid]=0;
    }
    if(Minutos[playerid] >= 60)
    {
        Horas[playerid]--;
                Segundos[playerid]=0;
    }
    if(Horas[playerid] == 0 && Minutos[playerid] == 0 && Segundos[playerid] == 0)
    {
                Segundos[playerid]=0;
       //Aca Funcion al quedar el reloj en 00:00:00
    }
    new str[30];
    format(str,32,"%02d:%02d:%02d",Horas[playerid],Minutos[playerid],Segundos[playerid]);
    TextDrawSetString(Tiempo[playerid],str);
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)