02.05.2017, 17:51
Quote:
Guessing.
PHP код:
So what if i want it to print to 100, 100 dots? TIL https://en.wikipedia.org/wiki/Modulo_operation |
---------------------------------------
Quote:
Код:
some3dtext = CreateDynamic3DTextLabel("hi", -1, 0.0, 0.0, 0.0, 0.0, 0); DestroyDynamic3DTextLabel(some3dtext); printf("%i", some3dtext); //prints 1 if (IsValidDynamic3DTextLabel(some3dtext )) { printf("first is valid..."); //this doesn't print } some3dtext = INVALID_3DTEXT_ID; printf("%i", some3dtext); //prints 65535 if (IsValidDynamic3DTextLabel(some3dtext)) { printf("invalid is valid..."); //this doesn't print } |
If you won't reset the variable, something like this could happen:
PHP код:
new Text3D:vartext;
public OnGameModeInit( )
{
vartext = Create3DTextLabel( ... ); // textlabel ID 0
Create3DTextLabel( ... ); // textlabel ID 1
Create3DTextLabel( ... ); // textlabel ID 2
}
public OnPlayerPickUpPickup( playerid, pickupid )
{
if( IsValid3DTextLabel( vartext ) ) // let's say you want it to be deleted when any pickup is picked up
Delete3DTextLabel( vartext ); // textlabel ID 0 is now deleted, so it isn't valid
}
// later
Create3DTextLabel( ... ); // because textlabel ID 0 is no longer valid, and it is the first free ID, this 3DText will be created with ID 0.
// you probably don't want it to be deleted when any player pick any pickup, but it will be deleted, because ID 0, which is
// stored in "vartext" is now valid (so IsValid3DTextLabel will return 1 for textlabel ID 0)
I actually had problems some years ago because I didn't reset variables after destroying. Random elements were deleted when they shouldn't (they can even change properties, for example you could add components to the wrong vehicle, or setting bad objects positions and so on. Every function that can apply to an element ID). Reset variables ! Otherwise it will give you headaches in the future.