A fix for Server_Roleplay?

Author Topic: A fix for Server_Roleplay?  (Read 1351 times)

When you hover over players there is suppose to be a rainbow text that says, "You do not recognize this person." but instead, it's black and spams the console with
Quote
Add-Ons/Server_Roleplay/server.cs (618): Unable to find function HSVtoRGB

link to addon: https://forum.blockland.us/index.php?topic=292093.0
pls help

Ok that's weird there's a color.txt librbary in which functions are defined for rgbToHex, hexToRgb, compToHex and hexToComp but hsvToRGB isn't defined anywhere. It is indeed called when looking at someone though. it's also only called then and nowhere else. Since I am not in the ability to test this 9especially since I need a second person), try deleting that line entirely and changing line 619 to
Code: [Select]
commandToClient(%this.client, 'centerPrint', "<br><br><br><br><color:FFFFFF>You do not recognize this person.", 0.2);. It'll make it flat white but it whould work.

Noedit: I really butchered the formatting and grammar of that.

Ok that's weird there's a color.txt librbary in which functions are defined for rgbToHex, hexToRgb, compToHex and hexToComp but hsvToRgb isn't defined anywhere. It is indeed called when looking at someone though. It's also only called then and nowhere else. Since I am not in the ability to test this (especially since I need a second person), try deleting line 618 entirely and changing line 619 in server.cs to:

Code: [Select]
commandToClient(%this.client, 'centerPrint', "<br><br><br><br><color:FFFFFF>You do not recognize this person.", 0.2);
It'll make it flat white but it whould work.

Note to do this in the serverside add-on, not the clientside one.

Code: (lib/hsvToRgb.cs) [Select]
// /was/ adapted from https://gist.github.com/Jadzia626/2323023 (now a dead link)

function hsvToRgb(%hsv) {
  %iH = getWord(%hsv, 0) * 360;
  %iS = getWord(%hsv, 1) * 360;
  %iV = getWord(%hsv, 2) * 360;

  if(%iH < 0)   %iH = 0;
  if(%iH > 360) %iH = 360;
  if(%iS < 0)   %iS = 0;
  if(%iS > 100) %iS = 100;
  if(%iV < 0)   %iV = 0;
  if(%iV > 100) %iV = 100;
  %dS = %iS/100.0;
  %dV = %iV/100.0;
  %dC = %dV*%dS;
  %dH = %iH/60.0;
  %dT = %dH;
  while(%dT >= 2.0) %dT -= 2.0;
  %dX = %dC*(1-mAbs(%dT-1));

  switch(mFloor(%dH)) {
    case 0:
      %dR = %dC; %dG = %dX; %dB = 0.0;
    case 1:
      %dR = %dX; %dG = %dC; %dB = 0.0;
    case 2:
      %dR = 0.0; %dG = %dC; %dB = %dX;
    case 3:
      %dR = 0.0; %dG = %dX; %dB = %dC;
    case 4:
      %dR = %dX; %dG = 0.0; %dB = %dC;
    case 5:
      %dR = %dC; %dG = 0.0; %dB = %dX;
    default:
      %dR = 0.0; %dG = 0.0; %dB = 0.0;
  }

  %dM  = %dV - %dC;
  %dR += %dM; %dG += %dM; %dB += %dM;
  %dR *= 255; %dG *= 255; %dB *= 255;

  return round(%dR) / 360 SPC round(%dG) / 360 SPC round(%dB) / 360;
}

Fixed add-on: Server_Roleplay

So, HSVtoRGB is a default function.
The reason why it doesn't work is because it is executed with client scripts only, so the function won't load on dedicated servers where only server scripts are loaded.

I have re-uploaded the fixed add-on with the default HSVtoRGB function used in Blockland, so if you downloaded it before the date/time of this post you will need to re-download it because the function I posted beforehand is incorrect.


NOEDIT: Some colors don't display and just centerprint out red. But it doesn't spam the console anymore, so I am fine with it.

NOEDIT: Some colors don't display and just centerprint out red. But it doesn't spam the console anymore, so I am fine with it.

Fixed.