Fastest way to reset Enum with loop not working -
Swimor - 22.05.2013
Fastest way to reset Enum with loop not working
Hello,
I have very big Enum to store players data, his length about 100...
I used this code OnPlayerConnect:
Код:
for(new i; i<sizeof(PEnum); i++)
{
PInfo[playerid][i] = 0;
}
But I got strange errors:
Quote:
X(1) : error 039: constant symbol has no size
X(3) : warning 213: tag mismatch
|
I know what the errors means but why the code isn't working?
Thanks for help!
Re: Fastest way to reset Enum with loop not working -
IstuntmanI - 22.05.2013
Show us the PInfo and PEnum codes (creation).
Re: Fastest way to reset Enum with loop not working -
Swimor - 22.05.2013
Here the Enum:
Код:
enum PEnum {
// Here some stuff...
};
And the PInfo:
Код:
new
PInfo[MAX_PLAYERS][PEnum];
Re: Fastest way to reset Enum with loop not working -
IstuntmanI - 22.05.2013
You have to use
Код:
for(new i; i<sizeof(PEnum); i++)
{
PInfo[playerid][Stuff Name] = 0;
}
Or if you have array "stuff":
Код:
for(new i; i<sizeof(PInfo[][Stuff Name]); i++)
{
PInfo[playerid][Stuff Name][i] = 0;
}
Re: Fastest way to reset Enum with loop not working -
Pottus - 22.05.2013
The code you've written is incorrect, your looping through the size of the array in this case MAX_PLAYERS while specifying your iterator as the array index in the ENUM.
You need do something like this
PInfo[playerid][enumval1] = 0;
PInfo[playerid][enumval2] = 0;
PInfo[playerid][enumval3] = 0;
PInfo[playerid][enumval4] = 0;
There is no need for looping unless one of your ENUM values is an array it's self!
Re: Fastest way to reset Enum with loop not working -
Swimor - 22.05.2013
Quote:
Originally Posted by IstuntmanI
You have to use
Код:
for(new i; i<sizeof(PEnum); i++)
{
PInfo[playerid][Stuff Name] = 0;
}
Or if you have array "stuff":
Код:
for(new i; i<sizeof(PInfo[][Stuff Name]); i++)
{
PInfo[playerid][Stuff Name][i] = 0;
}
|
This isn't what I want to do,
Please see this thread:
https://sampforum.blast.hk/showthread.php?tid=367225
Re: Fastest way to reset Enum with loop not working - HuSs3n - 22.05.2013
or try this
pawn Код:
for(new i; PEnum:i < PEnum; i++)
{
PInfo[playerid][PEnum:i] = 0;
}
Re: Fastest way to reset Enum with loop not working -
Swimor - 22.05.2013
Quote:
Originally Posted by HuSs3n
or try this
pawn Код:
for(new i; PEnum:i < PEnum; i++) { PInfo[playerid][PEnum:i] = 0; }
|
You are fucking Genius! Thanks!
Re: Fastest way to reset Enum with loop not working -
Swimor - 23.05.2013
Quote:
Originally Posted by ******
I would just do:
pawn Код:
new x[PEnum]; PInfo[playerid] = x;
|
I will give it a try, thanks!
Re: Fastest way to reset Enum with loop not working -
Pottus - 23.05.2013
Quote:
Originally Posted by ******
I would just do:
pawn Код:
new x[PEnum]; PInfo[playerid] = x;
|
That is actually pretty clever and makes sense I never really looked at it that way the simplest solution is the best solution when it is effective I think people tend to over think problems sometimes myself included.