Author Topic: How to bypass height control? [SOLVED]  (Read 6847 times)

By not parenting the last argument, you are breaking some features that use Armor::onTrigger. You should also use the last argument, or else all this will be called when they push space, and again when it's released.
This, never "leave arguments out"
Many languages will recognize doing so as a completely different function

By not parenting the last argument, you are breaking some features that use Armor::onTrigger. You should also use the last argument, or else all this will be called when they push space, and again when it's released.
Ok, will do.
This, never "leave arguments out"
Many languages will recognize doing so as a completely different function
Noted, thanks!

Ok, I've figured out what's causing the non-responsive spacebar issue - Support_HeightControl. Any idea how to get around this issue without removing the addon completely?

Ok, I've figured out what's causing the non-responsive spacebar issue - Support_HeightControl. Any idea how to get around this issue without removing the addon completely?
No. It's a really badly made add-on.

Crap. I don't want to have to use left click, but unless someone can figure out how it can be bypassed, I'll have to do that. I'll still look at the code though to try and fix it, though.

can you paste the code the heightcontrol addon uses for ::onTrigger?

can you paste the code the heightcontrol addon uses for ::onTrigger?
Yes, when I get to my computer.

Ok, here's the client (pretty sure it's the issue):
Code: [Select]
function clientcmdHC_client_ping(%x)
{
commandtoserver('HC_client_pong',%x);
$HCServer = 1;
}

package supportheightcontrol
{
function crouch(%val)
{
if($HCServer)
{
if(%val==1)
commandtoserver('hoverDescend');
else
commandtoserver('hoverStop');
}
Parent::crouch(%val);
}
function jump(%val)
{
if($HCServer)
{
if(%val==1)
commandtoserver('hoverAscend');
else
commandtoserver('hoverStop');
}
Parent::jump(%val);
}
function disconnect(%a)
{
if($HCServer)
{
commandtoserver('hoverStop');
$HCServer = 0;
}
Parent::disconnect(%a);
}
};
activatePackage(supportheightcontrol);

And here's the server:

Code: [Select]
$Server::HeightControl::delay=100;

//Ping-Pong is from the compass mod. All credits go to the original creator for this.
//This is a safe and good way to check if the server has the mod and if the client has the clientside.
function servercmdHC_client_pong(%client,%x)
{
if(%x == %client.HCchecknumber)
{
%client.hasHeightControlClient = 1;
}
}
package HeightControlServer
{
function GameConnection::loadMission(%client,%a,%b,%d,%e,%f)
{
Parent::loadMission(%client,%a,%b,%d,%e,%f);
%client.HCchecknumber = getRandom(0,100);
commandtoclient(%client,'HC_client_ping',%client.HCchecknumber);
}

//Slight support for people who don't have the client. :3
//People without the client will only be able to 'spam' the jump key to go up.
//They will have to rely on gravity to go down. :S
function FlyingVehicleData::onTrigger(%this,%obj,%client)
{
if(!%client.hasHeightControlClient)
{
%data= %obj.getDatablock();
if(%data.heightcontrol)
{
if(getsimtime() >= %obj.lastHoverMove+$Server::HeightControl::delay)
{
%velocity= "0 0 "@%data.ascendVelocity;
%obj.setVelocity(vectorAdd(%obj.getVelocity(),%velocity));
%obj.lastHoverMove=getsimtime();
}
}
}
}

function Armor::onMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f)
{
Parent::onMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f);
if(isObject(%player.client) && %obj.getDatablock().heightcontrol)
{
%player.client.bottomPrint("\c6Heightcontrol has been detected in this vehicle. Type /HChelp for help.",3);
}
}
};
ActivatePackage(HeightControlServer);

function servercmdHChelp(%client)
{
if(%client.hasHeightControlClient)
{
messageclient(%client,'',"When in a vehicle with Heightcontrol enabled, press your jump-key to ascend and your crouch-key to descend.");
messageclient(%client,'',"You can also hold the keys to automatically ascend/descend.");
}
else
{
messageclient(%client,'',"You do not have the add-on Support_HeightControl and thus you can only ascend by clicking the jump key to ascend.");
messageclient(%client,'',"People with the add-on have the following extra's (due to client sided code):");
messageclient(%client,'',"- Descend using crouch key.");
messageclient(%client,'',"- Ascend/Descend automatically by holding the jump/crouch key.");
if(%client.hasRTB)
messageclient(%client,'',"<a:rtb-3612>Click here to use RTB to download Support_HeightControl.</a>");
else
messageclient(%client,'',"\c6You can download Support_HeightControl by visiting the following link: <a:http://forum.returntoblockland.com/dlm/viewFile.php?id=3612>Support_HeightControl on RTB</a>.");
}
}

function servercmdhoverAscend(%client)
{
%client.hoverTrigger = 1;
hoverLoop(%client,1);
}
function servercmdhoverDescend(%client)
{
%client.hoverTrigger = 1;
hoverLoop(%client,0);
}

function hoverLoop(%client,%dir)
{
if(%client.hoverTrigger)
{
%player=%client.player;
if(!%player)
return;
%mnt= %player.getObjectMount();
if(!isObject(%mnt))
return;
%mountObj= %mnt.getMountNodeObject(0);
if(%mountObj!$=%player)
return;
%data= %mnt.getDatablock();
if(%data.heightcontrol)
{
if(getsimtime() >= %mnt.lastHoverMove+$Server::HeightControl::delay)
{
if(%dir==1)
%velocity= "0 0 "@%data.ascendVelocity;
else
%velocity= "0 0 "@%data.descendVelocity;
%mnt.setVelocity(vectorAdd(%mnt.getVelocity(),%velocity));
%mnt.lastHoverMove=getsimtime();
%client.HChoverMove = schedule($Server::HeightControl::delay,0,hoverLoop,%client,%dir);
}
}
}
}

function servercmdhoverStop(%client)
{
cancel(%client.HChoverMove);
%client.hoverTrigger=0;
}

Pretty sure it has to do with either function jump() or not having all the arguments in onTrigger.

I figured it out. In my script, I used WheeledVehicleData::onTrigger instead of Armor::onTrigger. Because height control uses FlyingVehicleData::onTrigger, there are no conflicts. Thanks for the help, everybody!

I figured it out. In my script, I used WheeledVehicleData::onTrigger instead of Armor::onTrigger. Because height control uses FlyingVehicleData::onTrigger, there are no conflicts. Thanks for the help, everybody!
Sorry for the very late response, i should keep more tabs on the coding topics.
Yes, the old heightcontrol only really supported flying vehicle (datablocks).
I am sorry for the inconvience, this will get fixed with the new version of Heighcontrol.
I will PM you when i got more information so we can look into the compatibility. :)