Fixed unlockveh using the player id instead of ped (#2591)

* Fixed unlockveh command using the Player ID for the arguments instead of the Player Ped.

* Fixed lock/unlock vehicle door calls to use the eVehicleLockState enum.
This commit is contained in:
gir489 2023-12-18 08:59:35 -05:00 committed by GitHub
parent c1a49635eb
commit e9fdc86239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View File

@ -11,9 +11,7 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
int lockStatus = VEHICLE::GET_VEHICLE_DOOR_LOCK_STATUS(player->id());
Ped ped = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(player->id());
Ped ped = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(player->id());
if (!PED::IS_PED_IN_ANY_VEHICLE(ped, true))
{
g_notification_service->push_warning("TOXIC"_T.data(), "ERROR_PLAYER_IS_NOT_IN_VEHICLE"_T.data());
@ -23,10 +21,7 @@ namespace big
Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(ped, false);
if (entity::take_control_of(veh))
{
entity::take_control_of(veh);
VEHICLE::SET_VEHICLE_DOORS_LOCKED(veh, 4);
}
VEHICLE::SET_VEHICLE_DOORS_LOCKED(veh, (int)eVehicleLockState::VEHICLELOCK_LOCKOUT_PLAYER_ONLY);
}
}
};

View File

@ -2,6 +2,7 @@
#include "natives.hpp"
#include "pointers.hpp"
#include "util/teleport.hpp"
namespace big
{
class unlock_vehicle : player_command
@ -10,10 +11,17 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (PED::IS_PED_IN_ANY_VEHICLE(player->id(), false))
Ped ped = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(player->id());
if (!PED::IS_PED_IN_ANY_VEHICLE(ped, true))
{
if (entity::take_control_of(PED::GET_VEHICLE_PED_IS_USING(player->id())))
VEHICLE::SET_VEHICLE_DOORS_LOCKED(PED::GET_VEHICLE_PED_IS_USING(player->id()), 0);
g_notification_service->push_warning("VEHICLE"_T.data(), "ERROR_PLAYER_IS_NOT_IN_VEHICLE"_T.data());
}
else
{
Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(ped, false);
if (entity::take_control_of(veh))
VEHICLE::SET_VEHICLE_DOORS_LOCKED(veh, (int)eVehicleLockState::VEHICLELOCK_UNLOCKED);
}
}
};