Enumerator and an Array
#1

The code inside the PAWN tag explains everything.

pawn Код:
//Enumerator & Enumerator Variable
enum EnumeratorName
{
    EnumeratorValue[1] // 0 = 1, 1 = 2, 2 = 3 and so on.
}
new eName[EnumeratorName];

//Usage:
// if the EnumeratorName [0] = 1;
if( eName[ EnumeratorName [0] ] == 1 ) 
    return SendClientMessage( playerid, -3, "Enumerator is currently on ( 1 )");
   
// if the EnumeratorName [0] = 0;
if( eName[ EnumeratorName [0] ] == 0 ) //means false or 0
    return SendClientMessage( playerid, -2, "Enumerator is currently off ( 0 )");

// error 028: invalid subscript (not an array or too many subscripts): "EnumeratorValue"
Reply
#2

It would have to be something like:
pawn Код:
if(eName[EnumeratorValue][0] == 1) return SendClientMessage(playerid,-3,"Enumerator is currently on ( 1 )");
    if(eName[EnumeratorValue][0] == 0) return SendClientMessage(playerid,-2,"Enumerator is currently off ( 0 )");
I changed the style of how it was as I find it easier to read.
Reply
#3

Quote:
Originally Posted by tyler12
Посмотреть сообщение
It would have to be something like:
pawn Код:
if(eName[EnumeratorValue][0] == 1) return SendClientMessage(playerid,-3,"Enumerator is currently on ( 1 )");
    if(eName[EnumeratorValue][0] == 0) return SendClientMessage(playerid,-2,"Enumerator is currently off ( 0 )");
I changed the style of how it was as I find it easier to read.
I appreciate your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)