SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese > Lançamentos/Releases

Reply
 
Thread Tools Display Modes
Old 25/12/2011, 11:02 PM   #21
SlashPT
High-roller
 
SlashPT's Avatar
 
Join Date: Sep 2009
Location: Hell
Posts: 2,071
Reputation: 107
Default Re: SetTimer

Quote:
Originally Posted by dMagnus View Post
Simples, mas útil...

...
Exemplo:
pawn Code:
...

Também podemos usar um timer, para fazer uma contagem!

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/contar", cmdtext, true, 10) == 0)
    {
        printf("3");
        SetTimer("contar2",1000, false);// False pois não queremos que este timer fique repetindo constatemente.
        return 1;
    }
    return 0;
}

forward contar2();
public contar2()
{
    printf("2");
    SetTimer("contar1",1000, false); // Chamará o timer congar1
    return 1;
}
forward contar1();
public contar1()
{
    printf("1");
    SetTimer("contargo", 1000, false); // Chamará o timer
    return 1;
}
forward contargo();
public contargo()
{
    printf("Go");
    return 1;
}

...
Eish jasus que trabalhao para fazer uma coisa tao simples, nao te esqueças que o settimerex existe para alguma coisa...


pawn Code:
public
    OnPlayerCommandText ( playerid , cmdtext [ ] )
{
    if ( strcmp ( "/contar" , cmdtext , true , 8 ) == 0 )
    {
        print ( "3" ) ;
        SetTimerEx ( "Contar" , 1000 , false , "i" , 3 ) ;
        return 1 ;
    }
    return 0 ;
}

forward Contar ( iR ) ;
public
    Contar ( iR )
{
    return ( iR ) ? ( iR-- , ( iR == 0 ) ? ( print ( "Go" ) ) : ( printf ( "%i" , iR ) ) , SetTimerEx ( "Contar" , 1000 , false , "i" , iR ) ) : ( 1 ) ;
}

Ou

pawn Code:
public
    OnPlayerCommandText ( playerid , cmdtext [ ] )
{
    if ( strcmp ( "/contar" , cmdtext , true , 8 ) == 0 )
    {
        return Contar ( 4 ) ;
    }
    return 0 ;
}

forward Contar ( iR ) ;
public
    Contar ( iR )
{
    return ( iR ) ? ( iR-- , ( iR == 0 ) ? ( print ( "Go" ) ) : ( printf ( "%i" , iR ) ) , SetTimerEx ( "Contar" , 1000 , false , "i" , iR ) ) : ( 1 ) ;
}

Como ves podes fazer codigos mais pequenos e organizados...
__________________

Zh3r0Jansish
SlashPT is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SetTimer wumpyc Scripting Help 7 30/09/2011 02:47 PM
SetTimer zxc1 Scripting Help 2 19/09/2011 01:16 PM
[Help] SetTimer NotoriousMOB Help Archive 8 05/06/2011 07:34 AM
[HELP] SetTimer Larsey123IsMe Help Archive 11 13/12/2010 10:05 PM
Settimer witha settimer in it 02manchestera Help Archive 2 07/03/2010 02:01 PM


All times are GMT. The time now is 08:13 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.