Creating Objects with arrays
#1

Hello, I was just wondering (in this case; using Incognito's streamer plugin)
how could you create objects with arrays?

I've tried it before, but it doesn't show up as it is suppose to.

the only problem that is not actually "working" is the configuration at the end, -1, -1, -1, 300.

How would I insert that into an array?
Using Float?

EDIT: Example below.
pawn Код:
new Float:gObjects[6][6] =
{
    {1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0},
    {1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0},
    {1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0},
    {1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0},
    {1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0},
    {1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0}
};

new gObjectsID[6][5] =
{
    {2323},
    {2323},
    {2323},
    {2323},
    {2323},
    {2323}
};

new Float:ObjConfig[6][4] =
{
    {-1, -1, -1, 300.0},
    {-1, -1, -1, 300.0},
    {-1, -1, -1, 300.0},
    {-1, -1, -1, 300.0},
    {-1, -1, -1, 300.0},
    {-1, -1, -1, 300.0},
};

//and then a function to create it.
for(new i = 0; i < 6; i++)//Looping through 6, since there are only 6 objects.
{
    CreateDynamicObject(gObjectID[i], gObject[1], gObject[2], gObject[3], gObject[4], gObject[5], gObject[6], ObjConfig[1], ObjConfig[2], ObjConfig[3]);
}
Any Ideas?
Reply
#2

Why would you need to? Are you getting compile error messages?
Reply
#3

no...more like warnings, tag mismatch.
Reply
#4

Which lines? post your code so i can see it
Reply
#5

The lines are posted above, as in the //edit.

Thats the only lines that I had relating to the topic.
Reply
#6

Post your compile errors and which lines are mentioned in the compile errors.
Reply
#7

Hmm....you define gObjects, but in the function you put gObject........would an 's' at the end of 'gObject' help?

And in the world of pawn(as for other scripting languages) numbers start at 0, so try changing 1 to 0, 2 to 1, etc...

AND as for the Tag mismatch, In CreateDynamicObject, your missing a ObjConfig arry of some sort, because you define 4 of them...
Reply
#8

Quote:
Originally Posted by The Toni
Посмотреть сообщение
Any Ideas?
Try:
pawn Код:
#include <a_samp>
#include <streamer>

enum
    gObjects_Enum
{
    g_modelid,
    Float:g_x,
    Float:g_y,
    Float:g_z,
    Float:g_rx,
    Float:g_ry,
    Float:g_rz,
    g_worldid,
    g_interiorid,
    g_playerid,
    Float:g_Distance
};

new
    gObjects[][gObjects_Enum] =
{
    { 2323, 1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0, -1, -1, -1, 300.0 },
    { 2323, 1235.12, 2322.23, 65.23, 0.0, 0.0, 0.0, -1, -1, -1, 300.0 }
};

public
    OnFilterScriptInit()
//  OnGameModeInit()
{
    for(new i = 0; i < sizeof(gObjects); i++)
    {
        CreateDynamicObject(gObjects[i][g_modelid],
                            gObjects[i][g_x],
                            gObjects[i][g_y],
                            gObjects[i][g_z],
                            gObjects[i][g_rx],
                            gObjects[i][g_ry],
                            gObjects[i][g_rz],
                            gObjects[i][g_worldid],
                            gObjects[i][g_interiorid],
                            gObjects[i][g_playerid],
                            gObjects[i][g_Distance]);
    }
    return 1;
}
Reply
#9

I can give you my functions so you can convert Float to Digit
pawn Код:
forward FloatToDigit(Float:Value);
forward Float:DigitToFloat(Value);

public FloatToDigit(Float:Value)
{
    new string[256];
    format(string,256,"%.0f",Value);
    new Digit = strval(string);
    return Digit;
}
public Float:DigitToFloat(Value)
{
    new string[256];
    format(string,256,"%d",Value);
    new Float:Digit = floatstr(string);
    return Digit;
}
Reply
#10

Try this:

Код:
new Float:gObjects[6][6] =
{
    1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0,
    1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0,
    1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0,
    1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0,
    1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0,
    1235.12, 2322.23, 55.23, 0.0, 0.0, 0.0
};

new gObjectsID[6] =
{
    2323,
    2323,
    2323,
    2323,
    2323,
    2323
};

new Float:ObjConfig[6][4] =
{
    -1, -1, -1, 300.0,
    -1, -1, -1, 300.0,
    -1, -1, -1, 300.0,
    -1, -1, -1, 300.0,
    -1, -1, -1, 300.0,
    -1, -1, -1, 300.0,
};

//and then a function to create it.

for(new i = 0; i < 6; i++)//Looping through 6, since there are only 6 objects.
{
    CreateDynamicObject(gObjectID[i], gObject[i][0], gObject[i][1], gObject[i][2], gObject[i][3], gObject[i][4], gObject[i][5], ObjConfig[i][0], ObjConfig[i][1], ObjConfig[i][2]);
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)