Author Topic: How to cancel %v.player.kill();  (Read 3159 times)

That code is horrid. That for loop makes absolutely no sense what soever and I don't understand at ALL what that is.



There are so many things wrong with your code, it's better to start from scratch. It makes no sense.

onVehicleExit and onPlayerSpawn are not functions, they are events (actually they are functions, but inside classes and it's not good to depend on them)

First, you'll have to found the proper function for exiting a vehicle and when the player spawns.

Oh.

What are they?

I'm a really terrible coder.


Oh.

What are they?

I'm a really terrible coder.
Do a trace and find out.

Start a game in a clean copy of blockland, and then prepare a vehicle. Use trace(1) in the console and quickly jump into the vehicle, then close the game. Look through the console log to find out what function was called when you entered the vehicle.

Do a trace and find out.

Start a game in a clean copy of blockland, and then prepare a vehicle. Use trace(1) in the console and quickly jump into the vehicle, then close the game. Look through the console log to find out what function was called when you entered the vehicle.

It appears that spawning is GameConnection::SpawnPlayer, and mounting is Armor::OnMount

I changed that code. What now?
« Last Edit: September 01, 2012, 03:34:22 PM by Deoxys And One Noob »

The problem is that the only kind of code you can put in packages are functions.  You are trying to place an if statement there which is only going to give you errors.  Place it inside the function instead.

The problem is that the only kind of code you can put in packages are functions.  You are trying to place an if statement there which is only going to give you errors.  Place it inside the function instead.

Whitch one?

 you should really learn the basics before doing stuff. :I just an opinion though

you should really learn the basics before doing stuff. :I just an opinion though

ik.

I know most of them, though.

EDIT: If armor::OnMount means entering a vehicle, then armor::OnDismount means exiting a vehicle, right?
« Last Edit: September 01, 2012, 10:04:15 PM by Deoxys And One Noob »

EDIT: If armor::OnMount means entering a vehicle, then armor::OnDismount means exiting a vehicle, right?
Yes. Logic = your best friend.

Great!

Err, what's the replacement for %v.player.kill.cancel();?

what's the replacement for %v.player.kill.cancel();
You can't cancel a function with another function while the first function is running. You need to edit the function itself or somehow make the player invincible.

You can't cancel a function with another function while the first function is running. You need to edit the function itself or somehow make the player invincible.

I think you can do that with a function, no?

for forget's sake

also you can only do this at max 30 seconds.
Code: [Select]
package VehicleStuff
{
    function Armor::onMount( %this , %player , %vehicle , %seat )
    {
        %cn = %vehicle.getClassName();
        if(  %cn $= "WheeledVehicle" || %cn $= "FlyingVehicle" || %cn $= "HoverVehicle" )
            %player.client.killSchedule = %player.schedule( 30000 , "kill" );
        parent::onMount( %this , %player , %vehicle , %seat );
    }
    function GameConnection::spawnPlayer( %this )
    {
        parent::spawnPlayer( %this );

        if(isEventPending( %this.killSchedule )
            cancel( %this.killSchedule );
    }
};
« Last Edit: September 02, 2012, 06:56:52 PM by Axolotl2 »

How will that prevent the kill function from being called?

How will that prevent the kill function from being called?
because player.client.killSchedule is the scheduleID of the 30-second player.kill event.

when the player spawns, client.killSchedule is cancelled.