textdraw bug -
stix - 23.12.2010
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:
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;
}
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 ?
Re: textdraw bug -
Steven82 - 23.12.2010
gettime function
getdate function
GetPlayerTime function
Above links are wiki topics. Check them out and read them. I just used them today to make my chat logging system so i know they work.
Re: textdraw bug -
stix - 23.12.2010
it gets the server time
not in game time
it will get the server time, IRL time where it is being hosted
Re: textdraw bug -
Steven82 - 23.12.2010
Yes the gettime function will get the servers IRL time. And the servers IRL date if you use the getdate function.
Re: textdraw bug -
stix - 23.12.2010
yes but how i make so each time player logs on it says the actual server IG instead IRL 6:30 ?
Re: textdraw bug -
Alice[WS] - 23.12.2010
Hello !
First you should replace your VClock function, i haven't tested but it shouldn't change of what you currently use.
pawn Код:
forward VClock(playerid);
public VClock(playerid)
{
Vminute++;
if(Vminute >= 60)
{
Vminute = 0;
Vhour++;
if(Vhour >= 24)
{
Vhour = 0;
SetWorldTime(Vhour);
}
}
new string[20];
format(string,sizeof(string),"%d:%.02d %s",Vhour,Vminute,(Vhour >= 12) ? ("PM") : ("AM"));
TextDrawSetString(VClockTD,string);
return 1;
}
For the bug, you should check if there isn't a "ToggleVClock(toggle)" in the public OnPlayerConnect(playerid).
Re: textdraw bug -
stix - 23.12.2010
pawn Код:
public OnFilterScriptInit()
{
SetWorldTime(6);
Vhour = 6;
Vminute = 30;
SetTimer("VClock", 30000, true);
ToggleVClock(1);
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;
}
forward VClock(playerid);
public VClock(playerid)
{
Vminute++;
if(Vminute >= 60)
{
Vminute = 0;
Vhour++;
if(Vhour >= 24)
{
Vhour = 0;
SetWorldTime(Vhour);
}
}
new string[20];
format(string,sizeof(string),"%d:%.02d %s",Vhour,Vminute,(Vhour >= 12) ? ("PM") : ("AM"));
TextDrawSetString(VClockTD,string);
return 1;
}
}
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;
}
return 1;
}
i made it but now the textdraw doesnt shows up :S
Re: textdraw bug -
Alice[WS] - 23.12.2010
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;
}
public OnFilterScriptInit()
{
ToggleVClock(1);
return 1;
}
public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid,VClockTD)
return 1;
}
forward VClock(playerid);
public VClock(playerid)
{
Vminute++;
if(Vminute >= 60)
{
Vminute = 0;
Vhour++;
if(Vhour >= 24)
{
Vhour = 0;
SetWorldTime(Vhour);
}
}
new string[20];
format(string,sizeof(string),"%d:%.02d %s",Vhour,Vminute,(Vhour >= 12) ? ("PM") : ("AM"));
TextDrawSetString(VClockTD,string);
return 1;
}
What happen if you do it ?
Re: textdraw bug -
stix - 23.12.2010
the textdraw doesnt shows up at the corner, its like nothing happens
Re: textdraw bug -
Alice[WS] - 23.12.2010
pawn Код:
TextDrawShowForPlayer(playerid,VClockTD);