Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ================
- Script Variables
- ================
- --]]
- local towTruck = {
- handle = nil,
- hash = nil,
- model = "towtruck2", -- 50's tow truck
- color = {128, 235, 90},
- position = {249.138150, 2600.628000, 44.709800},
- rotation = {0.410125, 1.653700, -35.268880},
- }
- --[[
- ================
- Script Functions
- ================
- --]]
- function init_towtruck()
- -- make sure hash is initialized
- if towTruck.hash == nil then
- towTruck.hash = GAMEPLAY.GET_HASH_KEY(towTruck.model)
- end
- if towTruck.handle == nil then
- STREAMING.REQUEST_MODEL(towTruck.hash)
- local pos = towTruck.position
- local rot = towTruck.rotation
- local numTicks = 0
- local loadFailed = false
- while not STREAMING.HAS_MODEL_LOADED(towTruck.hash) do
- if numTicks > 250 then
- loadFailed = true
- break
- else
- numTicks = numTicks + 1
- end
- end
- if loadFailed then
- print "Tow truck failed to spawn!!!"
- return
- end
- -- create towtruck
- towTruck.handle = VEHICLE.CREATE_VEHICLE(towTruck.hash, pos[1], pos[2], pos[3], 0.0, false, true)
- -- setup rotation
- ENTITY.SET_ENTITY_ROTATION(towTruck.handle, rot[1], rot[2], rot[3], 2, true)
- -- make sure no other tow trucks spawn (we don't want any competition :P)
- VEHICLE.SET_VEHICLE_MODEL_IS_SUPPRESSED(towTruck.hash, true)
- end
- end
- function unload_towtruck()
- if towTruck.handle ~= nil then
- -- we must assume the hash has not been screwed with
- VEHICLE.SET_VEHICLE_MODEL_IS_SUPPRESSED(towTruck.hash, false)
- --STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(towTruck.hash)
- ENTITY.SET_VEHICLE_AS_NO_LONGER_NEEDED(towTruck.handle)
- VEHICLE.DELETE_VEHICLE(towTruck.handle)
- -- TEMPORARY HACK!!!
- towTruck.handle = nil
- towTruck.hash = nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement