SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 02/06/2018, 04:15 PM   #21
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,723
Reputation: 3073
Default Re: UUID4 - Universal Unique Identifiers

Quote:
Originally Posted by Ada32 View Post
no



yes

the chances of a collision happening though is ridiculously low. like ridiculously ridiculously (did i say ridiculously?) low
I don't think you stressed ridiculously low enough (I'm not being sarcastic). If everyone on earth generated a million uuids per second for the age of the universe, there's a 50% chance any two of them would match.

For reference, there's a thing called the birthday paradox, which says that it takes only 30 people for a 50% chance that two of them will have the same birthday. So this huge age of the universe chance is massive despite being lowered by the same paradox.

Also, that article ignored two things:

1) some databases do support them natively.

2) binary trees are most efficiently balanced when the inserted data is random.
Y_Less is offline   Reply With Quote
Old 02/06/2018, 04:51 PM   #22
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,883
Reputation: 1443
Default Re: UUID4 - Universal Unique Identifiers

Some additional notes for this:

Yes, typical basic servers with an SQL database with a few thousand player records and auto increment IDs will not need this.

However, complex gamemodes often have many different entity types that are persisted. Often, these entities may be created by applications other than the gamemode itself, such as web services. The UUID format is standard and widely support in most programming languages and databases (yes, MySQL, Postgres, MongoDB and plenty of others actually support storing UUIDs as 128 bit fields not strings of text - I know from experience that Postgres provides optimised index features for UUIDs).

This isn't just for things in a database but for anything - you could assign UUIDs to vehicles, items, player login sessions, individual commands and chat messages or even every event that ever happens on a server ever - that beats using a combination of timestamp, event type, event contents, etc as a primary key.

The article does have some good points about UUIDs and is definitely worth a read by anyone considering using this plugin, but I wouldn't go as far as saying "you will almost never have to use uuids".
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is online now   Reply With Quote
Old 02/06/2018, 05:31 PM   #23
Ada32
Huge Clucker
 
Ada32's Avatar
 
Join Date: Apr 2013
Posts: 297
Reputation: 62
Default Re: UUID4 - Universal Unique Identifiers

the problem isn't uuids itself, it's how they're implementated. for starters they aren't (and shouldn't be) primary keys! i think that's what most people seem to think. they're more so references to a system designed to be made up of very different parts but are still part of that system

so this

Quote:
Originally Posted by [HLF]Southclaw
Itís also perfect for identifying entities such as vehicles, pickups, items, etc. A good example of this is the Scavenge and Survive gamemode: on each server restart, around 10-20,000 items are generated and placed in the world, each of these items is assigned a unique identifier so if a player picks one up and keeps it in their inventory or in a vehicle trunk, the unique identifier persists throughout the itemís lifetime and everywhere it goes can be tracked. This is very useful for auditing and anti-cheat.
i'd argue would actually be unnecessary as you would still need something (your db) to help differentiate between the items, vehicles etc.

which contradicts

Quote:
Originally Posted by [HLF]Southclaw
The problem with this is youíre relying on the database implementation to handle the uniqueness. This locks you into using that database and also means thereís a reliance on sequentiality in the identifiers.
maybe my words were brash so i'll reclarify by saying "you will almost never have to use uuids in samp"
Ada32 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dialogs unique identifiers (no longer maintained) Donny_k Help Archive 67 27/11/2009 10:40 PM


All times are GMT. The time now is 08:11 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.