[Tutorial] Tips & Tricks [Share Yours!]
#10

Tip/Trick Title: Enumerator & Loop

Tip/Trick Description: Easy to loop an Enumerator, nothing much too explain.

Tip/Trick Example(Use PAWN tags):
pawn Code:
enum debug//Enumerator
{
    debug1, debug2, debug3, debug 4;
}
new debug[ MAX_PLAYERS ][ debug ];

CMD:setenumto1(playerid, params[]) // debug purposes
{
    debug1[playerid][debug1] = 1;
    debug1[playerid][debug2] = 1;
    debug1[playerid][debug3] = 1;
    debug1[playerid][debug4] = 1;
     printf("[DEBUG]: %i, %i, %i, %i", debug1, debug2, debug3, debug4);
    //DEBUG result ( [DEBUG]: 1, 1, 1, 1)
}


//new process | shorter version
CMD:resetenum(playerid, params[])
{
    for(new i; robbingshop:i < robbingshop; i++) { debug[ playerid ][ robbingshop:s ] = 0; } return 1;
    printf("[DEBUG]: %i, %i, %i, %i", debug1, debug2, debug3, debug4);
    //DEBUG result ( [DEBUG]: 0, 0, 0, 0 )
}

//instead of | longer version
CMD:resetenum1(playerid, params[])
{
    debug1[playerid][debug1] = 0;
    debug1[playerid][debug2] = 0;
    debug1[playerid][debug3] = 0;
    debug1[playerid][debug4] = 0;
    printf("[DEBUG]: %i, %i, %i, %i", debug1, debug2, debug3, debug4);
    //DEBUG result ( [DEBUG]: 0, 0, 0, 0 )
}
Reply


Messages In This Thread
Tips & Tricks [Share Yours!] - by Weponz - 03.10.2013, 14:58
Re: Tips & Tricks [Share Yours!] - by DanishHaq - 03.10.2013, 15:33
Re: Tips & Tricks [Share Yours!] - by RajatPawar - 03.10.2013, 15:37
Re: Tips & Tricks [Share Yours!] - by Weponz - 03.10.2013, 15:39
Re: Tips & Tricks [Share Yours!] - by RajatPawar - 03.10.2013, 15:48
Re: Tips & Tricks [Share Yours!] - by Weponz - 03.10.2013, 15:52
Respuesta: Tips & Tricks [Share Yours!] - by ipsBruno - 05.10.2013, 12:03
Re: Tips & Tricks [Share Yours!] - by sanya_gnoy - 05.10.2013, 12:21
Re: Tips & Tricks [Share Yours!] - by Weponz - 06.10.2013, 10:41
Re: Tips & Tricks [Share Yours!] - by Patrick - 06.10.2013, 22:15
Re: Tips & Tricks [Share Yours!] - by Sublime - 07.10.2013, 02:31
Re: Tips & Tricks [Share Yours!] - by sanya_gnoy - 07.10.2013, 06:25

Forum Jump:


Users browsing this thread: 1 Guest(s)