Author Topic: [Solved] Packaged functions teleport player  (Read 937 times)

So I was creating a playertype that can't pick up guns/get in vehicles/get killed, etc. Well the packaged functions work fine for doing that to said playertype, however any other playertype gets teleported to 0 0 0 and I don't know what I did wrong, I just kinda named the arguments off of what they'd return in an echo, and added more to the end in case I left any out.
Code: [Select]
datablock playerData(Builder : PlayerStandardArmor)
{
Builder = true;
uiName = "Builder";
};

package ThorsBuilder
{
function weaponImage::onMount(%this,%player,%something,%a,%b,%c,%d,%e,%f)
{
if(%player.Datablock !$= "Builder")
{
parent::onMount(%this,%player,%something,%a,%b,%c,%d,%e,%f);
}
else
{
%name = %this.getName();
if(%name $= (PrintGunImage || WrenchImage || hammerImage))
{
parent::onMount(%this,%player,%something,%a,%b,%c,%d,%e,%f);
}
}
return;
}

function armor::onMount(%this,%player,%object,%something,%a,%b,%c,%d,%e,%f)
{
if(%player.Datablock !$= "Builder")
{
parent::onMount(%this,%player,%object,%something,%a,%b,%c,%d,%e,%f);
}
return;
}

function armor::onCollision(%this,%player,%Object,%something,%a,%b,%c,%d,%e,%f)
{
if(%player.Datablock !$= "Builder")
{
parent::onMount(%this,%player,%object,%something,%a,%b,%c,%d,%e,%f);
}
return;
}

function WheeledVehicleData::onCollision(%this,%object,%player,%cords,%a,%b,%c,%d,%e,%f)
{
if(%player.Datablock !$= "Builder")
{
parent::onCollision(%this,%object,%player,%cords,%a,%b,%c,%d,%e,%f);
}
return;
}

function GameConnection::onDeath(%this, %sourcePlayer, %sourceClient, %damageType, %damageArea)
{
if(%this.player.Datablock $= "Builder")
{
if(%damageType == $damageType::Self Delete)
{
parent::onDeath(%this, %sourcePlayer, %sourceClient, %damageType, %damageArea);
}
return;
}
parent::onDeath(%this, %sourcePlayer, %sourceClient, %damageType, %damageArea);
}
};
activatePackage(ThorsBuilder);
« Last Edit: January 08, 2015, 12:19:07 AM by Thorfin25 »

Well I'm not sure about the whole teleporting thing but I can tell you that if(%name $= (PrintGunImage || WrenchImage || hammerImage)) is definitely not something you can do

Yeah I just kinda ignored that part until I figured out why it'd teleport me. I was using default add-ons as well apart from what gets loaded through system add-ons.

Can you tell us under what conditions the other playertypes are teleported to origin? Is it when any of those functions are called, or just one of them?

Well I tested it with a variety of situations, when picking up a weapon, so the weaponImage would get called, as well as trying to mount a vehicle, so that'd be the ::collision functions, I haven't tested out the killing part yet but Self Delete works just fine with it. And I'd always get teleported to 0 0 0 no matter where the item/vehicle was located at. I could go back and add in the echos again if needed.

In the armor::onCollision function, you're calling the parent's onMount. You meant to call onCollision
Also, these functions don't work how you think they do. They're callbacks, they're called after the event that you're trying to stop has already happened. For example, overwriting onDeath won't stop you from dying, it'll stop what happens after you die: (setting your camera, giving you a death message, and allowing you to respawn, etc) from happening.
« Last Edit: January 07, 2015, 09:21:46 PM by Headcrab Zombie »

The collision ones will prevent someone from actually mounting a vehicle though.

When exactly do other players get teleported? From mounting a vehicle?

When exactly do other players get teleported? From mounting a vehicle?
Whenever colliding with something
The problem is
In the armor::onCollision function, you're calling the parent's onMount. You meant to call onCollision

He should really fix that..

I did fix it, but I just now got around to testing it, and it works fine now. Thanks :)