23.12.2010, 00:22
ok i got a kinda real life time which means 30 seconds irl = 1 in game minute
but i dont know, each time someone logs on the time sets back to 6:30 and the textdraw totally fucks up
i think its SAMP bug and not scripting bug, but anyway can someone help me
code:
Edit: OK, i fixed the time, but can someone tell me how to fix so each time the player spawns actuals game time shows up instead 6:30 ?
but i dont know, each time someone logs on the time sets back to 6:30 and the textdraw totally fucks up
i think its SAMP bug and not scripting bug, but anyway can someone help me
code:
pawn Код:
new Text:VClockTD;
new Vhour, Vminute;
stock ToggleVClock(toggle)
{
if(toggle == 1)
{
VClockTD = TextDrawCreate(546.000000,23.000000,"6:30 AM");
TextDrawAlignment(VClockTD,0);
TextDrawBackgroundColor(VClockTD,0x000000ff);
TextDrawFont(VClockTD,3);
TextDrawLetterSize(VClockTD,0.299999,1.600000);
TextDrawColor(VClockTD,0xFFFFFFFF);
TextDrawSetProportional(VClockTD,1);
TextDrawSetShadow(VClockTD,1);
TextDrawShowForAll(VClockTD);
SetTimer("VClock", 30000, true);
SetWorldTime(6);
Vhour = 6;
Vminute = 30;
}
return 0;
}
stock SetVClockTime(hour, minute)
{
Vhour = hour; Vminute = minute;
return 0;
}
forward VClock(playerid);
public VClock(playerid)
{
Vminute++; if(Vminute >= 60)
{
Vminute = 0;
Vhour++;
}
if(Vhour == 23 && Vminute == 59)
{
Vhour = 0;
Vminute = 0;
}
new string[178];
if(Vminute>=10)
{
if(Vhour >= 12 && Vhour <= 23 && Vminute <= 59)
{
format(string,sizeof(string),"%d:%d PM",Vhour,Vminute);
TextDrawSetString(VClockTD,string);
}
if(Vhour >= 0 && Vhour <= 11 && Vminute <= 59)
{
format(string,sizeof(string),"%d:%d AM",Vhour,Vminute);
TextDrawSetString(VClockTD,string);
}
}
if(Vminute<10)
{
if(Vhour >= 12 && Vhour <= 23 && Vminute <= 59)
{
format(string,sizeof(string),"%d:0%d PM",Vhour,Vminute);
TextDrawSetString(VClockTD,string);
}
if(Vhour >= 0 && Vhour <= 11 && Vminute <= 59)
{
format(string,sizeof(string),"%d:0%d AM",Vhour,Vminute);
TextDrawSetString(VClockTD,string);
}
}
if(Vhour == 0) return SetWorldTime(0);
if(Vhour == 1) return SetWorldTime(1);
if(Vhour == 2) return SetWorldTime(2);
if(Vhour == 3) return SetWorldTime(3);
if(Vhour == 4) return SetWorldTime(4);
if(Vhour == 5) return SetWorldTime(5);
if(Vhour == 6) return SetWorldTime(6);
if(Vhour == 7) return SetWorldTime(7);
if(Vhour == 8) return SetWorldTime(8);
if(Vhour == 9) return SetWorldTime(9);
if(Vhour == 10) return SetWorldTime(10);
if(Vhour == 11) return SetWorldTime(11);
if(Vhour == 12) return SetWorldTime(12);
if(Vhour == 13) return SetWorldTime(13);
if(Vhour == 14) return SetWorldTime(14);
if(Vhour == 15) return SetWorldTime(15);
if(Vhour == 16) return SetWorldTime(16);
if(Vhour == 17) return SetWorldTime(17);
if(Vhour == 18) return SetWorldTime(18);
if(Vhour == 19) return SetWorldTime(19);
if(Vhour == 20) return SetWorldTime(20);
if(Vhour == 21) return SetWorldTime(21);
if(Vhour == 22) return SetWorldTime(22);
if(Vhour == 23) return SetWorldTime(23);
return 1;
}