Evor
Enthusiast
I Found this 'gtav_lua_forklift.lua' and it doesn't work I know nothing about scripts I'm not sure if it's complete.
Its supposed to make it so you can lift anything with the forklift truck
Its supposed to make it so you can lift anything with the forklift truck
Code:
--
-- Created by roto / mozy
-- Feel free to do wtfever.
--
-- Yes it has some bugs, can be better. Go nuts fixing it.
--
-- Create a ScriptThread
-- I recommend matching addon name & script thread name
spawn_forklift = ScriptThread("spawn_forklift")
-- Run function
-- This is called once! It's your job to keep this alive!
function spawn_forklift:Run()
-- while-loop, do not use while true !
while self:IsRunning() do
-- Spawn us a forklift
if IsKeyDown(KEY_F7) then
-- Vehicle Spawn Position
-- In front of the Player
local vehicle_pos = LocalPlayer():GetOffsetVector(0,5,0)
-- Load Model
streaming.RequestModel(VEHICLE_FORKLIFT)
-- Create Vehicle
game.CreateVehicle(VEHICLE_FORKLIFT, vehicle_pos)
-- Set model as no longer needed
-- Otherwise it lies around in memory
streaming.ReleaseModel(VEHICLE_FORKLIFT)
end
-- Spawn Flatbed
if IsKeyDown(KEY_F9) then
local vehicle_pos = LocalPlayer():GetOffsetVector(0,10,0)
local position = LocalPlayer():GetPosition()
-- Load Model
streaming.RequestModel(VEHICLE_MONSTER) --VEHICLE_BULLDOZER, VEHICLE_FLATBED, VEHICLE_HANDLER (dock container handler)
-- Create Vehicle
game.CreateVehicle(VEHICLE_MONSTER, vehicle_pos)
-- Set model as no longer needed
-- Otherwise it lies around in memory
streaming.ReleaseModel(VEHICLE_MONSTER)
end
-- Detach from forklift, give gravity... also lets try some weird ****
if IsKeyDown(KEY_F10) then
local position = LocalPlayer():GetOffsetVector(0,10,0)
-- Lets try some vehicle stuff
local nearby_vehicles = LocalPlayer():GetNearbyVehicles(2) -- has to ALWAYS be a minimum of 2 for some reason
for _, vehicle in pairs(nearby_vehicles) do
--vehicle:Delete()
local a_0 = vehicle.ID
natives.VEHICLE.SET_VEHICLE_STRONG(a_0, false);
natives.VEHICLE.SET_VEHICLE_HAS_STRONG_AXLES(a_0, false);
natives.ENTITY.DETACH_ENTITY(a_0, true, true);
natives.VEHICLE.SET_VEHICLE_GRAVITY(a_0, true);
--natives.VEHICLE.SET_VEHICLE_GRAVITY(a_0, false); -- OK this works.... almost
--natives.VEHICLE.SET_VEHICLE_DAMAGE(a_0, 0.84, 2.21, 0.22, 100.0, 400.0, true);
end
end
-- Attach to forklift
if IsKeyDown(KEY_F11) then
-- Vehicle Spawn Position
-- In front of the Player
local vehicle_pos = LocalPlayer():GetOffsetVector(0,5,0)
local current_player_vehicle = LocalPlayer():GetVehicle()
local nearby_vehicles = LocalPlayer():GetNearbyVehicles(2)
for _, vehicle in pairs(nearby_vehicles) do
--vehicle:Delete()
local a_0 = vehicle.ID
if current_player_vehicle ~= vehicle.ID then
natives.VEHICLE.SET_VEHICLE_GRAVITY(a_0, false); -- OK this works.... almost
--natives.VEHICLE.SET_VEHICLE_DAMAGE(a_0, 0.84, 2.21, 0.22, 100.0, 400.0, true);
end
if LocalPlayer():IsInVehicle() then
if natives.ENTITY.IS_ENTITY_TOUCHING_ENTITY(current_player_vehicle.ID, vehicle.ID) then
--[[
Sample: --ENTITY::ATTACH_ENTITY_TO_ENTITY(a_0, a_1._f2, 0, v_5, 0.0, 0.0, 180.0, 0, 0, 0, 0, 2, 1);
ATTACH_ENTITY_TO_ENTITY(Entity entity1, -- Nearest Vehicle that we want to attach
Entity entity2, -- Our vehicle, the receiver
int boneIndex, -- Guessed this one, #3 is the "forks" of the forklift
float x, -- Leave at "0" to be centered on fork
float y, -- Distance from front of forklift body, how far the car should be away
float z, -- Height above forks, this doesnt work well with SUV's and such. But sportscars are OK.
float rot_x, -- bla
float rot_y, -- bla
float rot_z, -- Rotate car... if you go in from Drivers side, it works fine. Otherwise it rotates 90deg for you.
BOOL p9, -- dunno
BOOL p10, -- dunno
BOOL p11, -- dunno
BOOL p12, -- dunno
int unk, -- dunno, took this from decompiled mission scripts
BOOL p14) -- same as above
]]--
natives.ENTITY.ATTACH_ENTITY_TO_ENTITY(vehicle.ID, current_player_vehicle.ID, 3, 0.0, 1.3, -0.09, 0.0, 0, 90.0, false, false, false, false, 2, true)
end
end
end
end
-- Wait
self:Wait(50)
end
end
-- OnError
function spawn_forklift:OnError()
print("Oh no! Example Thread caused an error!")
self:Reset()
end
-- Register Thread
spawn_forklift:Register()