Array advice.
#1

I need some advice with storing some constant data in arrays.

I need to save 3 sets of spawnpoint coordinates PER SKIN, one in each city. Includes X, Y, Z and angle. Don't worry, I'm not saving 900 coordinates.

How should I go about doing this: I've tried all sorts.

I need something like

SetPlayerPos(playerid, spawn[skin][city][x], spawn[skin][city][y], spawn[skin][city][z]);

City can be 0/1/2. Skin can be 0-300. Needs 4 cells for x y z and angle.

Thanks.
Reply
#2

pawn Код:
enum E_SPAWN_DATA
{
    Float: E_X,
    Float: E_Y,
    Float: E_Z,
    SKIN_ID
}

static const
    g_spawnData[ ] [ E_SPAWN_DATA ]
    {
        { 1.0, 2.0, 3.0, 278 }
    }
;

new i = random( sizeof( g_spawnData ) );
SetPlayerPos( playerid, g_spawnData[ i ] [ E_X ], g_spawnData[ i ] [ E_Y ], g_spawnData[ i ] [ E_Z ] );
SetPlayerSkin( playerid, g_spawnData[ i ] [ E_SKIN ] );
Reply
#3

I have more data to store for skins than just spawns though. I would LIKE them in the same array - can you tell me how? I don't want the actual skin ID stored in an array, I want 300 (or whatever the max skin ID is) cells with the data for each skin on a different line, if you get me. I need to store like, X, Y, Z, angle, class (int, defined like CLASS_COP). Also, can you not space it out so much in the next example, it looks more complicated.

Please give me an example of two skins:

ID: 0
Spawns: 1, 1, 1, 1 2, 2, 2, 2 3, 3, 3, 3
Class: CLASS_COP

ID: 1
Spawns: 4, 4, 4, 4 5, 5, 5, 5 6, 6, 6, 6
Class: CLASS_MEDIC

I just want to be able to do, to get the class for skin 69: skin[69][SKIN_CLASS] == CLASS_MEDIC. And to spawn them, the X coordinate for LS (0) would be skin[69][SKIN_SPAWN][0][0] (skin 69, the spawns, city 0 (LS), [0] = x. Is it possible to have 4 dimensions?

Sorry about this, I just find it really confusing. Massive thanks.

-----------------------------------------------------------

EDIT:

Now I think about it, I'd like to have the skin ID saved in the array too. Just one thing, in your example you only have one set of coordinates, I need 3 per skin, one for each city.
Reply
#4

Because it's nicer to have them organised together D:
Reply
#5

pawn Код:
new Float:SkinCityPos[300][3][4]={//[Skin][City][xyza]
{{1000.0000,-1000.0000,0020.0000,000.0000},{-1000.0000,-2000.0000,0030.0000,090.0000},{2000.0000,2000.0000,0010.0000,180.0000}},//skin 0=line 0 i know, skin 0 not existing. you will need the same trick as for vehicles (+400 becomes +1 here)
{{1000.0000,-1000.0000,0020.0000,000.0000},{-1000.0000,-2000.0000,0030.0000,090.0000},{2000.0000,2000.0000,0010.0000,180.0000}},//skin 1 for santos, fierro, venturas
{{1000.0000,-1000.0000,0020.0000,000.0000},{-1000.0000,-2000.0000,0030.0000,090.0000},{2000.0000,2000.0000,0010.0000,180.0000}},//skin 2...
}
Skin=0-300; the first dimension [line] of the array
City=0-2; the second dimension {holding 3x coords{x,y,z} in it. oops, forgot to mention the angle ,a}
Float: x,y,z,a are stored in the array, so this
pawn Код:
{{santos},{fierro},{venturas}}
{{x,y,z,a},{x,y,z,a},{x,y,z,a}}
can be used like:
pawn Код:
SetPlayerPos(playerid,SkinCityPos[Skin][City][0],SkinCityPos[Skin][City][1],SkinCityPos[Skin][City][2]);
SetPlayerFacingAngle(playerid,SkinCityPos[Skin][City][3]);
.. or am i completedly wrong now?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)