RZA-PT | KilroyPT
- Joined
- Aug 27, 2007
- Messages
- 936
- Reaction score
- 85
Those of you who remember the xPT (or what ever it was) account management tool that was released here, you may have pilfered for your site, the directory number function:
This was great, except that it didn't capture every character.
I realised it's actually much simpler than this.
the simple function:
All the game is doing is taking the ascii value for the character (in upper case) and doing the same maths,
I get a lot of you may be thinking "great but what use do I have for this?"
Well I use it for many things, my tools for character list, for my item distributor tool, for character management and renaming characters.
I hope some of you get some use out of this, nothing special, not a huge gift to the community but hoping it will make things a little simpler for some of you.
Code:
function numDir($name)
{
$total = "";
$character=array
(
"0"=>"48", "1"=>"49", "2"=>"50",
"3"=>"51", "4"=>"52", "5"=>"53",
"6"=>"54", "7"=>"55", "8"=>"56",
"9"=>"57", "a"=>"65", "b"=>"66",
"c"=>"67", "d"=>"68", "e"=>"69",
"f"=>"70", "g"=>"71", "h"=>"72",
"i"=>"73", "j"=>"74", "k"=>"75",
"l"=>"76", "m"=>"77", "n"=>"78",
"o"=>"79", "p"=>"80", "q"=>"81",
"r"=>"82", "s"=>"83", "t"=>"84",
"u"=>"85", "v"=>"86", "w"=>"87",
"x"=>"88", "y"=>"89", "z"=>"90",
"A"=>"65", "B"=>"66", "C"=>"67",
"D"=>"68", "E"=>"69", "F"=>"70",
"G"=>"71", "H"=>"72", "I"=>"73",
"J"=>"74", "K"=>"75", "L"=>"76",
"M"=>"77", "N"=>"78", "O"=>"79",
"P"=>"80", "Q"=>"81", "R"=>"82",
"S"=>"83", "T"=>"84", "U"=>"85",
"V"=>"86", "W"=>"87", "X"=>"88",
"Y"=>"89", "Z"=>"90",
);
for($i=0;$i<strlen($name);$i++) {
$total+=$character[$name[$i]];
if($total>=256) {
$total=$total-256;
}
}
return $total;
}
This was great, except that it didn't capture every character.
I realised it's actually much simpler than this.
the simple function:
Code:
function numDir($name)
{
$total = 0; for($i=0;$i<strlen($name);$i++)
{
$total+=ord(strtoupper($name[$i])); if($total>=256)
{ $total=$total-256; } return $total;
}
}
All the game is doing is taking the ascii value for the character (in upper case) and doing the same maths,
I get a lot of you may be thinking "great but what use do I have for this?"
Well I use it for many things, my tools for character list, for my item distributor tool, for character management and renaming characters.
I hope some of you get some use out of this, nothing special, not a huge gift to the community but hoping it will make things a little simpler for some of you.
Last edited: