SA-MP Forums Archive
Creating Objects with arrays - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Creating Objects with arrays (/showthread.php?tid=163582)



Creating Objects with arrays - Toni - 28.07.2010

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?


Re: Creating Objects with arrays - mastasquizy - 28.07.2010

Why would you need to? Are you getting compile error messages?


Re: Creating Objects with arrays - Toni - 28.07.2010

no...more like warnings, tag mismatch.


Re: Creating Objects with arrays - mastasquizy - 28.07.2010

Which lines? post your code so i can see it


Re: Creating Objects with arrays - Toni - 28.07.2010

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

Thats the only lines that I had relating to the topic.


Re: Creating Objects with arrays - John_F - 28.07.2010

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


Re: Creating Objects with arrays - mastasquizy - 28.07.2010

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...


Re: Creating Objects with arrays - smeti - 28.07.2010

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;
}



Re: Creating Objects with arrays - ikey07 - 28.07.2010

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;
}



Re: Creating Objects with arrays - deather - 28.07.2010

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]);
}