Skip to content

Commit

Permalink
v1.5
Browse files Browse the repository at this point in the history
Added all new features and PD notification
  • Loading branch information
lenzh authored Apr 30, 2019
1 parent 66284f9 commit b59b71b
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 45 deletions.
215 changes: 174 additions & 41 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ local isDead = false
local CurrentTask = {}
local menuOpen = false
local wasOpen = false
local chopping = false
local pedIsTryingToSellDrugs = false



Citizen.CreateThread(function()
Expand All @@ -19,10 +20,10 @@ Citizen.CreateThread(function()
end

while ESX.GetPlayerData().job == nil do
Citizen.Wait(100)
Citizen.Wait(10)
end

ESX.PlayerData = ESX.GetPlayerData()
PlayerData = ESX.GetPlayerData()
end)

AddEventHandler('esx:onPlayerDeath', function(data)
Expand Down Expand Up @@ -103,57 +104,64 @@ end
function ChopVehicle()
ESX.TriggerServerCallback('Lenzh_chopshop:isCooldown', function(cooldown)
if cooldown <= 0 then
local ped = GetPlayerPed(-1)
local vehicle = GetVehiclePedIsIn( ped, false )
if Config.CallCops then
local randomReport = math.random(1, Config.CallCopsPercent)
print(Config.CallCopsPercent)
if randomReport == Config.CallCopsPercent then
TriggerServerEvent('drugsNotify')
end
end
local ped = GetPlayerPed(-1)
local vehicle = GetVehiclePedIsIn( ped, false )
exports.pNotify:SendNotification({text = "Chopping vehicle, please wait...", type = "error", timeout = 36000, layout = "centerRight", queue = "right", animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})

SetVehicleEngineOn(vehicle, false, false, true)
SetVehicleUndriveable(vehicle, false)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 2, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false), 2, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 3, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false), 3, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 4, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false),4, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 5, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false),5, true)
Citizen.Wait(1000)
DeleteVehicle()
exports.pNotify:SendNotification({text = "Vehicle Chopped Successfully...", type = "success", timeout = 1000, layout = "centerRight", queue = "right", animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
else
ESX.ShowNotification(_U('cooldown', math.ceil(cooldown/1000)))
SetVehicleEngineOn(vehicle, false, false, true)
SetVehicleUndriveable(vehicle, false)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 2, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false), 2, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 3, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false), 3, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 4, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false),4, true)
Citizen.Wait(1000)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), 5, false, false)
Citizen.Wait(5000)
SetVehicleDoorBroken(GetVehiclePedIsIn(GetPlayerPed(-1), false),5, true)
Citizen.Wait(1000)
DeleteVehicle()
exports.pNotify:SendNotification({text = "Vehicle Chopped Successfully...", type = "success", timeout = 1000, layout = "centerRight", queue = "right", animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
else
ESX.ShowNotification(_U('cooldown', math.ceil(cooldown/1000)))
end
end)
end

function DeleteVehicle()
--[[ ESX.TriggerServerCallback('Lenzh_chopshop:isCooldown', function(cooldown)
if cooldown <= 0 then ]]
if cooldown <= 0 then ]]
if IsDriver() then
local playerPed = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)

if IsPedInAnyVehicle(playerPed, false) then
local vehicle = GetVehiclePedIsIn(playerPed, false)
ESX.Game.DeleteVehicle(vehicle)
end
TriggerServerEvent("lenzh_chopshop:rewards", rewards)
end

TriggerServerEvent("lenzh_chopshop:rewards", rewards)

end
end
Expand All @@ -177,7 +185,7 @@ AddEventHandler('lenzh_chopshop:hasExitedMarker', function(zone)
end)

function CreateBlipCircle(coords, text, radius, color, sprite)

local blip = AddBlipForCoord(coords)
SetBlipSprite(blip, sprite)
SetBlipColour(blip, color)
Expand Down Expand Up @@ -281,7 +289,7 @@ Citizen.CreateThread(function()
if IsControlJustReleased(0, 38) then
if IsDriver() then
if CurrentAction == 'Chopshop' then
ChopVehicle()
ChopVehicle()
end
end
CurrentAction = nil
Expand All @@ -299,3 +307,128 @@ AddEventHandler('onResourceStop', function(resource)
end
end
end)

--DISPATCH BEGIN (better do not touch)
--Only if Config.CallCops = true
GetPlayerName()
RegisterNetEvent('outlawNotify')
AddEventHandler('outlawNotify', function(alert)
if PlayerData.job ~= nil and PlayerData.job.name == 'police' then
--Notify(alert)
Notify2(alert)
end
end)

function Notify(text)
SetNotificationTextEntry('STRING')
AddTextComponentString(text)
DrawNotification(false, false)
end

function Notify2(msg)

local mugshot, mugshotStr = ESX.Game.GetPedMugshot(GetPlayerPed(-1))

ESX.ShowAdvancedNotification(_U('911'), _U('chop'), _U('call'), mugshotStr, 1)

UnregisterPedheadshot(mugshot)

end


--Config
local timer = 1 --in minutes - Set the time during the player is outlaw
local showOutlaw = true --Set if show outlaw act on map
local blipTime = 35 --in second
local showcopsmisbehave = true --show notification when cops steal too
--End config

local timing = timer * 60000 --Don't touche it

Citizen.CreateThread(function()
while true do
Wait(100)
if NetworkIsSessionStarted() then
DecorRegister("IsOutlaw", 3)
DecorSetInt(GetPlayerPed(-1), "IsOutlaw", 1)
return
end
end
end)

Citizen.CreateThread( function()
while true do
Wait(100)
local plyPos = GetEntityCoords(GetPlayerPed(-1), true)
local s1, s2 = Citizen.InvokeNative( 0x2EB41072B4C1E4C0, plyPos.x, plyPos.y, plyPos.z, Citizen.PointerValueInt(), Citizen.PointerValueInt() )
local street1 = GetStreetNameFromHashKey(s1)
local street2 = GetStreetNameFromHashKey(s2)
if pedIsTryingToSellDrugs then
DecorSetInt(GetPlayerPed(-1), "IsOutlaw", 2)
if PlayerData.job ~= nil and PlayerData.job.name == 'police' and showcopsmisbehave == false then
elseif PlayerData.job ~= nil and PlayerData.job.name == 'police' and showcopsmisbehave then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
local sex = nil
if skin.sex == 0 then
sex = "male" --male/change it to your language
else
sex = "female" --female/change it to your language
end
TriggerServerEvent('ChoppingInProgressPos', plyPos.x, plyPos.y, plyPos.z)
if s2 == 0 then
TriggerServerEvent('ChopInProgressS1', street1, sex)
elseif s2 ~= 0 then
TriggerServerEvent('ChopInProgress', street1, street2, sex)
end
end)
Wait(3000)
pedIsTryingToSellDrugs = false
else
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
local sex = nil
if skin.sex == 0 then
sex = "male"
else
sex = "female"
end
TriggerServerEvent('ChoppingInProgressPos', plyPos.x, plyPos.y, plyPos.z)
if s2 == 0 then
TriggerServerEvent('ChopInProgressS1', street1, sex)
elseif s2 ~= 0 then
TriggerServerEvent('ChopInProgress', street1, street2, sex)
end
end)
Wait(3000)
pedIsTryingToSellDrugs = false
end
end
end
end)

