This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [QUESTION] Calculating playerBytes  (Read 3011 times)

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
[QUESTION] Calculating playerBytes
« on: November 28, 2015, 06:37:13 pm »
Hey!
How can I calculate the needed value of playerBytes in order to change a character in navicat, and not in the client?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.

Rangorn

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 291
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #1 on: November 28, 2015, 11:24:24 pm »
[deleted]
« Last Edit: May 17, 2016, 02:42:33 pm by Admin »

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #2 on: December 01, 2015, 06:20:32 pm »
Quote from: "Rangorn"
Hey.

This is how i do in PHP :

Code: [Select]
 
        $b = $row['playerBytes']; // PlayerBytes in Character table
        $b2 = $row['playerBytes2']; // PlayerBytes in Character table

        // Set Character Features
        $ha = ($b>>16)%256; // Hairs
        $hc = ($b>>24)%256; // Hairs color
        $fa = ($b>>8)%256; // Face
        $sk = $b%256; // Skin
        $fh = $b2%256; // Facial / Others


Ehm... You overestimate me.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #3 on: December 02, 2015, 08:24:38 pm »
Basically, my knowledge of PHP is not even enough for Hello world. Could you explain the mathematical way of calculating it?

Also, if its possible to do this via vb.net, I'll be happy to know
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.

Rochet2

  • Contributors
  • Polygonshifter
  • *****
  • Posts: 59
    • View Profile
    • http://rochet2.github.io/
Re: [QUESTION] Calculating playerBytes
« Reply #4 on: December 02, 2015, 08:46:39 pm »
in most programming languages and elsewhere (C, C++, java, lua, SQL, ... whatever else) you would use almost exact same code.
I myself wouldnt bother with the maths. instead just look up what %, << and >> operators do. % is modulo (3%2 = 1) and the rest are bit shifting operators.
Everything else is just a bunch of variables.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #5 on: December 03, 2015, 09:54:01 pm »
http://phptester.net/

It returns

NOTICE Undefined variable: row on line number 2

NOTICE Undefined variable: row on line number 3
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.

Rangorn

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 291
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #6 on: December 03, 2015, 10:00:49 pm »
[deleted]
« Last Edit: May 17, 2016, 02:43:23 pm by Admin »

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #7 on: December 03, 2015, 10:36:05 pm »
It just crashes and says This application is free so please don't break it !
Another website says



Parse error:  syntax error, unexpected '&lt;' in <>>[...][...] on line 1



Also, is there a backward code? To get the bytes from needed character settings?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.

Kaev

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 308
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #8 on: December 04, 2015, 05:22:05 pm »
Try it without the php tags:
Code: [Select]
$b = 17367552; // PlayerBytes in Character table
$b2 = 33554436; // PlayerBytes2 in Character table

// Set Character Features
$ha = ($b>>16)%256; // Hairs
$hc = ($b>>24)%256; // Hairs color
$fa = ($b>>8)%256; // Face
$sk = $b%256; // Skin
$fh = $b2%256; // Facial / Others

echo "Hairs : ".$ha."<br>";
echo "Hair Color : ".$hc."<br>";
echo "Face : ".$fa."<br>";
echo "Skin : ".$sk."<br>";
echo "Facial/Other : ".$fh."<br>";
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #9 on: December 04, 2015, 08:47:47 pm »
Thanks, Kaev, it works! What about a backward conversion?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #10 on: December 04, 2015, 11:09:14 pm »
Code: [Select]
$a= ($z>>24)&0xff;
$b= ($z>>16)&0xff;
$c= ($z>>8)&0xff;
$d= ($z>>0)&0xff;
$z = ($a<<24) |  ($b<<16) |  ($c<<8) |  ($d<<0);
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #11 on: December 05, 2015, 10:59:54 am »
Quote from: "schlumpf"
Code: [Select]
$a= ($z>>24)&0xff;
$b= ($z>>16)&0xff;
$c= ($z>>8)&0xff;
$d= ($z>>0)&0xff;
$z = ($a<<24) |  ($b<<16) |  ($c<<8) |  ($d<<0);
Which of these are what? I mean skin color, facial features, etc.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #12 on: December 05, 2015, 11:07:38 am »
Please map the four numbers to the four names yourself. It really isn't hard.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #13 on: December 05, 2015, 11:32:07 am »
Quote from: "schlumpf"
Please map the four numbers to the four names yourself. It really isn't hard.
It isnt, but there should be five numbers. Hair, Hair colour, Skin colour, Face and Facial features
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [QUESTION] Calculating playerBytes
« Reply #14 on: December 05, 2015, 12:21:15 pm »
There is also b and b2.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »