Generate SSN of unit from their name

Similar to how we're handling blood types, uses the unit's name to generate a valid three/two/four format SSN.

For names less than 9 characters long this will currently generate a unique SSN only up to the length of the name and append valid digits as necessary.
This commit is contained in:
SilentSpike 2016-06-21 18:42:15 +01:00
parent 7f39748ff0
commit ebcf1687a7
3 changed files with 25 additions and 3 deletions

View File

@ -9,4 +9,5 @@ PREP(getDogtagData);
PREP(getDogtagItem);
PREP(sendDogtagData);
PREP(showDogtag);
PREP(ssn);
PREP(takeDogtag);

View File

@ -23,9 +23,7 @@ private _targetName = [_target, false, true] call EFUNC(common,getName);
private _dogTagData = [
_targetName,
str(floor random 10) + str(floor random 10) + str(floor random 10) + "-" +
str(floor random 10) + str(floor random 10) + "-" +
str(floor random 10) + str(floor random 10) + str(floor random 10),
_targetName call FUNC(ssn),
_targetName call FUNC(bloodType)
];
// Store it

View File

@ -0,0 +1,23 @@
/*
* Author: SilentSpike
* Reports a social security number generated from the units name.
*
* Arguments:
* 0: Name of a unit <STRING>
*
* Return Value:
* A random social security number <STRING>
*
* Public: No
*/
#include "script_component.hpp"
params ["_name"];
private _nums = ((toArray _name) select [0,9]) apply { _x % 10 };
while {count _nums < 9} do {
_nums pushBack (floor random 10);
};
([_nums select [0,3],_nums select [3,2], _nums select [5,4]] apply { _x joinString "" }) joinString "-"