Pawn/php/javascript problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Pawn/php/javascript problem (
/showthread.php?tid=246709)
Pawn/php problem -
Johnson_boy - 05.04.2011
I need help with converting this to php:
pawn Код:
stock num_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
I've tried:
PHP код:
function num_hash($string)
{
$length = strlen($string);
$s1 = 1;
$s2 = 0;
for($n = 0; $n < $length; $n++)
{
$s1 = strval(($s1 + $string[$n]) % 65521);
$s2 = strval(($s2 + $s1) % 65521);
}
echo ($s2 << 16) + $s1;
}
But it does not return same value.
Re: Pawn/php/javascript problem -
Johnson_boy - 08.04.2011
bump
Re: Pawn/php/javascript problem -
Johnson_boy - 18.05.2011
Anyone?
Re: Pawn/php/javascript problem -
MadeMan - 18.05.2011
PHP код:
function num_hash($string)
{
$length = strlen($string);
$s1 = 1;
$s2 = 0;
for($n = 0; $n < $length; $n++)
{
$s1 = ($s1 + ord($string[$n])) % 65521;
$s2 = ($s2 + $s1) % 65521;
}
echo ($s2 << 16) + $s1;
}
Re: Pawn/php/javascript problem -
Johnson_boy - 18.05.2011
Thanks man, that works.