world.GetUniqueID

MUSHclient script function (Method) — introduced in version 3.23

Creates a unique ID for general use, or for making Plugin IDs

Prototype

BSTR GetUniqueID();

Data type meanings

Description

This uses CreateGUID to get a unique number, and then hashes it, retaining 24 characters (96 bits) of the hash. This generates a nice, unique identifier, like this: "0a96ce42d8e0ede554d3b9ab".

The advantage of using this over CreateGUID is that by hashing the number your network card MAC address is concealed. Conceivably some users might not want their MAC address to be revealed. The number generated here will be used by plugins to uniquely identify themselves.

You could also use it for variable, trigger, timer, alias names, when generated by a script, to ensure uniqueness over multiple sessions. You could also use it as a handy "password generator", as the number sequences are hardly going to be predicable.

Contrast this to "GetUniqueNumber" which only returns a unique number for this session of MUSHclient. Thus, the numbers (from "GetUniqueNumber") will not be unique over multiple sessions.

See also the new script function world.CreateGUID.

Also, using random number generation for unique identifiers has a chance of returning the same number, depending on a) the seed given to the generator; and b) the way the generator must eventually recyle and regenerate the same sequence.

VBscript example

world.Note world.GetUniqueID

Jscript example

world.Note (world.GetUniqueID ());

PerlScript example

$world->Note ($world->GetUniqueID ());

Python example

world.Note (world.GetUniqueID )

Lua example

Note (GetUniqueID ())

Return value

A 24-character unique identifier.

Related topic

Utilities

See also

FunctionDescription
CreateGUIDCreates a GUID - Global Unique Identifier
GetUniqueNumberReturns a unique number
HashProduces a hash (checksum) of a specified piece of text