RegisterNetEvent('Choplocation')
AddEventHandler('Choplocation', function(tx, ty, tz)
if PlayerData.job.name == 'police' then
local transT = 250
local Blip = AddBlipForCoord(tx, ty, tz)
SetBlipSprite(Blip, 10)
SetBlipColour(Blip, 1)
SetBlipAlpha(Blip, transT)
SetBlipAsShortRange(Blip, false)
while transT ~= 0 do
Wait(blipTime * 4)
transT = transT - 1
SetBlipAlpha(Blip, transT)
if transT == 0 then
SetBlipSprite(Blip, 2)
return
end
end
end
end)


RegisterNetEvent('drugsEnable')
AddEventHandler('drugsEnable', function()
pedIsTryingToSellDrugs = true
end)
--DISPATCH END
6 changes: 4 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ Config.MarkerType = 27
Config.MarkerColor = { r = 50, g = 50, b = 204 }

Config.Locale = 'en'
Config.CooldownMinutes = 1 -- Minutes between chopping.
Config.CooldownMinutes = 20 -- Minutes between chopping.

Config.CallCops = true
Config.CallCopsPercent = 1 -- (min1) if 1 then cops will be called every time=100%, 2=50%, 3=33%, 4=25%, 5=20%

Config.NPCEnable = true -- Set to false to disable NPC Ped at shop location.
Config.NPCHash = 68070371 --Hash of the npc ped. Change only if you know what you are doing.
Config.NPCHash = 68070371 --Hash of the npc ped. Change only if you know what you are doing.
Config.NPCShop = { x = -55.42, y = 6392.8, z = 30.5, h = 46.0 } -- Location of the shop For the npc

Config.GiveBlack = true -- Wanna use Blackmoney?
Expand Down
5 changes: 4 additions & 1 deletion locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ Locales['en'] = {
['shop_prompt'] = 'press ~INPUT_CONTEXT~ to talk with ~r~Stanley~s~.',
['item'] = '$%s',
['shop_title'] = 'Stanley\'s Car Parts',
['cooldown'] = '~s~You have to ~g~wait ~r~%s secondes ~s~before you can ~g~chop ~s~another vehicle.'
['cooldown'] = '~s~You have to ~g~wait ~r~%s secondes ~s~before you can ~g~chop ~s~another vehicle.',
['call'] = 'Someone is Chopping a vehicle. I attached a picture of the person',
['911'] = '911 Call',
['chop'] = 'Car Chopping',
}
27 changes: 26 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

ESX.RegisterServerCallback('Lenzh_chopshop:isCooldown',function(source, cb)
cb(cooldown)
end)
end)

RegisterServerEvent("lenzh_chopshop:rewards")
AddEventHandler("lenzh_chopshop:rewards", function()
Expand All @@ -23,6 +23,31 @@ function Rewards(rewards)
end
end

RegisterServerEvent('drugsNotify')
AddEventHandler('drugsNotify', function()
TriggerClientEvent("drugsEnable", source)
end)


RegisterServerEvent('ChopInProgress')
AddEventHandler('ChopInProgress', function(street1, street2, sex)
TriggerClientEvent("outlawNotify", -1, "~r~Someone is Chopping a vehicle")

end)


RegisterServerEvent('ChopInProgressS1')
AddEventHandler('ChopInProgressS1', function(street1, sex)
TriggerClientEvent("outlawNotify", -1, "~r~Someone is Chopping a vehicle")

end)

RegisterServerEvent('ChoppingInProgressPos')
AddEventHandler('ChoppingInProgressPos', function(gx, gy, gz)
TriggerClientEvent('Choplocation', -1, gx, gy, gz)
end)


RegisterServerEvent('lenzh_chopshop:sell')
AddEventHandler('lenzh_chopshop:sell', function(itemName, amount)
local xPlayer = ESX.GetPlayerFromId(source)
Expand Down

0 comments on commit b59b71b

Please sign in to comment.