Skip to content

Commit

Permalink
removePedFromVehicle, PutPlayerInVehicle fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
colistro123 committed Jul 1, 2020
1 parent f5d01d2 commit 064b6af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
15 changes: 2 additions & 13 deletions amx/server/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -520,26 +520,15 @@ function getPedOccupiedVehicle(player)
return data and data.vehicle
end

local _removePedFromVehicle = removePedFromVehicle
function removePedFromVehicle(player)
local playerdata = g_Players[getElemID(player)]
if not playerdata.vehicle then
return false
end
-- Built-in removePlayerFromVehicle is simply too unreliable
local health, armor = getElementHealth(player), getPedArmor(player)
local weapons, currentslot = playerdata.weapons, getPedWeaponSlot(player)
playerdata.beingremovedfromvehicle = true
local x, y, z = getElementPosition(playerdata.vehicle)
local rx, ry, rz = getVehicleRotation(playerdata.vehicle)
procCallOnAll('OnPlayerExitVehicle', getElemID(player), getElemID(playerdata.vehicle))
spawnPlayerBySelectedClass(player, x + 4*math.cos(math.rad(rz+180)), y + 4*math.sin(math.rad(rz+180)), z + 1, rz)
playerdata.beingremovedfromvehicle = nil
playerdata.vehicle = nil
setElementHealth(player, health)
setPedArmor(player, armor)
if weapons then
giveWeapons(player, weapons, currentslot)
end
setTimer(_removePedFromVehicle, 500, 1, player)
return true
end
-------------------------------
Expand Down
3 changes: 2 additions & 1 deletion amx/server/natives/a_players.lua
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@ function PutPlayerInVehicle(amx, player, vehicle, seat)
if g_RCVehicles[getElementModel(vehicle)] then
setElementAlpha(player, 0)
end
setPlayerState(player, seat == 0 and PLAYER_STATE_DRIVER or PLAYER_STATE_PASSENGER)
--setPlayerState(player, seat == 0 and PLAYER_STATE_DRIVER or PLAYER_STATE_PASSENGER)
--No need to do this since the vehicle event gets called when we enter a vehicle
end

function GetPlayerVehicleID(amx, player)
Expand Down

0 comments on commit 064b6af

Please sign in to comment.