Clearing out an enum? -
dowster - 21.07.2011
is there an easy way to erase everything in an enum without doing
pawn Код:
enum[VALUE1] = 0;
enum[VALUE2] = 0;
for the whole thing?
Re: Clearing out an enum? -
Mauzen - 21.07.2011
pawn Код:
for(new i = 0; i < sizeof(enum); i++)
enum[enumname:i] = 0;
}
Should do it, but it might not clear arrays properly when you got one in the enum.
Re: Clearing out an enum? -
MadeMan - 21.07.2011
I think there is
pawn Код:
enum eEnum
{
eVar1,
eVar2,
eVar3
}
new MyVar[eEnum];
pawn Код:
for(new i=0; i < sizeof(MyVar); i++)
{
MyVar[eEnum:i] = 0;
}
Re: Clearing out an enum? -
dowster - 21.07.2011
then how would i clear the array if it was setup like
pawn Код:
gPlayerInfo[playerid][PASSWORD]
where the PASSWORD is a 32 character array
Re: Clearing out an enum? - rjjj - 21.07.2011
If you have this enum for example

:
pawn Код:
enum Example
{
xD,
xO,
xP,
};
new Var[Example];
You can't change the values of the symbols
xD and
xO inside the brackets, like:
Because they are constant

.
But if you want to do this without write one per one

:
pawn Код:
new Var[xD] = 0;
new Var[xO] = 0;
new Var[xP] = 0;
Just use:
pawn Код:
for(new y = 0; y != sizeof(Var); y++)
{
Var[Example:y] = 0; //The tag "Example:" is derived from the enum "Example"
}
@EDIT
Quote:
Originally Posted by dowster
then how would i clear the array if it was setup like
pawn Код:
gPlayerInfo[playerid][PASSWORD]
where the PASSWORD is a 32 character array
|
You can use:
pawn Код:
strmid(gPlayerInfo[playerid][PASSWORD],"",false,0,32);
To clean it

.
I hope that i have helped

.
Re: Clearing out an enum? -
MadeMan - 21.07.2011
Quote:
Originally Posted by dowster
then how would i clear the array if it was setup like
pawn Код:
gPlayerInfo[playerid][PASSWORD]
where the PASSWORD is a 32 character array
|
pawn Код:
for(new i=0; i < sizeof(gPlayerInfo[]); i++)
{
gPlayerInfo[playerid][i] = 0;
}
Re: Clearing out an enum? -
Mauzen - 21.07.2011
Hm, i got no idea if this will work, didnt test it, but maybe it works:
pawn Код:
new var[enum];
for (new i = 0; i < sizeof(var); i++)
{
if (sizeof(var[enum:i]) > 1)
{
for (new j = 0; j < sizeof(var[enum:i]); j ++)
{
var[enum:i][j] = 0;
} else {
var[enum:i] = 0;
}
}
}
AW: Clearing out an enum? -
Nero_3D - 21.07.2011
Once again, the same basic code

like in reply #3
pawn Код:
enum E_VAR {
var1,
var2[10],
var3
}
new var[E_VAR];
for(new i; i < sizeof(var); i++) {
var[E_VAR: i] = 0;
}
This is fully enough to clear all enum variables and arrays, due to the fact how enums work!