SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/08/2019, 01:19 PM   #1
Killa[DGZ]
Huge Clucker
 
Killa[DGZ]'s Avatar
 
Join Date: Feb 2010
Location: Australia
Posts: 355
Reputation: 85
Default numhash'd usernames

Hey guys, quick question for anyone who knows,

If one was to numhash usernames, do you think that there would be the possibility of some other player having the same number?, no?

An what if I divide the returned number by 100?, would that increase the chances of it happening then?, or still no??
__________________
Killa[DGZ] is offline   Reply With Quote
Old 13/08/2019, 01:24 PM   #2
YouShootIDodge
Little Clucker
 
Join Date: May 2019
Posts: 42
Reputation: 11
Default Re: numhash'd usernames

Dividing 2 same numbers by 100, the numbers will still be the same.
YouShootIDodge is offline   Reply With Quote
Old 13/08/2019, 02:01 PM   #3
Killa[DGZ]
Huge Clucker
 
Killa[DGZ]'s Avatar
 
Join Date: Feb 2010
Location: Australia
Posts: 355
Reputation: 85
Default Re: numhash'd usernames

Quote:
Originally Posted by YouShootIDodge View Post
Dividing 2 same numbers by 100, the numbers will still be the same.

I don't think you quite understand man, I'm asking if there is a chance of someones username returning the same hashed value as someone else's username(the names ARE NOT the same), so the hashed value in theory should not, nor never be the same.

But then some usernames can result in quite a large number when returned as a numhash, much larger than the maximum possible virtual world.. so maybe it can be divided by 100 to circumvent this.
__________________
Killa[DGZ] is offline   Reply With Quote
Old 13/08/2019, 02:36 PM   #4
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,642
Reputation: 541
Default Re: numhash'd usernames

There can always be collisions but that depends on the algorithm. What's the point anyway?

If that number is larger than a 4 byte variable can store, dividing is pointless. It would already have exceeded the maximum number at that point, you wouldn't be able to calculate with the real number.
Also dividing would increase the likelihood of collisions, eg. 7812 and 7813 give the same result if you divide those by 100 (as integer) and it wouldn't matter how large the number is for the same thing to happen.
NaS is offline   Reply With Quote
Old 13/08/2019, 02:49 PM   #5
Killa[DGZ]
Huge Clucker
 
Killa[DGZ]'s Avatar
 
Join Date: Feb 2010
Location: Australia
Posts: 355
Reputation: 85
Default Re: numhash'd usernames

Thanks for clearing that up NaS, I ask because I've made a world edit script and I'm trying to figure out a way to assign each and every player a unique virtual world based on the players username.

Then with that I wish to store the user created maps under their own virtual world id eg: (71521.map), then others would be able to fetch and load the objects in that particular world by just knowing the username of the creator.


It's much harder than I originally thought though.. any ideas on how I can achieve this man?
__________________
Killa[DGZ] is offline   Reply With Quote
Old 13/08/2019, 03:00 PM   #6
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,179
Reputation: 404
Default Re: numhash'd usernames

Quote:
Originally Posted by Killa[DGZ] View Post
Thanks for clearing that up NaS, I ask because I've made a world edit script and I'm trying to figure out a way to assign each and every player a unique virtual world based on the players username.

Then with that I wish to store the user created maps under their own virtual world id eg: (71521.map), then others would be able to fetch and load the objects in that particular world by just knowing the username of the creator.


It's much harder than I originally thought though.. any ideas on how I can achieve this man?
SetPlayerVirtualWorld(playerid, playerid); ???????

Then, there's also this: https://github.com/Southclaws/pawn-uuid

EDIT: Almost forgot, if you're an SQL user you can also take advantage of the ' AUTOINCREMENT ' feature. Players being registered on the database would have their own unique ID based on when they actually register.
__________________
Quote:
Originally Posted by Andy
My anti cheat is still relevant *puts shades on* https://github.com/RogueDrifter/Anti_cheat_pack

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link
RogueDrifter is offline   Reply With Quote
Old 13/08/2019, 06:08 PM   #7
GTLS
High-roller
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 1,044
Reputation: 115
Default Re: numhash'd usernames

Quote:
Originally Posted by RogueDrifter View Post
SetPlayerVirtualWorld(playerid, playerid); ?

Then, there's also this: https://github.com/Southclaws/pawn-uuid

EDIT: Almost forgot, if you're an SQL user you can also take advantage of the ' AUTOINCREMENT ' feature. Players being registered on the database would have their own unique ID based on when they actually register.
Exactly. Just set their VW on the based of their Database ID, when you spawn them. Database IDs stay unique for each and every character.
__________________

I don't help for rep. I help cuz I was helped in the past.


Retired from SAMP Scene. Might open SAMP Forums once in a while.

Some treats for ya. Click em
Basic House System
Simple Speedo
Base Login/Register Script

GTLS 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
Social/gaming media usernames thread Potassium Everything and Nothing 134 08/12/2016 05:41 PM
Gaming Usernames (PS3/XBox) Akira297 Everything and Nothing 3 06/05/2014 12:51 PM
Saving usernames with '(' or ')' in mysql DeathTone Scripting Help 2 01/08/2012 10:40 AM
2 letter usernames. 12 General 5 13/03/2012 08:08 AM


All times are GMT. The time now is 10:29 AM.


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