Szerző Téma: Time  (Megtekintve 500 alkalommal)

Nem elérhető ZSOLTI99

  • 1827
    • Profil megtekintése
Time
« Dátum: 2013. április 07. - 18:28:40 »
0 Show voters
Üdv. Valaki meg tudná csinálni hogy a másodpercet is ki írja Óra/perc/másodperc?? Így szeretném ha valaki tud segíteni!
 
//
// 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)
//
//  Kye 2009
#include <a_samp>
#pragma tabsize 0
//--------------------------------------------------
new Text:txtTimeDisp;
new hour, minute;
new timestr[32];
forward UpdateTime();
//--------------------------------------------------
 
public UpdateTime()
{
    gettime(hour, minute);
      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++;
}
}
//--------------------------------------------------
public OnGameModeInit()
{
// Init our text display
txtTimeDisp = TextDrawCreate(605.0,25.0,\"00:00\");
TextDrawUseBox(txtTimeDisp, 0);
TextDrawFont(txtTimeDisp, 2);
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);
UpdateTime();
SetTimer(\"UpdateTime\",1000 * 60,1);
return 1;
}
//--------------------------------------------------
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid,txtTimeDisp);
gettime(hour, minute);
SetPlayerTime(playerid,hour,minute);
return 1;
}
//--------------------------------------------------
public OnPlayerDeath(playerid, killerid, reason)
{
    TextDrawHideForPlayer(playerid,txtTimeDisp);
return 1;
}
//--------------------------------------------------
public OnPlayerConnect(playerid)
{
    gettime(hour, minute);
    SetPlayerTime(playerid,hour,minute);
    return 1;
}
//--------------------------------------------------

Nem elérhető kos

  • 292
    • Profil megtekintése
Time
« Válasz #1 Dátum: 2013. április 07. - 19:14:08 »
0 Show voters
Hello!
Én még régebben így írtam meg.
Alakítsad át ahogyan akarod :)
 

//valahova mód elejére
new Text:Time[MAX_PLAYERS], Text:Date[MAX_PLAYERS];
        //ez az OnPlayerConnect alá
        Date[playerid] = TextDrawCreate(2.000000,438.000000,\"--\");
TextDrawFont(Date[playerid],1);
TextDrawColor(Date[playerid],0xFFFF00AA);
TextDrawLetterSize(Date[playerid],0.35,1.000000);
TextDrawSetOutline(Date[playerid],1);
TextDrawSetShadow(Date[playerid],1);
TextDrawSetProportional(Date[playerid],1);
TextDrawBackgroundColor(Date[playerid],0x000000ff);
Time[playerid] = TextDrawCreate(100.000000,438.000000,\"--\");
TextDrawFont(Time[playerid],1);
TextDrawColor(Time[playerid],0xFFFF00AA);
TextDrawLetterSize(Time[playerid],0.35,1.000000);
TextDrawSetOutline(Time[playerid],1);
TextDrawSetShadow(Time[playerid],1);
TextDrawSetProportional(Time[playerid],1);
TextDrawBackgroundColor(Time[playerid],0x000000ff);
        SetTimerEx(\"settime\", 1000, true, \"i\", playerid);
//OnPlayerDisconnect alá
TextDrawHideForPlayer(playerid, Time[playerid]), TextDrawHideForPlayer(playerid, Date[playerid]);
//OnPlayerSpawn alá
TextDrawShowForPlayer(playerid, Time[playerid]), TextDrawShowForPlayer(playerid, Date[playerid]);
//új public
forward settime(playerid);
public settime(playerid)
{
new string[256],year,month,day,hours,minutes,seconds;
getdate(day, month, year), gettime(hours, minutes, seconds);
format(string, sizeof string, \"Idõ:%d/%s%d/%s%d\", day, ((month < 10) ? (\"0\") : (\"\")), month, (year < 10) ? (\"0\") : (\"\"), year);
TextDrawSetString(Date[playerid], string);
format(string, sizeof string, \"%s%d:%s%d:%s%d\", (hours < 10) ? (\"0\") : (\"\"), hours, (minutes < 10) ? (\"0\") : (\"\"), minutes, (seconds < 10) ? (\"0\") : (\"\"), seconds);
TextDrawSetString(Time[playerid], string);
}

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal