[Snippet] Allow players to carjack other players!

Hello beautiful people :revolving_hearts:

It’s 2021 and I’ve not posted anything in a long time so here goes, 3 years of confusion has amounted to this moment, I’ve always wanted my players to be able to drag other players out of their vehicles, after numerous failed attempts in the past playing with random natives and other strange methods - I finally sussed it, anyone else feel free to chime in and say “I already knew this!” but you never posted it here!

Turns out, the default relationship group the player is set into marks others within the same group relationship type Respect, this means they won’t be able to do certain devious actions such as dragging them out of vehicles and maybe some other stuff, who knows! Setting the relationship type to anything higher than 1 will enable this functionality.

Feel free to find the full list of relationship types here: GET_RELATIONSHIP_BETWEEN_GROUPS - Cfx.re Docs

Anyway, place the line below anywhere in a client script to enable this functionality:

SetRelationshipBetweenGroups(2, `player`, `player`)

If you learn anything else that this or any subsequent relationship editing plays a role in, let me know!

6 Likes

Ohhhh, interesting idea… Much love for the help you fucking legend.

Hello this native must be in a loop or it is not necessary? Thank you for this help I had no idea.

No it isn’t required to be run every frame.

1 Like

Thank you :slight_smile:

1 Like

This is good. But how can we sit in passenger seat? I mean in GTA:O if we hold F, we can drag players out of their vehicles. But if you just press the F, your character will sit in passenger seat.

With this native you can’t sit in passenger seat :frowning:

You could make it so holding F near a vehicle temporarily sets the driver to the relationship, thus, allowing them to be dragged out.

2 Likes

How do you do this?

Because you have it on 5, set it to 3

So basically if I just wanted to create it’s own script, it would just look like this for the client.lua right? Figured having it’s own script could come in handy for future needs, if we wanted to change anything between other groups.

I have the types commented out, just there for future reference.

Citizen.CreateThread(function()
SetRelationshipBetweenGroups(2, `player`, `player`)
end)

-- Relationship types:  0 = Companion,  1 = Respect,  2 = Like,  3 = Neutral,  4 = Dislike,  5 = Hate,  255 = Pedestrians

That still doesn’t work. You’d probably have to make a custom script like the OP was saying to make it only temporarily set it.

I have quickly coded up a solution, if you hold Shift + F, you will be able to drag the player out the vehicle or punch them out from the passenger side.

Citizen.CreateThread(function()
    while true do
        if IsControlJustPressed(0, 21) then
            SetRelationshipBetweenGroups(2, 'player', 'player')
        end
        if IsControlJustReleased(0, 21) then
            SetRelationshipBetweenGroups(1, 'player', 'player')
        end
        Citizen.Wait(0)
    end
end)
2 Likes