CreateDynamicObject
#1

So, assuming i have in an array a coordinates of all robbery places, like this:

pawn Код:
LoadRobberies()
{

    RobberyP[0] = CreateDynamicSphere(2065.439453125, -1897.5510253906, 13.19670009613, 3.0);
    RobberyP[1] = CreateDynamicSphere(1497.7467041016, -1749.8747558594, 15.088212013245, 3.0);
    //And so on...
    return 1;
}
How i can create objects with streamer without doing:

CreateDynamicObject multiple times? (I have 40 robbery places).

Basically, i wanna create an object based on the coordinates in that array.
Reply
#2

You'll need a loop to go through the array, something like this:

Код:
for(new i = 0; i < sizeof(Coords); i ++)
{
CreateDynamicObject(model, Coords[i][0], Coords[i][1], Coords[i][2], Coords[i][3], Coords[i][4], Coords[i][5], ...);
}
Where "Coords" is the array you use to hold the coordinates.
The array is a 2D Array, the first dimension being the ID of the Robbery Place and the second dimension are the actual coords. 0 - 2 are X, Y, Z and 3 - 5 are RX, RY, RZ (if you also have rotations in the array).

You might also want to save the Dynamic Object IDs in an Array in case you need them later on.
Reply
#3

Tried in this way:

pawn Код:
new const RobOjbects[][RobIcons] =
{
    {2067.4,-1831.2,13.5},
    {488.0,-1734.0,34.4},
    {720.016,-454.625,15.328}
};

enum RobIcons
{
    Float:XXX,
    Float:YYY,
    Float:ZZZ
}

for(new i = 0; i < sizeof(AtmObjects); i ++)
{
CreateDynamicObject(19324, RobOjbects[i][XXX], RobOjbects[i][YYY], RobOjbects[i][ZZZ], 0.0, 0.0, 0.0, 100);
}
But getting this:

error 017: undefined symbol "RobIcons"
error 010: invalid function or declaration
Reply
#4

You must declare the enum before the array. So just move it up.
Reply
#5

Declare the RobIcon enum before RobObject enum.
Reply
#6

Ok managed to fix, now i wanna create mapicons.

I did in this way:

pawn Код:
for(new i = 0; i < sizeof(AtmObjects); i ++)
    {
    CreateDynamicObject(19324, AtmObjects[i][XXX], AtmObjects[i][YYY], AtmObjects[i][ZZZ], 0.0, 0.0, 0.0, 100);
    CreateDynamicMapIcon(AtmObjects[i][XXX][0], AtmObjects[i][YYY][1], AtmObjects[i][ZZZ][2], 15, 0, 0, .streamdistance = 200.0);
    }
(Forget all the code above, i changed from rob to atm objects).

And got this at the CreateDynamicMapIcon line:

Quote:

error 001: expected token: ",", but found "["
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
fatal error 107: too many error messages on one line

EDIT: Just checked now...object doesn't appear :/
Reply
#7

`AtmObjects[i][XXX]` is enough, you don't need to add an additional dimension.
Reply
#8

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
`AtmObjects[i][XXX]` is enough, you don't need to add an additional dimension.
So just:

CreateDynamicObject(19324, AtmObjects[i][XXX], 0.0, 0.0, 0.0, 100);

?

EDIT: Tried, doesnt work.
Reply
#9

PHP код:
for(new 0sizeof(AtmObjects); ++)
{
    
CreateDynamicObject(19324AtmObjects[i][XXX], AtmObjects[i][YYY], AtmObjects[i][ZZZ], AtmObjects[i][XXX][0], AtmObjects[i][YYY][1], AtmObjects[i][ZZZ][2]);
    
CreateDynamicMapIcon(AtmObjects[i][XXX], AtmObjects[i][YYY], AtmObjects[i][ZZZ], 150);

I do not know if that will help you a lot, try

and post the AtmObjects enum to see how work your atm system
Reply
#10

pawn Код:
new const AtmObjects[][AtmIcons] =
{
    {2065.439453125, -1897.5510253906, 13.19670009613},
    {1497.7467041016, -1749.8747558594, 15.088212013245},
    {2093.5124511719, -1359.5474853516, 23.62727355957},
    {1155.6235351563, -1464.9141845703, 15.44321346283},
    {1482.7761230469, -1010.3353881836, 26.48664855957},
    {2139.4487304688, -1164.0811767578, 23.63508605957}
};

enum AtmIcons
{
    Float:XXX,
    Float:YYY,
    Float:ZZZ
}
I'm getting an error on your code:

Код:
error 001: expected token: ",", but found "["
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
fatal error 107: too many error messages on one line
Referred to the CreateDynamicObject line.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)