SA-MP Forums Archive
Converting strings - 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)
+--- Thread: Converting strings (/showthread.php?tid=443180)



Converting strings - IgrexolonO - 10.06.2013

Hiho! I was thinking, is there any simple way to convert strings in pawno to values since integer, ending on hex.

Regards.

// I'm not talking about strings like "123", just normal characters ~` "hello", "welcome world" etc.


Re: Converting strings - Scenario - 10.06.2013

I don't quite understand what you're asking...


Re: Converting strings - rpg894 - 10.06.2013

like this?
pawn Код:
/*Credits to Dracoblue*/
stock udb_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;
}
Copied from Kush's y_ini tutorial


Re: Converting strings - IgrexolonO - 11.06.2013

Yes! This is exactly what I want! Thank you rpg.