Jump to content
  • 0

pomoc Časovač?


snake3321

Dotaz

Zdravím,

mám zde menší dotaz. Jedná se o to, že si dělám takové malé vězení a potřebuji udělat Timer na 30 sekund, to by ještě šlo. Ale potřebuji udělat čas tak, aby byl někde vidět, například do GameTextForPlayer, ovšem potřebuji, aby za každou sekundu tam naběhlo o sekundu méně a nechci dělat 30 timerů, jak bych si to mohlo ulehčit? Předem děkuji.

Link to comment
Share on other sites

4 odpovědí na tuto otázku

Recommended Posts

  • 0
  • Globální moderátor

new cas = 30;

 

 

funkce timeru:

 

cas--; 

//updatovat textdraw

 

if(cas == 0) //akce po uplynuti casu

Link to comment
Share on other sites

  • 0


#include < a_samp >

 

new g_iJailTimer[ MAX_PLAYERS ] = 0;

 

public OnPlayerDisconnect( playerid, reason ) // vložiť do funkcie na player disconnect..

{

    g_iJailTimer[ playerid ] = 0;

    DajMiJailTimer( playerid, 60 );

}

 

stock DajMiJailTimer( playerid, seconds )

{ // celkový čas ktorý sa bude odpočítavať sa zadáva v sekundách..

    if( !IsPlayerConnected( playerid ) || ( seconds <= 0 ) )

    {

        return 0;

    }

    g_iJailTimer[ playerid ] = seconds;

    SetTimerEx( "task_JailOdpocet", 1000, false, "i", playerid );

    return 1;

}

 

forward task_JailOdpocet( playerid );

public task_JailOdpocet( playerid )

{

    if( g_iJailTimer[ playerid ] != 0 )

    {

        new iTime = g_iJailTimer[ playerid ];

        g_iJailTimer[ playerid ]--;

        new string[ 16 ];

        format( string, 16, "%02d:%02d", ( iTime / 60 ), ( iTime % 60 ) ); // Čas minuty:sekundy (00:00) vypočítané zo sekúnd..

    //        sem textdraw alebo nejaky text..

        SetTimerEx( "task_JailOdpocet", 1000, false, "i", playerid );

    }

    return 1;

}
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...