Sign in to follow this  
Captien

Spike Strips (I know)

Recommended Posts

Captien    29

Hello Guys,

After making this script i was noticed that there is already a spike that can pop the tires, so i thought I would give this out as a Training to me. So why not share it with the community.

This script makes you create spike strip anywhere and remove it so you can pop out some cars :P (Pretty funny script tho).

Spoiler

Client-side:

mp.events.add('breaktyres', (vehicle) => { //Event that break the tires of the vehicle.
    vehicle.setTyreBurst(0, false, 1000);
    vehicle.setTyreBurst(1, false, 1000);
    vehicle.setTyreBurst(4, false, 1000);
    vehicle.setTyreBurst(5, false, 1000);
    vehicle.setBurnout(true);
    setTimeout(_ => {
        vehicle.setBurnout(false);
    }, 2000)
})

Server-side:

let strips = {}
let colshape_toggle = false;

function createspike(player, strip, pos) {
    player.playAnimation('[email protected][email protected]@idle_a', 'idle_b', 1, 49)
    let object = mp.objects.new(mp.joaat('p_stinger_03'), pos, [0, 0, 0]);
    let colshape = mp.colshapes.newSphere(pos.x, pos.y, pos.z, 3)
    if (strip === 'strip1') strips[player.name].strip1 = object;
    else {
        strips[player.name].strip2 = object
    }
    setTimeout(_ => {
        player.stopAnimation();
    }, 1000)
    player.notify('Spike was created successfully')
    mp.events.add('playerEnterColshape', (player, shape) => {
        if (!colshape_toggle) {
            return false;
        }
        if (shape == colshape && player.vehicle) {
            player.call('breaktyres', player.vehicle)
        }
    })
}

mp.events.addCommand('add', (player) => {
    if (strips[player.name] === undefined) {
        strips[player.name] = {
            strip1: null,
            strip2: null
        }
    }
    let pos = player.position;
    pos.y += 1
    pos.z -= 1
    if (strips[player.name].strip1 === null) {
        createspike(player, 'strip1', pos)
        colshape_toggle = true;
    } else if (strips[player.name].strip2 === null) {
        createspike(player, 'strip2', pos)
        colshape_toggle = true;
    } else {
        player.notify('You have reached the maximum number of Stingers (2). Please remove the stingers before deploying another.')
        return false;
    }
})

mp.events.addCommand('remove', (player) => {
    if (strips[player.name] === undefined || strips[player.name].strip1 === null)
        return player.notify('You did not deploy any stingers to remove.')

    if (strips[player.name].strip1 != null) {
        let object = strips[player.name].strip1;
        object.destroy();
        strips[player.name].strip1 = null;
        colshape_toggle = false;
    }

    if (strips[player.name].strip2 != null) {
        let object = strips[player.name].strip2;
        object.destroy();
        strips[player.name].strip2 = null;
        colshape_toggle = false;
    }

    player.notify('Successfully removed all Spike Stingers')
})

Pretty Beginner script. Feel free to do what you want with it.

Thanks anyways

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.