Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------
- -- COMMUNITY CONTRIBUTION FOR CIT2.NET
- -- PURPOSE: Illegal Trucker version 2.0 - Server Side
- -- DEVELOPERS: Ryan#USNS (IRC: Ryan1)
- ------------------------------------------------------------------------------------
- local t = function(...) return exports.CITt:t(...) or arg[2] end
- local trailers, illegalStart, caughtCrim, missionsAble, copSearching, missionPlayer, vehInfo, trailBlip = {}, {}, {}, {}, {}, {}, {}, {}
- local trucksAllowed = {[403]=true, [515]=true, [514]=true}
- local crimTeam = {["Criminal"] = true, ["Gangster"] = true}
- local illegalMissions = {
- {"Stolen woods", 1, "currency",
- {
- {-1671.9651, -2238.5376, 34.6840, 2509.6804, -2397.6389, 13.4531},
- {-510.5513, -184.0313, 77.5739, 2509.6804, -2397.6389, 13.4531},
- {1431.6707, 53.5757, 31.0861, 2509.6804, -2397.6389, 13.4531},
- {-602.7764, -2379.2439, 27.4724, 2509.6804, -2397.6389, 13.4531},
- {-1728.1807, -1004.1956, 75.3903, 2509.6804, -2397.6389, 13.4531},
- },
- },
- {"Stolen military weapons", 3, "explosive",
- {
- {-67.1604, 1849.6941, 17.2266, 1338.4467, 333.1886, 19.6567},
- {-67.1604, 1849.6941, 17.2266, 2736.7161, -1999.3199, 13.3314},
- {-67.1604, 1849.6941, 17.2266, 65.2693, -273.1205, 1.5781},
- {-67.1604, 1849.6941, 17.2266, -494.6841, -526.1557, 25.5178},
- },
- },
- {"Stolen weed", 3, "drug",
- {
- {-1084.0078, -1647.5510, 76.3672, 869.2811, -33.9733, 63.1953},
- {-1049.5341, -1260.6897, 128.3069, 869.2811, -33.9733, 63.1953},
- {-104.4346, -131.0314, 3.1172, 869.2811, -33.9733, 63.1953},
- {-377.4979, -1425.2390, 25.7266, 869.2811, -33.9733, 63.1953},
- {-1398.3806, -1473.2067, 101.7125, 869.2811, -33.9733, 63.1953},
- {-3273.8613, 881.2361, 3.0082, 869.2811, -33.9733, 63.1953}, --City Island
- },
- },
- {"Stolen resource market", 1, "drug",
- {
- {987.6440, -927.7278, 42.1797, 2476.3892, -2432.6646, 13.6250},
- {1475.9570, -1130.9758, 24.0781, 2476.3892, -2432.6646, 13.6250},
- {1815.0590, -1841.7106, 13.5781, 2476.3892, -2432.6646, 13.6250},
- {507.1934, -1362.7794, 16.1252, 2476.3892, -2432.6646, 13.6250},
- },
- },
- {"Stolen special cars", 1, "currency",
- {
- {2123.0535, -1116.6073, 25.3297, 2476.3892, -2432.6646, 13.6250},
- {523.8887, -1273.7391, 16.0930, 2476.3892, -2432.6646, 13.6250},
- {-1631.6243, 1202.3541, 7.1797, 2476.3892, -2432.6646, 13.6250},
- {-2110.8545, -2253.4629, 30.4688, 2476.3892, -2432.6646, 13.6250},
- {1261.0795, 171.6992, 19.5692, 2476.3892, -2432.6646, 13.6250},
- {-3298.0298, 620.1749, 2.9982, 2476.3892, -2432.6646, 13.6250}, --City Island
- },
- },
- {"Illegal immigrants", 1, "currency",
- {
- {834.0153, -2045.3047, 12.8672, 2604.9885, -953.1558, 80.6604},
- {834.0153, -2045.3047, 12.8672, 771.5433, 310.2221, 20.6317},
- {834.0153, -2045.3047, 12.8672, 348.2115, 90.5939, 4.3677},
- {834.0153, -2045.3047, 12.8672, 1464.0338, 382.6462, 19.4622},
- {834.0153, -2045.3047, 12.8672, -76.0696, 983.9888, 19.7815},
- },
- },
- {"Drug Trafficking", 2, "drug",
- {
- {2506.0276, -1274.3027, 34.8569, 2460.5017, -1937.3405, 13.5391},
- {2506.0276, -1274.3027, 34.8569, 692.2917, -1169.7361, 15.4038},
- {2506.0276, -1274.3027, 34.8569, 2273.5767, 86.4542, 26.4844},
- },
- },
- {"Money Trafficking", 3, "currency",
- {
- {-14.6364, -285.3926, 5.4297, 1509.5836, -1155.6906, 24.0781},
- {-14.6364, -285.3926, 5.4297, 2329.5215, -23.3170, 26.3346},
- {-14.6364, -285.3926, 5.4297, -1873.0447, 723.7877, 45.4453},
- },
- },
- {"Stolen radioactive materials", 3, "explosive",
- {
- {-1821.5568, 3.2573, 15.1172, 1335.5579, 333.5837, 19.5547},
- {2460.8257, -2089.0498, 13.5469, 1335.5579, 333.5837, 19.5547},
- },
- },
- {"Stolen Precious material", 3, "explosive",
- {
- {-337.6020, 1193.7675, 19.7422 , 1335.5579, 333.5837, 19.5547},
- {-2372.1145, -2172.9739, 33.4450, 1335.5579, 333.5837, 19.5547},
- {832.4146, 853.0563, 12.2773, 1335.5579, 333.5837, 19.5547},
- },
- },
- {"Animals Trafficking", 2, "currency",
- {
- {-1084.0078, -1647.5510, 76.3672, 2681.6831, -2532.0396, 13.3757},
- {-1049.5341, -1260.6897, 128.3069, 2681.6831, -2532.0396, 13.3757},
- {-104.4346, -131.0314, 3.1172, 2681.6831, -2532.0396, 13.3757},
- {-377.4979, -1425.2390, 25.7266, 2681.6831, -2532.0396, 13.3757},
- {-1398.3806, -1473.2067, 101.7125, 2681.6831, -2532.0396, 13.3757},
- {-3273.8613, 881.2361, 3.0082, 2681.6831, -2532.0396, 13.3757}, --City Island
- },
- },
- {"Weapon Trafficking", 2, "explosive",
- {
- {-2440.3691, 490.4811, 30.0861, 1363.4043, -1313.7269, 13.5469},
- {-2440.3691, 490.4811, 30.0861, 2392.6135, -1977.6481, 13.5469},
- {-2440.3691, 490.4811, 30.0861, 2338.6655, 53.7166, 26.4844},
- {-2440.3691, 490.4811, 30.0861, 246.2604, -194.5964, 1.5781},
- },
- },
- {"Human trafficking", 2, "currency",
- {
- {834.0153, -2045.3047, 12.8672, 867.9329, -33.3535, 63.1953},
- {834.0153, -2045.3047, 12.8672, -1668.4901, -2238.7463, 34.3476},
- {834.0153, -2045.3047, 12.8672, -2778.6094, -1539.8674, 139.9183},
- },
- },
- {"Transportation of escaped prisoners", 2, "currency",
- {
- {1904.0194, -1530.7120, 3.3538, 834.0153, -2045.3047, 12.8672},
- {1904.0194, -1530.7120, 3.3538, 2597.1680, -2445.1038, 13.6252},
- {1904.0194, -1530.7120, 3.3538, 2857.2747, -272.7637, 9.2056},
- },
- },
- {"Felony Aiding Illegal Aliens", 2, "currency",
- {
- {-1618.2531, 1777.9023, 10.3289, 2740.5879, -1999.2815, 13.3157},
- {-1618.2531, 1777.9023, 10.3289, 1754.5313, -2631.9651, 13.5469},
- {-1618.2531, 1777.9023, 10.3289, 64.0848, -265.2267, 1.5781},
- },
- },
- {"Counterfeit Goods Transport", 1, "drug",
- {
- {52.2017, -274.7493, 1.6974, 987.6440, -927.7278, 42.1797},
- {52.2017, -274.7493, 1.6974, 1475.9570, -1130.9758, 24.0781},
- {52.2017, -274.7493, 1.6974, 1815.0590, -1841.7106, 13.5781},
- {52.2017, -274.7493, 1.6974, 507.1934, -1362.7794, 16.1252},
- },
- },
- }
- function assignedMission(mission)
- local veh = getPedOccupiedVehicle(client)
- missionsAble[mission][3] = missionsAble[mission][3] - 1
- vehInfo[client] = veh
- removeEventHandler("onPlayerQuit", client, onPlrQuit)
- addEventHandler("onPlayerQuit", client, onPlrQuit)
- if (missionsAble[mission][3] == 0) then
- missionsAble[mission] = nil
- return true
- end
- updatePlrTable(false)
- end
- addEvent("CITcrimTruck.assignedMission", true)
- addEventHandler("CITcrimTruck.assignedMission", resourceRoot, assignedMission)
- function pickCargo(mission)
- local veh = getPedOccupiedVehicle(client)
- if (not trucksAllowed[getElementModel(veh)] or illegalStart[client]) then
- return false
- end
- local x, y, z = getElementPosition(veh)
- local rx, ry, rz = getElementRotation(veh)
- trailers[veh] = createVehicle(435, x, y, z, rx, ry, rz)
- attachTrailerToVehicle(veh, trailers[vehInfo[client]])
- removeEventHandler("onElementDestroy", trailers[veh], onVehDestroy)
- removeEventHandler("onVehicleExplode", trailers[veh], onVehDestroy)
- addEventHandler("onElementDestroy", trailers[veh], onVehDestroy)
- addEventHandler("onVehicleExplode", trailers[veh], onVehDestroy)
- if (not illegalStart[client]) then
- illegalStart[client] = nil
- end
- illegalStart[client] = true
- for i, pol in pairs(exports.CITbusiness:getPlayersByJob("Police Service")) do
- triggerClientEvent(pol, "CITcrimTruck.updateCrimTable", pol, illegalStart)
- end
- end
- addEvent("CITcrimTruck.pickCargo", true)
- addEventHandler("CITcrimTruck.pickCargo", resourceRoot, pickCargo)
- function removeMarkers(mission)
- if (trailers[vehInfo[client]]) then
- destroyElement(trailers[vehInfo[client]])
- trailers[vehInfo[client]] = nil
- end
- removeEventHandler("onPlayerQuit", client, onPlrQuit)
- updatePlrTable(false)
- missionPlayer[client] = nil
- vehInfo[client] = nil
- if (not illegalStart[client]) then
- return false
- end
- illegalStart[client] = false
- caughtCrim[client] = false
- end
- addEvent("CITcrimTruck.removeMarkers", true)
- addEventHandler("CITcrimTruck.removeMarkers", resourceRoot, removeMarkers)
- function paymentIllegal(paymentTable, hp)
- local mission, risk, distance, typePay = paymentTable[1], paymentTable[2], paymentTable[3], paymentTable[4]
- if (caughtCrim[client]) then
- risk = 0
- end
- local payment = math.ceil((1000 * ((risk * 0.2) + (distance / 100 * 0.6) + (hp / 100 * 0.2))), 0)
- exports.CITaccounts:invSet(getPlayerAccount(client), "illegalTrucking", (exports.CITaccounts:invGet(getPlayerAccount(client), "illegalTrucking") or 0) + 1)
- exports.CITcrimExp:modifyPlayerCriminalRep(client, 500)
- if (typePay == "drug") then
- local amountDrugs = math.ceil((payment / 1500), 0)
- if (not exports.CITmoney:checkMoneyIncome(client, amountDrugs * 1500)) then
- return false
- end
- exports.CITdrug:giveDrug(client, "all", amountDrugs)
- amountDrugs = exports.CITmisc:comVal(amountDrugs)
- exports.CITlogs:logSomething(getPlayerName(client).." got "..amountDrugs.." of each drugs from illegal mission:"..mission, "crimTruck2", client)
- exports.CIThelp:dm("You delivered the goods successfully and you got %s of each drugs.", client, 150, 0, 0, true, amountDrugs)
- return true
- end
- if (typePay == "explosive") then
- local amountExplo = math.ceil((payment / 300), 0)
- if (not exports.CITmoney:checkMoneyIncome(client, amountExplo * 300)) then
- return false
- end
- exports.CITcrafting:modifyPlayerItem(client, "Explosive", amountExplo)
- amountExplo = exports.CITmisc:comVal(amountExplo)
- exports.CITlogs:logSomething(getPlayerName(client).." got "..amountExplo.." explosives from illegal mission:"..mission, "crimTruck2", client)
- exports.CIThelp:dm("You delivered the goods successfully and you got %s grams of explosives.", client, 150, 0, 0, true, amountExplo)
- return true
- end
- exports.CITmoney:GPM(client, payment, "Accomplished crimTruck mission: "..mission, true)
- payment = exports.CITmisc:comVal(payment)
- exports.CIThelp:dm("You delivered the goods successfully and you got $%s", client, 150, 0, 0, true, exports.CITmisc:comVal(payment))
- end
- addEvent("CITcrimTruck.paymentIllegal", true)
- addEventHandler("CITcrimTruck.paymentIllegal", resourceRoot, paymentIllegal)
- function caughtByPolice(police)
- local gCrim, gPolice = getElementData(client, "g"), getElementData(police, "g")
- local sCrim, sPolice = getElementData(client, "s"), getElementData(police, "s")
- local uCrim, uPolice = getElementData(client, "n"), getElementData(police, "n")
- if ((gCrim and gPolice and gCrim == gPolice) or (sCrim and sPolice and sCrim == sPolice) or (uCrim and uPolice and uCrim == uPolice) or caughtCrim[client]) then
- return false
- end
- caughtCrim[client] = true
- exports.CIThelp:dm("You have been located by a police officer. Finish the mission before they catch you!", client, 150, 0, 0, true)
- exports.CIThelp:dm("You are near of a criminal! You have been rewarded with $5,000.", police, 0, 0, 200, true)
- exports.CITpoliceDatabase:recordCrime(client, 12)
- local x, y, z = getElementPosition(police)
- for i, copsNear in pairs(exports.CITbusiness:getPlayersByJob("Police Service")) do
- local x1, y1, z1 = getElementPosition(copsNear)
- if (getDistanceBetweenPoints2D(x, y, x1, y1) <= 25 and copsNear ~= police) then
- exports.CITmoney:GPM(copsNear, 1000, "Finding an illegal trucker.", true)
- exports.CIThelp:dm("You got $1,000 for assisting the police!", copsNear, 0, 0, 200, true)
- end
- end
- exports.CITmoney:GPM(police, 5000, "Finding an illegal trucker.", true)
- exports.CIThelp:opc("Dispatcher: "..getPlayerName(police).." has found a criminal that is transporting an illegal cargo. Stop the criminal!", exports.CITbusiness:getPlayersByJob("Police Service"), 0, 0, 200)
- end
- addEvent("CITcrimTruck.caughtByPolice", true)
- addEventHandler("CITcrimTruck.caughtByPolice", resourceRoot, caughtByPolice)
- function pickTrailer()
- trailBlip[client] = createBlipAttachedTo(trailers[vehInfo[client]], 17, 2, 255, 255, 255, 255, 0, 3000, client)
- removeEventHandler("onTrailerAttach", trailers[vehInfo[client]], onAttachTrailerIllegal)
- removeEventHandler("onElementDestroy", vehInfo[client], onVehDestroy)
- addEventHandler("onTrailerAttach", trailers[vehInfo[client]], onAttachTrailerIllegal)
- addEventHandler("onElementDestroy", vehInfo[client], onVehDestroy)
- end
- addEvent("CITcrimTruck.pickTrailer", true)
- addEventHandler("CITcrimTruck.pickTrailer", resourceRoot, pickTrailer)
- function onAttachTrailerIllegal(theTruck)
- local driver = getVehicleController(theTruck)
- if (trailBlip[driver]) then
- destroyElement(trailBlip[driver])
- trailBlip[driver] = nil
- exports.CIThelp:dm("You already got the trailer. Now delivery it!", driver, 0, 255, 0, true)
- removeEventHandler("onTrailerAttach", trailers[vehInfo[driver]], onAttachTrailerIllegal)
- removeEventHandler("onElementDestroy", vehInfo[driver], onVehDestroy)
- end
- end
- function recoverTrail(plr, cmd)
- if (not getPedOccupiedVehicle(plr) or not vehInfo[plr] or not trailers[vehInfo[plr]]) then
- return false
- end
- local x, y, z = getElementPosition(plr)
- local x1, y1, z1 = getElementPosition(trailers[vehInfo[plr]])
- if (getDistanceBetweenPoints2D(x, y, x1, y1) > 100) then
- exports.CIThelp:dm("You are away from your trailer!", plr, 0, 255, 0, true)
- return false
- end
- attachTrailerToVehicle(vehInfo[plr], trailers[vehInfo[plr]])
- fixVehicle(trailers[vehInfo[plr]])
- end
- addCommandHandler("rtrailer", recoverTrail)
- function onPlrQuit()
- if (not crimTeam[getElementData(source, "o")]) then
- return false
- end
- if (getPedOccupiedVehicleSeat(source) ~= 0) then
- return false
- end
- --triggerClientEvent(source, "CITcrimTruck.stopMission", source)
- removeMarkers(missionPlayer[source], source)
- end
- function onVehDestroy()
- if (getElementType(source) ~= "vehicle" or not trucksAllowed[getElementModel(source)] or getElementModel(source) ~= 435) then
- return false
- end
- if (getElementModel(source) == 435) then
- for plr, trail in pairs(trailers) do
- if (trail == source) then
- triggerClientEvent(plr, "CITcrimTruck.stopMission", plr)
- break
- end
- end
- end
- local driver = getVehicleController(source)
- if (not driver or not trailBlip[driver]) then
- return false
- end
- destroyElement(trailBlip[driver])
- trailBlip[driver] = nil
- exports.CIThelp:dm("Removed blip as you destroyed the vehicle.", driver, 0, 255, 0, true)
- removeEventHandler("onTrailerAttach", trailers[vehInfo[driver]], onAttachTrailerIllegal)
- removeEventHandler("onElementDestroy", vehInfo[driver], onVehDestroy)
- end
- function newMission()
- local count = 0
- for mission, value in pairs(missionsAble) do
- if (type(value) == "table") then
- count = count + 1
- end
- end
- if (count == 10) then
- return false
- end
- local missionR = math.random(#illegalMissions)
- if (type(missionsAble[illegalMissions[missionR][1]]) == "table") then
- newMission()
- return false
- end
- if (type(missionsAble[illegalMissions[missionR][1]]) ~= "table") then
- missionsAble[illegalMissions[missionR][1]] = {}
- end
- missionsAble[illegalMissions[missionR][1]] = {illegalMissions[missionR][2], illegalMissions[missionR][3], math.random(1, 5), illegalMissions[missionR][4]}
- end
- setTimer(newMission, 5000, 0)
- function updatePlrTable(bool, bCrim)
- if (bool) then
- triggerClientEvent(client, "CITcrimTruck.updateTables", client, missionsAble)
- return bool
- end
- if (bCrim) then
- triggerClientEvent(client, "CITcrimTruck.updateCrimTable", client, illegalStart)
- return bCrim
- end
- for i, plr in pairs(getElementsByType("player")) do
- if (crimTeam[getElementData(plr, "o")] and getPedOccupiedVehicle(plr) and trucksAllowed[getElementModel(getPedOccupiedVehicle(plr))]) then
- triggerClientEvent(plr, "CITcrimTruck.updateTables", plr, missionsAble)
- end
- end
- end
- addEvent("CITcrimTruck.updateTableToPlrs", true)
- addEventHandler("CITcrimTruck.updateTableToPlrs", resourceRoot, updatePlrTable)
Advertisement
Add Comment
Please, Sign In to add comment