[Release] Police Spike strip non-scripthook version

that a nice little update :), am happy to see people improving the code

1 Like

Is there a way to make it so it spawns in front of you instead of a set heading and position?

Make it get the players heading and set the object to that position, simple

Mind showing a screenshot?

Replace the current with this and it should work, havent tested though:

function SetSpikesOnGround()
    x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
    local heading = GetEntityHeading(GetPlayerPed(-1))

    spike = GetHashKey("P_ld_stinger_s")

    RequestModel(spike)
    while not HasModelLoaded(spike) do
      Citizen.Wait(1)
    end

    local object = CreateObject(spike, x+1, y, z-2, true, true, false) -- x+1
    PlaceObjectOnGroundProperly(object)
    SetEntityHeading(object, heading)
end
1 Like

Works great, although with the latest edit posted yesterday by @sadboilogan, the spike spawns on the side of the player. An improvement over the original, which spawned it behind the player.

Only issue I’m having is it sometimes is not visible… Maybe it’s spawning it under the ground when the ground is uneven?

Also, Is there any way to also have this work on AI vehicles and not just player vehicles?

1 Like

Sometimes the PlaceObjectOnGroundProperly(object) native is sometimes weird and doesnt set on the ground properly i believe, you could possible try make it dynamic and spawn a bit higher so it falls into place

Have you tried using SetEntityCoords instead?

Is it synchronised between players ? Do other players can have their tires exploding ?

No need when you can just edit the CreateObject part up a bit and changing the last false to true (just to make it fall)

Regarding what Denziel said, how would you make it spawn directly infront of you?

Change the coords of where it spawns

It is all synced between the players

Agree with @Deziel0495 that it would be nice if this worked on AI vehicles.

Hi, here it’s my version of spike strip from my french rp server n3mtv - Have a good time :slight_smile:

If you use a menu for cop, put it in a same files where you have your menu.

https://pastebin.com/czbjd9Gm

2 Likes

Thanks!

How do we use it mate? Is the first lot of code server and the other client?

This is what I like to see people helping each other and improving the code, and Couga thats a nice update i like how you shorted the code :slight_smile:

1 Like

Thanks it’s a pleasure :slight_smile:

as in the F5 cop menu where you go on duty?

why the barrier the harrow always appear in the same direction?

1 Like