SA-MP Forums Archive
ID Shifting - 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)
+--- Thread: ID Shifting (/showthread.php?tid=443580)



ID Shifting - Psycho77 - 12.06.2013

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:
Quote:

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.