Blockland Forums > Modification Help
Need help with player throwing Script
Crysist:
--- Code: ---package Throw
{
function armor::onTrigger(%this, %obj, %triggerNum, %val)
{
Parent::onTrigger(%this,%obj,%triggerNum,%val);
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 2), %client.player.getEyePoint()), $typeMasks::playerObjectType, %obj); //< what did you do here?
%client = %obj.client;
if(%obj.dudemounted==1)
{
dudecheck(%dude, %obj);
return;
}
if(isObject(%target))
{
%dude = %target;
%target.playThread(%slot, "death1");
%this.player.mountobject(1, %dude);
%this.dudemounted=1;
}
}
};
activatepackage(Throw);
function dudecheck(%dude, %obj)
{
%dude.dismount();
%dude.setVelocity(vectorAdd(%obj.getVelocity(),vectorScale(%obj.client.player.getEyeVector(),8)));
%dude.client.centerprint('',"\c3" @ %this.name @ "\c2 threw you!",3);
}
--- End code ---
When I execute this code, I spawn a bot and try to 'pick him up', yet when I click him, nothing happens and anytime I just click the console says this:
--- Code: ---Add-Ons/Script_Throw/server.cs (6): Unable to find object: '' attempting to call function 'getEyePoint'
BackTrace: ->[throw]armor::onTrigger
Add-Ons/Script_Throw/server.cs (6): Unable to find object: '' attempting to call function 'getEyeVector'
BackTrace: ->[throw]armor::onTrigger
Add-Ons/Script_Throw/server.cs (6): Unable to find object: '' attempting to call function 'getEyePoint'
BackTrace: ->[throw]armor::onTrigger
Add-Ons/Script_Throw/server.cs (6): Unable to find object: '' attempting to call function 'getEyePoint'
BackTrace: ->[throw]armor::onTrigger
Add-Ons/Script_Throw/server.cs (6): Unable to find object: '' attempting to call function 'getEyeVector'
BackTrace: ->[throw]armor::onTrigger
Add-Ons/Script_Throw/server.cs (6): Unable to find object: '' attempting to call function 'getEyePoint'
BackTrace: ->[throw]armor::onTrigger
--- End code ---
Yes, all 6 of those... Error thingies. There are no problems with that script (nothing comes up when I scroll up in the console to the add-on). Somebody help please.
Also Amade helped me when I had console errors with it. I took from the clickpush script and edited it a lot so it mounts players in a person's hands and when they click next they'd throw them.
lilboarder32:
You were calling those functions before %client was even defined.
Crysist:
--- Quote from: lilboarder32 on June 12, 2010, 07:07:02 PM ---You were calling those functions before %client was even defined.
--- End quote ---
So I should put the %client = %obj.client; before the %target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 2), %client.player.getEyePoint()), $typeMasks::playerObjectType, %obj)?
Crysist:
Ok I did it, now new problem:
When I click it makes the bot play the animation, yet he doesn't mount and this happens even if I click him while holding a wrench or something. It just gives this console error:
--- Code: ---Add-Ons/Script_Throw/server.cs (17): Unable to find object: '' attempting to call function 'mountObject'
BackTrace: ->[throw]armor::onTrigger
Add-Ons/Script_Throw/server.cs (17): Unable to find object: '' attempting to call function 'mountObject'
BackTrace: ->[throw]armor::onTrigger
--- End code ---
Code:
--- Code: ---package Throw
{
function armor::onTrigger(%this, %obj, %triggerNum, %val)
{
Parent::onTrigger(%this,%obj,%triggerNum,%val);
%client = %obj.client;
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 2), %client.player.getEyePoint()), $typeMasks::playerObjectType, %obj); //< what did you do here?
if(%obj.dudemounted==1)
{
dudecheck(%dude, %obj);
return;
}
if(isObject(%target))
{
%dude = %target;
%target.playThread(%slot, "death1");
%this.player.mountobject(1, %dude);
%this.dudemounted=1;
}
}
};
activatepackage(Throw);
function dudecheck(%dude, %obj)
{
%dude.dismount();
%dude.setVelocity(vectorAdd(%obj.getVelocity(),vectorScale(%obj.client.player.getEyeVector(),8)));
%dude.client.centerprint('',"\c3" @ %this.name @ "\c2 threw you!",3);
}
--- End code ---
Crysist:
Ok I saw from the error before that %client wasn't defined or something before the clicking thing. But for this error I though what is '%this' and I noticed that I had to use %client instead. So I used it and when I clicked a bot ingame, the error didn't appear yet same thing; bot plays death animation. Yet also when I hold down click, he 'dies', yet when I let go he 'dies' again.
--- Code: ---package Throw
{
function armor::onTrigger(%this, %obj, %triggerNum, %val)
{
Parent::onTrigger(%this,%obj,%triggerNum,%val);
%client = %obj.client;
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 2), %client.player.getEyePoint()), $typeMasks::playerObjectType, %obj); //< what did you do here?
if(%obj.dudemounted==1)
{
dudecheck(%dude, %obj);
return;
}
if(isObject(%target))
{
%dude = %target;
%target.playThread(%slot, "death1");
%client.player.mountobject(1, %dude);
%client.dudemounted=1;
}
}
};
activatepackage(Throw);
function dudecheck(%dude, %obj)
{
%dude.dismount();
%dude.setVelocity(vectorAdd(%obj.getVelocity(),vectorScale(%obj.client.player.getEyeVector(),8)));
%dude.client.centerprint('',"\c3" @ %this.name @ "\c2 threw you!",3);
}
--- End code ---
Also is there a way to check if %client is holding an item in their hands?