Author Topic: Making a Projectile Start a JVS_Content Brick  (Read 2251 times)

Code: [Select]
function TezRPBatonProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
        {
                serverPlay3D(hammerHitSound, %pos);
               
                if((%col.getType() & $typeMasks::fxBrickObjectType))
                {
                        if(isObject(%col.content))
                        {
                                %col.fakeKillBrick("1 1 1", 5);
                               
                                %col.schedule(3000, "contentstart");
                        }
                       
                        return;
                }

It doesnt seem to be working...  I'm trying to make it open doors, but when that failed I tried to make it atleast fake brick kill them.  I'd prefer it to just start the content instead of fake brick killing it, if thats possible?  Anyone?

fxDTSBrick::contentStart has more than one argument.

Also, if you're doing it for a cityrp, don't bother. People can do things like put bricks in front of their doors, make it non-raycasting, etc. that will break your baton.

fxDTSBrick::contentStart has more than one argument.

Also, if you're doing it for a cityrp, don't bother. People can do things like put bricks in front of their doors, make it non-raycasting, etc. that will break your baton.

It is city rp, but I still want to do it.  I'm not sure what to do, can you show me how to revise the code?  Thanks

It is city rp, but I still want to do it.  I'm not sure what to do, can you show me how to revise the code?  Thanks
No, because it's basically impossible to stop people using events/other JVS content in locked areas/colliding bricks etc. to make the door impossible to open except to them.

No, because it's basically impossible to stop people using events/other JVS content in locked areas/colliding bricks etc. to make the door impossible to open except to them.

Well thats the point, the police are suppsoed to be able to bust in.

If you are using contentStart, this has to obey the "door is blocked" check. There are too many ways of forcing a brick in front of the door to have collision and stop it opening to the baton until a separate button/touch switch/content restriction is triggered for the person who owns it.

Hmmm, well this doesn't seem to be working.  Anyone know why?

Code: [Select]
function TezRPBatonProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
        {
                serverPlay3D(hammerHitSound, %pos);
               
                if((%col.getType() && $typeMasks::fxBrickObjectType))
                {
                 %col.ForceDoor(%col.client);
                }
        }

function fxDTSBrick::ForceDoor(%brick, %client)
{
 // Is door
 if (!isObject(%brick.shape))
  return 1;
 
 // Cannot open admin doors
 if (getBrickGroupFromObject(%brick).client.isAdmin)
  return 0;
 
 
 // JVS hack
 if (%brick.isContentBlocked(%client, 1, "CW") <= 0)
 {
  %brick.contentUse(%client, 0, "START", "CW");
  %brick.schedule(3000, "contentUse", %client, 0, "STOP", "CW");
 }
 else if (%brick.isContentBlocked(%client, 1, "CCW") <= 0)
 {
  %brick.contentUse(%client, 0, "START", "CCW");
  %brick.schedule(3000, "contentUse", %client, 1, "STOP", "CCW");
 }
 else
 {
  return 0;
 }
 
 return 1;
}


What doesn't work? Is there a syntax error?

contentuse? contentstart?

What doesn't work? Is there a syntax error?

Code: [Select]
Add-Ons/TezMods_CityRP/datablocks.cs (451): Unable to find object: '' attempting
 to call function 'ForceDoor'
BackTrace: ->TezRPBatonProjectile::OnCollision
« Last Edit: November 23, 2009, 09:26:59 PM by Tezuni »

Code: [Select]
if((%col.getType() && $typeMasks::fxBrickObjectType))Change "&&" to "&".

Thanks, I saw that in your pm as well.

Code: [Select]
if((%col.getType() && $typeMasks::fxBrickObjectType))Change "&&" to "&".
 

Here's the revised code, and I don't get why it's not working?  Anyone can fix it?

Code: [Select]
package PicklockPackage
{
function PicklockProjectile::onCollision(%projectile, %obj, %col, %fade, %pos, %normal)
{
%client = %obj.sourceObject.client;
if (isObject(%col))
{
if (%col.getType() & $TypeMasks::fxBrickObjectType)
%col.onPicklock(%client);
}
}

function fxDTSBrick::BrutalOpenDoor(%brick, %client)
{
// Is door
if (!isObject(%brick.shape))
return 1;

// Cannot open admin doors
if (getBrickGroupFromObject(%brick).client.isAdmin)
return 0;

// JVS hack
if (%brick.isContentBlocked(%client, 1, "CW") <= 0)
{
%brick.contentUse(%client, 0, "START", "CW");
%brick.schedule(3000, "contentUse", %client, 0, "STOP", "CW");
}
else if (%brick.isContentBlocked(%client, 1, "CCW") <= 0)
{
%brick.contentUse(%client, 0, "START", "CCW");
%brick.schedule(3000, "contentUse", %client, 1, "STOP", "CCW");
}
else
{
return 0;
}

return 1;
}

function fxDTSBrick::onBashDoor(%brick, %client)
{
if (!isObject(%brick.shape))
return;

if (!%brick.BrutalOpenDoor(%client))
commandToClient(%client, 'centerPrint', "\c6The door is batonproof.", 2);
}

function fxDTSBrick::onPicklock(%brick, %client)
{
if (!isObject(%brick.shape))
return;
%client = %obj.client;
if (%brick.BrutalOpenDoor(%client))
commandToClient(%obj.client, 'centerPrint', "\c6You have commited a crime. [\c3Breaking and Entering\c6]", 1);
                                %obj.client.TezRP(2, $TezRP::demerits::hittingInnocents);

}

};
activatePackage(PicklockPackage);

Here is the console error:

Code: [Select]
Add-Ons/TezMods_CityRP/datablocks.cs (0): Unable to find object: '' attempting t
o call function 'TezRP'
BackTrace: ->PicklockProjectile::OnCollision->fxDTSBrick::onPicklock

Code: [Select]
Add-Ons/TezMods_CityRP/datablocks.cs (0): Unable to find object: '' attempting
to call function 'TezRP'
BackTrace: ->PicklockProjectile::OnCollision->fxDTSBrick::onPicklock

Code: [Select]
function fxDTSBrick::onPicklock(%brick, %client)
{
if (!isObject(%brick.shape))
return;
%client = %obj.client;
if (%brick.BrutalOpenDoor(%client))
commandToClient(%obj.client, 'centerPrint', "\c6You have commited a crime. [\c3Breaking and Entering\c6]", 1);
                                %obj.client.TezRP(2, $TezRP::demerits::hittingInnocents);

}

Did you define GameConnection::TezRP?
%obj isn't defined.
« Last Edit: November 24, 2009, 09:35:20 PM by Club559 »

Code: [Select]
Add-Ons/TezMods_CityRP/datablocks.cs (0): Unable to find object: '' attempting
to call function 'TezRP'
BackTrace: ->PicklockProjectile::OnCollision->fxDTSBrick::onPicklock

Did you define GameConnection::TezRP?
Yes, in the server.cs it is defined.