Disable car moving, pushing
#1

Hello, I want to disable car moving and pushing.
I want all the cars can move only if you are in the car as driver and you are driving the car.
Any ideas how that's possible?
Reply
#2

Quote:
Originally Posted by bobsona
Посмотреть сообщение
Hello, I want to disable car moving and pushing.
I want all the cars can move only if you are in the car as driver and you are driving the car.
Any ideas how that's possible?
If you're talking about the player pushing the car, That is not possible to disable from what i think.
Reply
#3

https://sampwiki.blast.hk/wiki/OnUnoccupiedVehicleUpdate
Reply
#4

Any example code for my case with OnUnoccupiedVehicleUpdate?
Reply
#5

pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
        new Float: pos[3];
        GetTrunkPos(vehicleid, pos[0], pos[1], pos[2]);
        if(IsPlayerInRangeOfPoint(playerid, 4.5, pos[0], pos[1], pos[2]))
        {
                GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
                SetVehiclePos(vehicleid, pos[2], pos[1], pos[2]);
        }
    return 1;
}
You can try doing something like this.
Reply
#6

Quote:
Originally Posted by Abagail
Посмотреть сообщение
pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
        new Float: pos[3];
        GetTrunkPos(vehicleid, pos[0], pos[1], pos[2]);
        if(IsPlayerInRangeOfPoint(playerid, 4.5, pos[0], pos[1], pos[2]))
        {
                GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
                SetVehiclePos(vehicleid, pos[2], pos[1], pos[2]);
        }
    return 1;
}
You can try doing something like this.
Basically the same as this, but with one suggestion:
1. Save the vehicle position when a player exits it. Save it into a global array.
2. OnUnoccupiedVehicleUpdate if the position has changed by more than 0.1, then teleport the vehicle back to the last recorded position (from when the player exited) and return 1 to sync the update to all players.
Reply
#7

How can I save the vehicle position when a player exits it into a global array?
For the second point I could not understand what you mean exactly.
I apologize for the stupid questions, but I'm still a beginner in PAWN scripting.
The syntax is still difficult for me.
Reply
#8

pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
    new Float: pos[3];
    GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
    SetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
    return 0;
}
Reply
#9

This callback is called VERY frequently, I suggest you to return 0 so that it won't be synchronized to anyone else in case if a player is trying to push it. But that would become hassle if other cars hit them and they were supposed to move, or in cases like an explosion.

I see no way to avoid players pushing the vehicle efficiently on SA-MP right now, other than increasing it's mass (client modification will be required). But since the main post asks that vehicle shouldn't be moved unless it has got a driver, it's better to use "return 0" under OnUnoccupiedVehicleUpdate callback.
Reply


Forum Jump:


Users browsing this thread: