BigETI

3D array example

Apr 27th, 2011
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.79 KB | None | 0 0
  1. //Example of a 3D array made by BigETIĀ©
  2. //This time we want to store float values into the 3D array
  3.  
  4. new SituationID; //Lets make a situation like example Race Map ID
  5.  
  6. enum ArrayInfos //Start with enum to use them later to get more easier the values from the array field
  7. {
  8.     Float:CPINFO_X,
  9.     Float:CPINFO_Y,
  10.     Float:CPINFO_Z,
  11. }
  12.  
  13. new array[][][ArrayInfos] = //our array variable
  14. {
  15.     {
  16.         {0.00, 0.00, 0.00,},    //
  17.         {0.00, 0.00, 0.00,},    //
  18.         {0.00, 0.00, 0.00,},    // The amount of 1D arrays (look left) should be the same as the ones below
  19.         {0.00, 0.00, 0.00,},    //
  20.         {0.00, 0.00, 0.00,} //
  21.     }//<-- Important! Use comma if you want to add another 2D array field
  22.     {
  23.         {2.00, 5.00, 11.05,},   //
  24.         {123.40, 0.20, 0.04,}//
  25.         {12.00, 0.01, 0.30,},   // Same Here but as we see we can write another values inside the array field.
  26.         {-12.00, 0.60, 0.99,}//
  27.         {2.50, 0.00, 10.99,}    //
  28.     }//<-- still the same as above..
  29.     //Add here more if you want...
  30.     {
  31.         {0.00, 0.00, 0.00,},    //
  32.         {0.00, 0.00, 0.00,},    //
  33.         {0.00, 0.00, 0.00,},    // Just the same as above
  34.         {0.00, 0.00, 0.00,},    //
  35.         {0.00, 0.00, 0.00,} //
  36.     }   //<-- Here you shouldn't use a comma if you don't want to add another 2D array field below.
  37. }; //<-- End!
  38.  
  39. //Somewhere in your script..
  40. //Lets just create a CP
  41. SetPVarInt(playerid, "CPID", GetPVarInt(playerid, "CPID")+1);
  42. SetPlayerRaceCheckpoint(playerid, 0, array[SituationID][GetPVarInt(playerid, "CPID")][CPINFO_X],
  43. array[SituationID][GetPVarInt(playerid, "CPID")][CPINFO_Y],
  44. array[SituationID][GetPVarInt(playerid, "CPID")][CPINFO_Z],
  45. array[SituationID][GetPVarInt(playerid, "CPID")+1][CPINFO_X],
  46. array[SituationID][GetPVarInt(playerid, "CPID")+1][CPINFO_Y],
  47. array[SituationID][GetPVarInt(playerid, "CPID")+1][CPINFO_Z]);
  48.  
  49. //Hope this one helped you how to create and use 3D arrays
Advertisement
Add Comment
Please, Sign In to add comment