• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

unique id for monsters

lexus21

Active Member
Joined
Dec 14, 2022
Messages
89
Reaction score
25
I noticed that when we assign the id of a given monster to some database. And we will create monsters and remove them, so after restarting the server the id will not match the id from before the restart (in the database).

I noticed that ids like to duplicate themselves.
How to prevent such behavior?
I would like the id of a given monster to be unique (as much as possible) and removing a monster with a given id later when creating other monsters would never receive that id again.
 
There is no way to save monsters to the database....
Saving a number does not mean that there is black magic that saves your monster and its status just because you have written down your monster id in a notebook or a database.

To achieve a similar and not so complicated behavior, maybe you could store the monster's health, the monster's name, and the properties that you think are necessary for what you need and when you need to spawn the monster, you just create a new one and set it the health and properties you saved.
 
I noticed that when we assign the id of a given monster to some database. And we will create monsters and remove them, so after restarting the server the id will not match the id from before the restart (in the database).

I noticed that ids like to duplicate themselves.
How to prevent such behavior?
I would like the id of a given monster to be unique (as much as possible) and removing a monster with a given id later when creating other monsters would never receive that id again.
getId() is just a running incremented id in memory... It is not persistent like player:getGuid() which is the static id from the players table.
 
Back
Top