PDA

View Full Version : ID Shifting


Psycho77
12/06/2013, 07:07 PM
Hi...

I hope you know the problems with ID shifting.

For example you have 2 cars. One of these will be destroyed. Now I create another Car.
Now have the variable of the destroyed car and the variable of the new car the same value.

So i try to fix this problem with own functions where the variables got a invalid value:

stock j_PlayerTextDrawDestroy(playerid, &PlayerText:text)
{
PlayerTextDrawDestroy(playerid, text);
text = PlayerText:INVALID_TEXT_DRAW;
}

stock j_TextDrawDestroy(&Text:text)
{
TextDrawDestroy(text);
text = Text:INVALID_TEXT_DRAW;
}

stock j_DestroyDynamicMapIcon(&mapconid)
{
DestroyDynamicMapIcon(mapconid);
mapconid = -1;
}

stock j_DestroyDynamicPickup(&pickupid)
{
DestroyDynamicPickup(pickupid);
pickupid = -1;
}

With these functions there cant be any shifting because the variable with the same as the itemid will be resetted when the item with this Id will be destroyed.

Not i do the same with 3DTextLabel's:
stock j_DestroyDynamic3DTextLabel(&Text3D:textid)
{
DestroyDynamic3DTextLabel(textid);
textid = Text3D:INVALID_3DTEXT_ID;
}But in this case he want to have a returned value:
warning 209: function "j_DestroyDynamic3DTextLabel" should return a value
Why he need a return here? I use &Text3D:textid because he should set the value of the variable directly.