SA-MP Forums Archive
Display time not working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Display time not working (/showthread.php?tid=287169)



Display time not working - [GOD]Dragonster82 - 02.10.2011

Код:
// Time
Game mode init:
Tsec= 0;
THrs= 0;
SetTimer("TimeU",1000,true);
return 1;
}
forward TimeU();
public TimeU()
{
new string[128];
Tsec+=1;
if(Tsec==60)
{
Tsec=00;
THrs+=1;
}
if(THrs==24)
{
Tsec=00;
THrs=0;
}
if(Tsec<10)
{
format(string,sizeof(string),"%d:%d0",THrs,Tsec);


}
if(Tsec>10)
{
format(string,sizeof(string),"%d:%d",THrs,Tsec);


}
if(THrs<10)
{
format(string,sizeof(string),"0%d:%d",THrs,Tsec);


}
for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
        SetPlayerTime(i,THrs,Tsec);
        Servt=TextDrawCreate(545, 31, "00:00");
        TextDrawColor(Servt, COLOR_WHITE);
        }
        }
Servt=TextDrawCreate(545, 31, "00:00"); and TextDrawColor(Servt, COLOR_WHITE); can compile perfectly but it doesn't displays the time.


Re: Display time not working - Pharrel - 02.10.2011

pawn Код:
if(IsPlayerConnected(i)) {
on game mode init nobody is connected...

@edit ignore my comment...wait a little... i didnt read the whole code...

@edit 2... did you put TextDrawShowForPlayer when he connect or log in? and TextDrawHideForPlayer when he disconnect?


Re: Display time not working - [GOD]Dragonster82 - 02.10.2011

No. What should i put?


Re: Display time not working - [MWR]Blood - 02.10.2011

You are formatting the string, but you aren't using it anywhere.
https://sampwiki.blast.hk/wiki/TextDrawSetString


Re: Display time not working - Pharrel - 02.10.2011

pawn Код:
//GM top
new Servt;

//OnGameModeInit
for(new i=0; i<MAX_PLAYERS; i++)
{
    Servt = TextDrawCreate(545, 31, "00:00");
    TextDrawColor(Servt, COLOR_WHITE);
}

forward TimeU();
public TimeU()
{
    new hr,min,sec,string[10];
    gettime(hr,min,sec);
    #pragma unused sec
    format(string, 10,"%02d:%02d",hr,min);
    TextDrawSetString(Servt,string);
}

//onplayerconnect
TextDrawShowForPlayer(playerid, Servt);

//onplayerdisconnect
TextDrawHideForPlayer(playerid, Servt);



Re: Display time not working - [GOD]Dragonster82 - 02.10.2011

Well, but i don't see how this is NOT working ( OnPlayer Connect and Disconnect is added, thank you )
And...
I am using the server-sided time for end round , so yeah.
Код:
public TimeU()
{
new string[128];
Tsec+=1;
if(Tsec==60)
{
Tsec=00;
THrs+=1;
}
if(THrs==24)
{
Tsec=00;
THrs=0;
}
if(Tsec<10)
{
format(string,sizeof(string),"%d:%d0",THrs,Tsec);


}
if(Tsec>10)
{
format(string,sizeof(string),"%d:%d",THrs,Tsec);


}
if(THrs<10)
{
format(string,sizeof(string),"0%d:%d",THrs,Tsec);


}
for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
        SetPlayerTime(i,THrs,Tsec);
        Servt=TextDrawCreate(545, 31, "00:00");
        TextDrawColor(Servt, COLOR_WHITE);
        }
        }
TextDrawSetString(Servt,string);
if(THrs==23 && Tsec==59)
{
SendClientMessageToAll(COLOR_LIGHTBLUE,"Round Of The Day Ended");
if(Gscore>Pscore)
{
SendClientMessageToAll(COLOR_LIGHTBLUE,"Winner Of Today's Round: Team Gangs.");
GameTextForAll("~bl~Team Gangs\nWins",4000,3);
}
if(Gscore<Pscore)
{
SendClientMessageToAll(COLOR_LIGHTBLUE,"Winner Of Today's Round: Team Police.");
GameTextForAll("~bl~Team Police\nWins",4000,3);
}
if(Gscore==Pscore)
{
SendClientMessageToAll(COLOR_LIGHTBLUE,"Winner of Today's Round: Nobody.");
GameTextForAll("~bl~Nobody\nWins",4000,3);
Edit:
Time is showing, but it is not moving.


Re: Display time not working - [GOD]Dragonster82 - 02.10.2011

Bump.