[SOLVED] Integer array inside an enum -
-zriptarusk - 18.03.2009
Hi everyone.
I'm creating my first game server script, and I'm not sure about something..
Can I do this?
Код:
enum _pVehicle{
ownerName[256],
vehicleId,
modelId,
Float:posX,
Float:posY,
Float:posZ,
Float:rotation,
bool:locked,
color1,
color2,
mod[10]
};
new p_Vehicle[MAX_PLAYERS][_pVehicle];
(...)
p_Vehicle[0][mod[1]] = 3;
These are the errors I get
Код:
D:\San Andreas Multiplayer\gamemodes\script.pwn(438) : error 028: invalid subscript (not an array or too many subscripts): "mod"
D:\San Andreas Multiplayer\gamemodes\script.pwn(438) : warning 215: expression has no effect
D:\San Andreas Multiplayer\gamemodes\script.pwn(438) : error 001: expected token: ";", but found "]"
D:\San Andreas Multiplayer\gamemodes\script.pwn(438) : error 029: invalid expression, assumed zero
D:\San Andreas Multiplayer\gamemodes\script.pwn(438) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Can anyone help me? What should I do to access the X position of the "mod" array inside that other array, which has an enum.
Re: Integer array inside an enum -
pen_theGun - 18.03.2009
Код:
p_Vehicle[0][mod][1] = 3;
Re: Integer array inside an enum -
Dujma - 18.03.2009
Quote:
Originally Posted by pen_†ĥęGun
Код:
p_Vehicle[0][mod][1] = 3;
|
That is correct
Re: Integer array inside an enum -
Google63 - 18.03.2009
Defining max chars if most often used for strings and you don't need it for saving numbers...
So It Will be: p_Vehicle[0][mod] = 3 // I think you want to return playerID so insted of 0 put playerid.... cuz this will only work for playerid = 0...
So in comparing it will be something as:
pawn Код:
if(p_Vehicle[playerid][mod] == 3)
{
// do something
}
And replacing mod[10] with just mod
Re: Integer array inside an enum -
-zriptarusk - 19.03.2009
That doesn't answer my question.
Anyway. I searched a little more about PAWN Language and I think theres no way of doing what I want to do.
So, I guess I will just create the ten car mod slots one by one inside the enum
I would like to thanks anyone who tried to help me.
Honestly,
Thanks.
[EDIT]
Quote:
Defining max chars if most often used for strings and you don't need it for saving numbers...
So It Will be: p_Vehicle[0][mod] = 3 // I think you want to return playerID so insted of 0 put playerid.... cuz this will only work for playerid = 0...
So in comparing it will be something as:
PAWN Code:
if(p_Vehicle[playerid][mod] == 3)
{
// do something
}
And replacing mod[10] with just mod
|
No. I want an array of Integers, capable of storing 10 numbers.
You can do this:
Код:
new intArrayExample[10];
for(new i = 0; i < 10; i++) intArrayExample[i] = i;
This is what I needed before, and I guess I can't do that while the integer array is inside an enum.
Re: Integer array inside an enum -
Nubotron - 19.03.2009
Quote:
Originally Posted by Dujma
Quote:
Originally Posted by pen_†ĥęGun
Код:
p_Vehicle[0][mod][1] = 3;
|
lol that is not correct.
Can you give us some more code?
|
What is not correct? It is correct!
Re: Integer array inside an enum -
Dujma - 19.03.2009
Wrong
Re: Integer array inside an enum -
Dujma - 19.03.2009
Wrong
Re: Integer array inside an enum -
Dujma - 19.03.2009
Ignore this you are right. Sorry
Re: Integer array inside an enum -
Dujma - 19.03.2009
Quote:
Originally Posted by Westie
EDIT: He seems to get my point, but post is kept.
EDIT 2: Even then I just failed D:
No! That would imply that mod[1] carries the key for the array. Lemme show you a simple demonstration about arrays.
pawn Код:
enum e_Array { aArray[30], }
new aData[30][30], aEnum[e_Array]
main() { aData[30][1] = 35 aEnum[aArray][1] = 35
print("aData: %d, aEnum: %d", aData[30][1], aEnum[aArray][1]) }
What's the difference? They both equal 35.
|
I said I was wrong.
My fault I did not see this mod[10] enum