Display time not working
#1

Код:
// 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.
Reply
#2

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?
Reply
#3

No. What should i put?
Reply
#4

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

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);
Reply
#6

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.
Reply
#7

Bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)