01.01.2014, 15:55
Okay so I'm working with a system that involves destroying 12 objects at a time then creating 12 new ones at the same time. I will give an example below:
So what is basically happening is sometimes certain objects aren't destroyed (visibly anyway, I can see them when testing in-game but I guess the script thinks they've been destroyed) and it just seems like object ID's get mixed up, sometimes different objects a created to what I want and sometimes only for example half a set of objects are created. As far as I know there isn't anything wrong with my code, so I'm not sure what the problem is.
If it helps, the objects I'm working with are PinSpotLights and smoke machines, and in my actual script I'm using more than just 3 sets of lights, I'm using 14, there are 12 objects in a set, you can imagine it's quite a big chunk of code.
pawn Код:
new green_light_1,
green_light_2,
green_light_3,
green_light_4,
green_light_5,
green_light_6,
green_light_7,
green_light_8,
green_light_9,
green_light_10,
green_light_11,
green_light_12,
red_light_1,
red_light_2,
red_light_3,
red_light_4,
red_light_5,
red_light_6,
red_light_7,
red_light_9,
red_light_9,
red_light_10,
red_light_11,
red_light_12,
purple_light_1,
purple_light_2,
purple_light_3,
purple_light_4,
purple_light_5,
purple_light_6,
purple_light_7,
purple_light_8,
purple_light_9,
purple_light_10,
purple_light_11,
purple_light_12;
CMD:green(playerid, params[])
{
ClearObjectsFirst(); //clears the last set of created lights for the new set
green_light_1 = CreateObject(bla bla bla);
green_light_2 = CreateObject(bla bla bla);
//continue to create all the green lights and setting them to green_light_x
return 1;
}
stock ClearObjectsFirst()
{
if(IsValidObject(green_light_1)) //Im only checking for the first one in the set since if one is valid they all should be
{
DestroyObject(green_light_1);
DestroyObject(green_light_2);
DestroyObject(green_light_3);
DestroyObject(green_light_4);
DestroyObject(green_light_5);
DestroyObject(green_light_6);
DestroyObject(green_light_7);
DestroyObject(green_light_8);
DestroyObject(green_light_9);
DestroyObject(green_light_10);
DestroyObject(green_light_11);
DestroyObject(green_light_12);
}
else if(IsValidObject(red_light_1))
{
//Do the same as above, destroy all red lights if they're valid
}
else //the purple lights must be the ones spawned then
{
//Same as above, destroy all purple lights
}
return 1;
}
If it helps, the objects I'm working with are PinSpotLights and smoke machines, and in my actual script I'm using more than just 3 sets of lights, I'm using 14, there are 12 objects in a set, you can imagine it's quite a big chunk of code.