Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local truckVehicles = {
- --Trucker
- {[403]=true, [515]=true, [514]=true},
- --Delivery Man
- {[482]=true, [413]=true, [440]=true, [414]=true, [499]=true, [456]=true},
- }
- local delMarkers = {
- ["trucker"] = {
- {},
- },
- ["delivery man"] = {
- ["LS"] = {
- {},
- },
- ["SF"] = {
- {},
- },
- },
- }
- local marker, blip, trailer
- local payment = 1
- local dest = {}
- function showIllegalPanel()
- local resX, resY = guiGetScreenSize()
- illegalWin = guiCreateWindow((resX/2) - 200, (resY/2) - 200, 496, 268, "Illegal Trucking Mission", false)
- guiWindowSetSizable(illegalWin, false)
- guiSetVisible(illegalWin, false)
- guiSetAlpha(illegalWin, 95)
- informationLabel = guiCreateLabel(9, 22, 477, 59, "You has been given the opportunity to transport illegal cargo to another location. You \nwill become wanted if you accept this mission, but you will get extra payment +\ncriminal reputation. Select 1 of 3 missions. If you decline this mission, you will not get \nany mission until you re-enter at vehicle. Doing Delivery man mission at SF will be reduced for 50%", false, illegalWin)
- guiLabelSetHorizontalAlign(informationLabel, "center", false)
- selectionLabel = guiCreateLabel(9, 91, 477, 17, "Please select an option below", false, illegalWin)
- guiSetFont(selectionLabel, "default-bold-small")
- guiLabelSetColor(selectionLabel, 255, 0, 0)
- guiLabelSetHorizontalAlign(selectionLabel, "center", false)
- lowPayRadioButton = guiCreateRadioButton(9, 118, 477, 21, "Delivery Immigrants (1.0x Money, 30 wanted points)", false, illegalWin)
- guiRadioButtonSetSelected(lowPayRadioButton, true)
- medPayRadioButton = guiCreateRadioButton(9, 149, 477, 21, "Deliver Drugs and Guns (1.5x Money, 45 wanted points)", false, illegalWin)
- highPayRadioButton = guiCreateRadioButton(9, 180, 477, 21, "Deliver Counterfeit Money (2.0x Money, 60 wanted points)", false, illegalWin)
- acceptButton = guiCreateButton(124, 218, 91, 35, "Start", false, illegalWin)
- cancelButton = guiCreateButton(281, 218, 91, 35, "Cancel", false, illegalWin)
- --Event Handler
- addEventHandler("onClientGUIClick", acceptButton, acceptMission)
- addEventHandler("onClientGUIClick", cancelButton, showPanel)
- end
- function showPanel()
- if (marker and not guiGetVisible(illegalWin)) then
- return false
- end
- if (not illegalWin) then
- showIllegalPanel()
- end
- local state = not guiGetVisible(illegalWin)
- guiSetVisible(illegalWin, state)
- showCursor(state)
- if (dest[localPlayer]) then
- dest = {}
- end
- end
- function acceptMission()
- local crime = 24
- if (guiRadioButtonGetSelected(medPayRadioButton)) then
- payment = 1.5
- crime = 25
- end
- if (guiRadioButtonGetSelected(highPayRadioButton)) then
- payment = 2
- crime = 26
- end
- triggerServerEvent("CITillegalTrucking.startMission", localPlayer, crime)
- end
- function onCrimEnterVehicle(veh, seat)
- local dim = getElementDimension(localPlayer)
- if (getElementType(localPlayer) ~= "player" or not truckVehicles[1][getElementModel(veh)] and not truckVehicles[2][getElementModel(veh)] or getElementData(localPlayer, "o") ~= "Criminal" or seat ~= 0 or dim ~= 0) then
- return false
- end
- local company = "delivery man"
- if (truckVehicles[1][getElementModel(veh)]) then
- company = "trucker"
- end
- setElementData(localPlayer, "illegalc", company)
- bindKey("n", "down", showPanel)
- exports.CIThelp:modTextBar("illegalTrucking", "Press 'n' for Illegal Trucking", 100, 0, 0, 95, 30000)
- end
- addEventHandler("onClientPlayerVehicleEnter", localPlayer, onCrimEnterVehicle)
- function spawnMarkers()
- unbindKey("n", "down", showPanel)
- exports.CIThelp:modTextBar("illegalTrucking", "")
- showPanel()
- local job
- local x, y, z = getElementPosition(localPlayer)
- dest = {x, y, z}
- local loc = getElementData(localPlayer, "z")
- local company = getElementData(localPlayer, "illegalc")
- if (company == "delivery man") then
- if (loc == "LV") then
- exports.CIThelp:dm("Leave from LV for handle this mission.", 255, 0, 0)
- return false
- end
- job = delMarkers[company][loc]
- end
- if (company == "trucker") then
- job = delMarkers[company]
- local veh = getPedOccupiedVehicle(localPlayer)
- local rotx, roty, rotz = getElementRotation(veh)
- trailer = createVehicle(435, x-4, y, z, rotx, roty, rotz)
- attachTrailerToVehicle(veh, trailer)
- removeEventHandler("onClientTrailerDetach", trailer, onDetachTrailer)
- addEventHandler("onClientTrailerDetach", trailer, onDetachTrailer)
- end
- local coord = math.random(#job)
- local x, y, z = job[coord][1], job[coord][2], job[coord][3]
- marker = createMarker(x, y, z, "cylinder", 4, 150, 0, 0, 95)
- blip = createBlipAttachedTo(marker, 51)
- removeEventHandler("onClientMarkerHit", marker, deliveryGoods)
- addEventHandler("onClientMarkerHit", marker, deliveryGoods)
- outputChatBox("Delivery this goods at "..getZoneName(x, y, z)..", "..getZoneName(x, y, z, true))
- end
- addEvent("CITillegalTrucking.spawnMarkers", true)
- addEventHandler("CITillegalTrucking.spawnMarkers", root, spawnMarkers)
- function deliveryGoods(plr, dim)
- if (not plr or not dim) then
- return false
- end
- local x1, y1, z1 = getElementPosition(marker)
- local x2, y2, z2 = dest[1], dest[2], dest[3]
- local dist = getDistanceBetweenPoints2D(x1, y1, x2, y2)
- if (marker) then
- removeEventHandler("onClientMarkerHit", marker, deliveryGoods)
- destroyElement(marker)
- end
- if (blip) then
- destroyElement(blip)
- end
- if (trailer) then
- removeEventHandler("onClientTrailerDetach", trailer, onDetachTrailer)
- destroyElement(trailer)
- end
- local payIllegal = math.floor(dist*payment)
- local company = getElementData(localPlayer, "illegalc")
- local loc = getElementData(localPlayer, "z")
- if (company == "delivery man" and loc == "SF") then
- payIllegal = math.floor(payIllegal * 0.5)
- end
- triggerServerEvent("CITillegalTrucking.illegalPayment", localPlayer, payIllegal)
- marker = nil
- blip = nil
- trailer = nil
- payment = 1
- setElementData(localPlayer, "illegalc", nil)
- onCrimEnterVehicle(getPedOccupiedVehicle(localPlayer), getPedOccupiedVehicleSeat(localPlayer))
- end
- function onDetachTrailer(veh)
- if (not trailer) then
- return false
- end
- attachTrailerToVehicle(veh, trailer)
- end
- function resignJob(oldJob)
- if (oldJob == "Criminal") then
- if (marker) then
- removeEventHandler("onClientMarkerHit", marker, deliveryGoods)
- destroyElement(marker)
- end
- if (blip) then
- destroyElement(blip)
- end
- if (trailer) then
- removeEventHandler("onClientTrailerDetach", trailer, onDetachTrailer)
- destroyElement(trailer)
- end
- end
- end
- addEventHandler("onClientPlayerResign", localPlayer, resignJob)
- addEventHandler("onClientPlayerEndShift", localPlayer, resignJob)
Advertisement
Add Comment
Please, Sign In to add comment