Jump to content
  • 0

Question

Posted

Salutare ! Am si eu o problema cu ora pe server . Am comanda /time care imi arata ora , si am si un ceas facut de mine . Eh , problema e ca , spre exemplu , acum e ora 19 , pe server imi arata ora 9 si minutele le indica corect , codul de la ceas este acesta  : 

ceas si data : 

#include <a_samp>
#define FILTERSCRIPT

new Text:Time, Text:Date;

forward settime(playerid);

public OnFilterScriptInit()
{
        print("\n--------------------------------------");
        print("Yamato");
        print("--------------------------------------\n");

        SetTimer("settime",1000,true);

        Date = TextDrawCreate(547.000000,11.000000,"--");
        TextDrawFont(Date,3);
        TextDrawLetterSize(Date,0.399999,1.600000);
        TextDrawColor(Date,0xffffffff);

        Time = TextDrawCreate(547.000000,28.000000,"--");
        TextDrawFont(Time,3);
        TextDrawLetterSize(Time,0.399999,1.600000);
        TextDrawColor(Time,0xffffffff);
        return 1;
}

public OnFilterScriptExit()
{
        print("\n-----------------------------------------------------");
        print("Yamato");
        print("-----------------------------------------------------/n");
        return 1;
}

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

public OnPlayerDisconnect(playerid, reason)
{
        TextDrawHideForPlayer(playerid, Time), TextDrawHideForPlayer(playerid, Date);
        return 1;
}

public settime(playerid)
{
        new string[256],year,month,day,hours,minutes;
        getdate(year, month, day), gettime(hours, minutes);
        format(string, sizeof string, "%d/%s%d/%s%d", day, ((month < 10) ? ("0") : ("")), month, (year < 10) ? ("0") : (""), year);
        TextDrawSetString(Date, string);
        format(string, sizeof string, "%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (minutes < 10) ? ("0") : (""), minutes);
        TextDrawSetString(Time, string);
}
  

  
  
  
  si comanda /time : 
  
 if(strcmp(cmd, "/time", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
		    new mtext[20];
			new year, month,day;
			getdate(year, month, day);
			if(month == 1) { mtext = "January"; }
			else if(month == 2) { mtext = "February"; }
			else if(month == 3) { mtext = "March"; }
			else if(month == 4) { mtext = "April"; }
			else if(month == 5) { mtext = "May"; }
			else if(month == 6) { mtext = "June"; }
			else if(month == 7) { mtext = "Juli"; }
			else if(month == 8) { mtext = "August"; }
			else if(month == 9) { mtext = "September"; }
			else if(month == 10) { mtext = "October"; }
			else if(month == 11) { mtext = "November"; }
			else if(month == 12) { mtext = "December"; }
		    new hour,minuite,second;
			gettime(hour,minuite,second);
			FixHour(hour);
			hour = shifthour;
			if (minuite < 10)
			{
				if (PlayerInfo[playerid][pJailTime] > 0)
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
				}
				else
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|", day, mtext, hour, minuite);
				}
			}
			else
			{
				if (PlayerInfo[playerid][pJailTime] > 0)
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
				}
				else
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|", day, mtext, hour, minuite);
				}
			}
			GameTextForPlayer(playerid, string, 5000, 1);
		}
		return 1;
	} 

Cum pot rezolva , am nevoie neaparat , Multumesc Frumos ! 

15 answers to this question

Recommended Posts

  • 0
  • Administrator
Posted

In loc de %s%d:%s%d poti folosi %02d:%02d. Poti sa-i dai un printf sa vezi ce este in variabila hours?

  • 0
Posted (edited)

Poftim : 

Capture.JPG

Sa stii ca poza e facuta chiar acum , deci normal ar trebuii sa arate 20:31 

 

Edited by Yamato
completare
  • 0
  • Administrator
Posted

Nu mai face asta

(hours < 10) ? ("0") : ("")(hours < 10) ? ("0") : ("")

foloseste %02d daca vrei sa afisezi cu 00, 01, 02, etc.. Ce ai aratat in poza este pe un server sau la tine ine PC?

  • 0
Posted (edited)

este pe server-ul localhost unde scriptez eu , cum adica sa folosesc %02d ? 

Edited by Yamato
  • 0
Posted (edited)
8 minutes ago, WopsS said:

In loc de %s%d:%s%d poti folosi %02d:%02d. Poti sa-i dai un printf sa vezi ce este in variabila hours?

dispui de skype sa vorbim acolo ? (nu stiu cum se da acel printf)

Edited by Yamato
  • 0
Posted (edited)
13 minutes ago, WopsS said:

hai ca incerc sa fac cum ai spus cu  %02d:%02d , sa vad daca reusesc

EDIT : degeaba , nu functioneaza , problema cred ca e mult mai amanuntita , deoarece face asta si la /time .. 

Edited by Yamato
  • 0
  • Administrator
Posted
9 minutes ago, Yamato said:

hai ca incerc sa fac cum ai spus cu  %02d:%02d , sa vad daca reusesc

EDIT : degeaba , nu functioneaza , problema cred ca e mult mai amanuntita , deoarece face asta si la /time .. 

Ce iti arata la printf?

  • 0
Posted
1 minute ago, WopsS said:

Ce iti arata la printf?

eu doar am inlocuit , ca sa fac printf cum anume trb sa arate , nu am lucrat niciodata cu asa ceva .... 

  • 0
  • Administrator
Posted

Cam asa trebuie sa arate

printf("%02i:%02i", hour, minutes);

Vezi ca ai scris gresit minuite.

  • Upvote 1
  • 0
Posted

format(string, sizeof string, "%02d:%02d", hours, minutes);

 

Cred ca e corect, sunt pe telefon si nu-mi prea dau seama ce ai acolo.

  • Upvote 1

242086.png

  • 0
Posted (edited)
9 hours ago, WopsS said:

Cam asa trebuie sa arate


printf("%02i:%02i", hour, minutes);

Vezi ca ai scris gresit minuite.

La acest printf arata asa 

Untitled-1.jpg

Quote

format(string, sizeof string, "%02d:%02d", hours, minutes);

 

Cred ca e corect, sunt pe telefon si nu-mi prea dau seama ce ai acolo.

Ce mi-ai dat tu , la fel arata in joc , ora 23:39 , ora nu o arata bine , minutele sunt corecte , nu imi pot imagina ce o fi

Edited by Yamato
  • 0
Posted (edited)
Acum 2 ore, Yamato a spus:

La acest printf arata asa 

Untitled-1.jpg

Ce mi-ai dat tu , la fel arata in joc , ora 23:39 , ora nu o arata bine , minutele sunt corecte , nu imi pot imagina ce o fi

Stai asa, tu zici c-arata 23 in loc de 11? La calculator ti-o arata in format 12 AM/PM, serverul o afiseaza in format de 24 ore.

Tu ai ora pc-ului 11:39 PM(adica seara), normal ca arata 23.

Edited by Ksenon
  • Upvote 1
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.