Jump to content

[REZOLVAT] TIMER!


SorinDivoiu
 Share

Recommended Posts

Username: Senno
Problema întălnită: TIMER.
Detalii despre problemă:Deci, eu vreau sa fac un timer pentru fiecare jucator si nu-mi iese, as vrea sa fac un sistem ca pe ruby  (cel cu stupii), si dupa cum stiti ei au un timer mic intr-un colt si-ti spune exact cate minute mai sunt pana iti poti ridica mierea. Un timer din acesta as vrea si eu. Sistemul este gata, doar timer-ul mai am sa-l fac si habar n-am cum.
Ce ai încercat să faci înainte să postezi?: Incerc de aseara sa-i tot dau de cap si nu pot.
Cod sursă (recomandat pastebin.com) :https://pastebin.com/2Vbfj7a5
Alte detalii: Am pus pChestie si 'mesaj' deoarece sunt unii 'scripteri' si dupa spun ca e ideea lor originala.

Edited by SorinDivoiu
Link to comment
Share on other sites

Foloseste-te de YSI Timers (y_timers).

ptask UpdateTime[1000](playerid) 
{
    foreach(Player, i)
    {
        new Str[34];
        TimeS --;
        if(PlayerInfo[playerid][pChestie] == 1)
        {
 
            if(TimeM == 0 && TimeS == 0)
            {  
                PlayerInfo[playerid][pChestie] = 0;
                SendClientMessage(playerid, -1, "mesaj");
                PlayerTextDrawDestroy(playerid, Textdraw0);  
                KillTimer(Time);
            }
            if(TimeS == -1)
            {
                TimeM--;
                TimeS = 59;
            }
            if(TimeS<10)
            {
              format(Str, sizeof(Str), "%d:0%d", TimeM, TimeS);
            }
            if(TimeS>9)
            {
              format(Str, sizeof(Str), "%d:%d", TimeM, TimeS);
            }
        }
    }  
    return 1;	
}

P.S: cand a facut prima tura sa se porneasca timer-ul prin "defer UpdateTime(playerid);"

Edited by qRuby.

XNgeArL.png

GKmys99.png?1

Link to comment
Share on other sites

1 oră în urmă, qRuby. a spus:

Foloseste-te de YSI Timers (y_timers).


ptask UpdateTime[1000](playerid) 
{
    foreach(Player, i)
    {
        new Str[34];
        TimeS --;
        if(PlayerInfo[playerid][pChestie] == 1)
        {
 
            if(TimeM == 0 && TimeS == 0)
            {  
                PlayerInfo[playerid][pChestie] = 0;
                SendClientMessage(playerid, -1, "mesaj");
                PlayerTextDrawDestroy(playerid, Textdraw0);  
                KillTimer(Time);
            }
            if(TimeS == -1)
            {
                TimeM--;
                TimeS = 59;
            }
            if(TimeS<10)
            {
              format(Str, sizeof(Str), "%d:0%d", TimeM, TimeS);
            }
            if(TimeS>9)
            {
              format(Str, sizeof(Str), "%d:%d", TimeM, TimeS);
            }
        }
    }  
    return 1;	
}

P.S: cand a facut prima tura sa se porneasca timer-ul prin "defer UpdateTime(playerid);"

Mersi de ajutor, o sa incerc chiar acum.

Link to comment
Share on other sites

  • Administrator

????

 

De ce ai face un foreach intr-un timer per player? ... nu-i logic ca e apelat la fiecare jucator in parte?

Pentru a face un timer mai usor, foloseste-te de libraria YSI, mai exact de include-ul y_timers.

 

ptask onPlayerSecondTimer[ 1000 ]( playerid ) 
{
    // your code
    return true;
}

 

Link to comment
Share on other sites

Acum 5 ore, qRuby. a spus:

Foloseste-te de YSI Timers (y_timers).


ptask UpdateTime[1000](playerid) 
{
    foreach(Player, i)
    {
        new Str[34];
        TimeS --;
        if(PlayerInfo[playerid][pChestie] == 1)
        {
 
            if(TimeM == 0 && TimeS == 0)
            {  
                PlayerInfo[playerid][pChestie] = 0;
                SendClientMessage(playerid, -1, "mesaj");
                PlayerTextDrawDestroy(playerid, Textdraw0);  
                KillTimer(Time);
            }
            if(TimeS == -1)
            {
                TimeM--;
                TimeS = 59;
            }
            if(TimeS<10)
            {
              format(Str, sizeof(Str), "%d:0%d", TimeM, TimeS);
            }
            if(TimeS>9)
            {
              format(Str, sizeof(Str), "%d:%d", TimeM, TimeS);
            }
        }
    }  
    return 1;	
}

P.S: cand a facut prima tura sa se porneasca timer-ul prin "defer UpdateTime(playerid);"

Aici ai creat un timer care pentru fiecare player va executa un loop prin toti playerii.

@SorinDivoiu foloseste exemplul lui Leonard.

Respecta si vei fi respectat.

 

BigInt Pawn:

Pacman C++: 

Snake C++:

Minesweeper C++:

 

mattbb.cash

leaks.ro

Link to comment
Share on other sites

  • Administrator
Acum 5 ore, qRuby. a spus:

Foloseste-te de YSI Timers (y_timers).


ptask UpdateTime[1000](playerid) 
{
    foreach(Player, i)
    {
        new Str[34];
        TimeS --;
        if(PlayerInfo[playerid][pChestie] == 1)
        {
 
            if(TimeM == 0 && TimeS == 0)
            {  
                PlayerInfo[playerid][pChestie] = 0;
                SendClientMessage(playerid, -1, "mesaj");
                PlayerTextDrawDestroy(playerid, Textdraw0);  
                KillTimer(Time);
            }
            if(TimeS == -1)
            {
                TimeM--;
                TimeS = 59;
            }
            if(TimeS<10)
            {
              format(Str, sizeof(Str), "%d:0%d", TimeM, TimeS);
            }
            if(TimeS>9)
            {
              format(Str, sizeof(Str), "%d:%d", TimeM, TimeS);
            }
        }
    }  
    return 1;	
}

P.S: cand a facut prima tura sa se porneasca timer-ul prin "defer UpdateTime(playerid);"

 

Bravo coaie.

Edited by Leonard
=))))))))))))))))))))))))))))))))
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...