Jump to content
Sign in to follow this  
sakura_chan

getArray returns string? Halp!

Recommended Posts

so in the config i have:

sakuarray[] =
{
       [1201, [-0.7,0.3,-1.4]],
       [1202, [0, 0, 0]],
       [1203, [0.7,0.3,-1.4]],
       [1204, [0.7,-0.7,-1.4]],
       [1205, [-0.7,-0.7,-1.4]]
};

but it returns it as a bunch of strings, like ["[1201", "[-0.7", 0.3, "-1.4]"], etc

How do I turn this into a usable array? I can't separate each array into its own cfgVehicle entry because that would require a script to check for each one. The script also works on the principal of receiving an array with a non-specific number of entries. Is there something simple that I'm missing with the syntax of the array or something? Do I just make it like:

sakuarray[] =
{
       1201, -0.7,0.3,-1.4,
       1202, 0, 0, 0,
       1203, 0.7,0.3,-1.4,
       1204, 0.7,-0.7,-1.4,
       1205, -0.7,-0.7,-1.4
};

and write a few lines of code to convert that into the nested array that the script requires?

Share this post


Link to post
Share on other sites

You need to use curly braces as array start/end:

sakuarray[] =
{
       {1201, {-0.7,0.3,-1.4}},
       {1202, {0, 0, 0}},
       {1203, {0.7,0.3,-1.4}},
       {1204, {0.7,-0.7,-1.4}},
       {1205, {-0.7,-0.7,-1.4}}
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×