-- These vehicles will be registered as "allowed/valid" tow
trucks.
-- Change the x, y and z offset values for the towed vehicles to be
attached to the tow truck.
-- x = left/right, y = forwards/backwards, z = up/down
local allowedTowModels = {
['flatbed'] = {x = 0.0, y = -0.85, z = 1.25}, -- default GTA V
flatbed
['flatbed2'] = {x = 0.0, y = 0.0, z = 0.68}, -- addon
flatbed2
['flatbed3'] = {x = 0.0, y = -1.2, z = 1.30}, -- addon
flatbed3
}
local allowTowingBoats = false -- Set to true if you want to be
able to tow boats.
local allowTowingPlanes = false -- Set to true if you want to be
able to tow planes.
local allowTowingHelicopters = false -- Set to true if you want to
be able to tow helicopters.
local allowTowingTrains = false -- Set to true if you want to be
able to tow trains.
local allowTowingTrailers = true -- Disables trailers. NOTE: THIS
ALSO DISABLES THE AIRTUG, TOWTRUCK, SADLER, AND ANY OTHER VEHICLE
THAT IS IN THE UTILITY CLASS.
local currentlyTowedVehicle = nil
RegisterCommand("tow", function()
TriggerEvent("tow")
end,false)
function isTargetVehicleATrailer(modelHash)
if GetVehicleClassFromName(modelHash) == 11 then
return true
else
return false
end
end
local xoff = 0.0
local yoff = 0.0
local zoff = 0.0
function isVehicleATowTruck(vehicle)
local isValid = false
for model,posOffset in pairs(allowedTowModels) do
if IsVehicleModel(vehicle, model) then
xoff = posOffset.x
yoff = posOffset.y
zoff = posOffset.z
isValid = true
break
end
end
return isValid
end
RegisterNetEvent('tow')
AddEventHandler('tow', function()
local playerped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(playerped,
true)
local isVehicleTow = isVehicleATowTruck(vehicle)
if isVehicleTow then
local coordA =
GetEntityCoords(playerped, 1)
local coordB =
GetOffsetFromEntityInWorldCoords(playerped, 0.0, 5.0, 0.0)
local targetVehicle =
getVehicleInDirection(coordA, coordB)
Citizen.CreateThread(function()
while true
do
Citizen.Wait(0)
isVehicleTow = isVehicleATowTruck(vehicle)
local roll =
GetEntityRoll(GetVehiclePedIsIn(PlayerPedId(), true))
if
IsEntityUpsidedown(GetVehiclePedIsIn(PlayerPedId(), true)) and
isVehicleTow or roll > 70.0 or roll < -70.0 then
DetachEntity(currentlyTowedVehicle, false, false)
currentlyTowedVehicle =
nil
ShowNotification("~o~~h~Tow
Service:~n~~s~Looks like the cables holding on the vehicle have
broke!")
end
end
end)
if currentlyTowedVehicle == nil
then
if targetVehicle
~= 0 then
local targetVehicleLocation = GetEntityCoords(targetVehicle,
true)
local towTruckVehicleLocation = GetEntityCoords(vehicle,
true)
local distanceBetweenVehicles =
GetDistanceBetweenCoords(targetVehicleLocation,
towTruckVehicleLocation, false)
-- print(tostring(distanceBetweenVehicles)) -- debug only
-- Distance allowed (in meters)
between tow truck and the vehicle to be towed
if distanceBetweenVehicles > 12.0 then
ShowNotification("~o~~h~Tow Service:~n~~s~Your cables can't reach
this far. Move your tow truck closer to the vehicle.")
else
local targetModelHash = GetEntityModel(targetVehicle)
-- Check to make sure the target vehicle is allowed to be towed
(see settings at lines 8-12)
if not ((not allowTowingBoats and
IsThisModelABoat(targetModelHash)) or (not allowTowingHelicopters
and IsThisModelAHeli(targetModelHash)) or (not allowTowingPlanes
and IsThisModelAPlane(targetModelHash)) or (not allowTowingTrains
and IsThisModelATrain(targetModelHash)) or (not allowTowingTrailers
and isTargetVehicleATrailer(targetModelHash))) then
if not IsPedInAnyVehicle(playerped, true) then
if vehicle ~= targetVehicle and IsVehicleStopped(vehicle)
then
-- TriggerEvent('chatMessage', '', {255,255,255}, xoff .. ' ' ..
yoff .. ' ' .. zoff) -- debug line
AttachEntityToEntity(targetVehicle, vehicle,
GetEntityBoneIndexByName(vehicle, 'bodyshell'), 0.0 + xoff, -1.5 +
yoff, 0.0 + zoff, 0, 0, 0, 1, 1, 0, 1, 0, 1)
currentlyTowedVehicle = targetVehicle
ShowNotification("~o~~h~Tow Service:~n~~s~Vehicle has been loaded
onto the flatbed.")
else
ShowNotification("~o~~h~Tow Service:~n~~s~There is currently no
vehicle on the flatbed.")
end
else
ShowNotification("~o~~h~Tow Service:~n~~s~You need to be outside of
your vehicle to load or unload vehicles.")
end
else
ShowNotification("~o~~h~Tow Service:~n~~s~Your tow truck is not
equipped to tow this vehicle.")
end
end
else
ShowNotification("~o~~h~Tow Service:~n~~s~No towable vehicle
detected.")
end
elseif IsVehicleStopped(vehicle)
then
DetachEntity(currentlyTowedVehicle, false, false)
local vehiclesCoords = GetOffsetFromEntityInWorldCoords(vehicle,
0.0, -12.0, 0.0)
SetEntityCoords(currentlyTowedVehicle, vehiclesCoords["x"],
vehiclesCoords["y"], vehiclesCoords["z"], 1, 0, 0, 1)
SetVehicleOnGroundProperly(currentlyTowedVehicle)
currentlyTowedVehicle = nil
ShowNotification("~o~~h~Tow Service:~n~~s~Vehicle has been unloaded
from the flatbed.")
end
else
ShowNotification("~o~~h~Tow Service:~n~~s~Your vehicle is not
registered as an official tow truck.")
end
end)
function getVehicleInDirection(coordFrom, coordTo)
local rayHandle = CastRayPointToPoint(coordFrom.x,
coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10,
PlayerPedId(), 0)
local a, b, c, d, vehicle =
GetRaycastResult(rayHandle)
return vehicle
end
function ShowNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName(text)
DrawNotification(false, false)
end
We need to create an application which operates in the same way as uber but instead...
create a new Java application called "WeightedAvgDataAnalyzer" (without the quotation marks), that modifies the DataAnalyzer.java in Horstmann Section 7.5, pp. 350-351 according to the specifications below. The input file should be called 'data.txt' and should be created according to the highlighted instructions below. Note that even though you know the name of the input file, you should not hard-code this name into your program. Instead, prompt the user for the name of the input file. The input file should contain...
You need to create your own connection string. So you need to know what each of the parts of the connection string mean. The connection string needs to know the location where the SQL Server resides, and that's usually a domain name or IP address. This may vary! Then you need to know who you are talking to, and that is the name of the server. This is the initial catalog. The AttachDbFilename shows the name of the file and...
In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...
I need some help i need to do this in C# Objectives: • Create an application that uses a dictionary collection to store information about an object. • Understanding of abstract classes and how to use them • Utilize override with an abstract class • Understanding of Interfaces and how to use them • Implement an Interface to create a “contract” between classes. • Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the...
I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...
Code in JAVA You are asked to implement “Connect 4” which is a two player game. The game will be demonstrated in class. The game is played on a 6x7 grid, and is similar to tic-tac-toe, except that instead of getting three in a row, you must get four in a row. To take your turn, you choose a column, and slide a checker of your color into the column that you choose. The checker drops into the slot, falling...
Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor. Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...
1-Suppose you write an application in which one class contains code that keeps track of the state of a board game, a separate class sets up a GUI to display the board, and a CSS is used to control the stylistic details of the GUI (for example, the color of the board.) This is an example of a.Duck Typing b.Separation of Concerns c.Functional Programming d.Polymorphism e.Enumerated Values 2-JUnit assertions should be designed so that they a.Fail (ie, are false) if...
We will build one Python application via which users can perform various analytics tasks on data in 2-D table (similar to Spreadsheet) format which looks like: Column Name 1 Column Name 2 Column Name 3 Column Name N … … … … … In this table, each row represents the data of one object that we are interested in. Columns, on the other hand, represent the attributes of these objects. For example, this table could represent students’ academic records. Each...
Lab 10: ArrayLists and Files in a GUI Application For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, DrawTextItem, DrawTextPanel, and SimpleFileChooser) in the code directory. These files are supposed to be in package named "textcollage". Start an Eclipse project, create a package named textcollage in that project, and copy the four files into the package. To run the program, you should run the file TextCollage.java, which...