mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 02:08:55 +00:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
dependency 'essentialmode'
|
||||
|
||||
client_script {
|
||||
'config.lua',
|
||||
'client/esx_holdup_cl.lua'
|
||||
}
|
||||
|
||||
server_script {
|
||||
'config.lua',
|
||||
'server/esx_holdup_sv.lua'
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
local holdingup = false
|
||||
local store = ""
|
||||
local secondsRemaining = 0
|
||||
local blipRobbery = nil
|
||||
ESX = nil
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while ESX == nil do
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
|
||||
function DisplayHelpText(str)
|
||||
SetTextComponentFormat("STRING")
|
||||
AddTextComponentString(str)
|
||||
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
||||
end
|
||||
|
||||
function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline)
|
||||
SetTextFont(0)
|
||||
SetTextProportional(0)
|
||||
SetTextScale(scale, scale)
|
||||
SetTextColour(r, g, b, a)
|
||||
SetTextDropShadow(0, 0, 0, 0,255)
|
||||
SetTextEdge(1, 0, 0, 0, 255)
|
||||
SetTextDropShadow()
|
||||
if(outline)then
|
||||
SetTextOutline()
|
||||
end
|
||||
SetTextEntry("STRING")
|
||||
AddTextComponentString(text)
|
||||
DrawText(x - width/2, y - height/2 + 0.005)
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx_holdup:currentlyrobbing')
|
||||
AddEventHandler('esx_holdup:currentlyrobbing', function(robb)
|
||||
holdingup = true
|
||||
store = robb
|
||||
secondsRemaining = 300
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_holdup:killblip')
|
||||
AddEventHandler('esx_holdup:killblip', function()
|
||||
RemoveBlip(blipRobbery)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_holdup:setblip')
|
||||
AddEventHandler('esx_holdup:setblip', function(position)
|
||||
blipRobbery = AddBlipForCoord(position.x, position.y, position.z)
|
||||
SetBlipSprite(blipRobbery , 161)
|
||||
SetBlipScale(blipRobbery , 2.0)
|
||||
SetBlipColour(blipRobbery, 3)
|
||||
PulseBlip(blipRobbery)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_holdup:toofarlocal')
|
||||
AddEventHandler('esx_holdup:toofarlocal', function(robb)
|
||||
holdingup = false
|
||||
ESX.ShowNotification('Le braquage vas être annulé, vous ne gagnerez rien!')
|
||||
robbingName = ""
|
||||
secondsRemaining = 0
|
||||
incircle = false
|
||||
end)
|
||||
|
||||
|
||||
RegisterNetEvent('esx_holdup:robberycomplete')
|
||||
AddEventHandler('esx_holdup:robberycomplete', function(robb)
|
||||
holdingup = false
|
||||
ESX.ShowNotification('Braquage réussi vous avez gagné ~g~$' .. Stores[store].reward)
|
||||
store = ""
|
||||
secondsRemaining = 0
|
||||
incircle = false
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
if holdingup then
|
||||
Citizen.Wait(1000)
|
||||
if(secondsRemaining > 0)then
|
||||
secondsRemaining = secondsRemaining - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
for k,v in pairs(Stores)do
|
||||
local ve = v.position
|
||||
|
||||
local blip = AddBlipForCoord(ve.x, ve.y, ve.z)
|
||||
SetBlipSprite(blip, 156)
|
||||
SetBlipScale(blip, 0.8)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentString("Braquage magasin")
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
end)
|
||||
incircle = false
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
local pos = GetEntityCoords(GetPlayerPed(-1), true)
|
||||
|
||||
for k,v in pairs(Stores)do
|
||||
local pos2 = v.position
|
||||
|
||||
if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 15.0)then
|
||||
if not holdingup then
|
||||
DrawMarker(1, v.position.x, v.position.y, v.position.z - 1, 0, 0, 0, 0, 0, 0, 1.0001, 1.0001, 1.5001, 1555, 0, 0,255, 0, 0, 0,0)
|
||||
|
||||
if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 1.0)then
|
||||
if (incircle == false) then
|
||||
DisplayHelpText("Appuyer sur ~INPUT_CONTEXT~ pour braquer ~b~" .. v.nameofstore)
|
||||
end
|
||||
incircle = true
|
||||
if IsControlJustReleased(1, 51) then
|
||||
TriggerServerEvent('esx_holdup:rob', k)
|
||||
end
|
||||
elseif(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 1.0)then
|
||||
incircle = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if holdingup then
|
||||
|
||||
drawTxt(0.66, 1.44, 1.0,1.0,0.4, "Braquage de magasin: ~r~" .. secondsRemaining .. "~w~ secondes restantes", 255, 255, 255, 255)
|
||||
|
||||
local pos2 = Stores[store].position
|
||||
|
||||
if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 7.5)then
|
||||
TriggerServerEvent('esx_holdup:toofar', store)
|
||||
end
|
||||
end
|
||||
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,50 @@
|
||||
Stores = {
|
||||
--[["paleto_twentyfourseven"] = {
|
||||
position = { ['x'] = 1736.32092285156, ['y'] = 6419.4970703125, ['z'] = 35.037223815918 },
|
||||
reward = math.random(100,1000),
|
||||
nameofstore = "24/7. (Paleto Bay)",
|
||||
lastrobbed = 0
|
||||
},]]
|
||||
["sandyshores_twentyfoursever"] = {
|
||||
position = { ['x'] = 1961.24682617188, ['y'] = 3749.46069335938, ['z'] = 32.3437461853027 },
|
||||
reward = math.random(500,5000),
|
||||
nameofstore = "24/7. (Sandy Shores)",
|
||||
lastrobbed = 0
|
||||
},
|
||||
["bar_one"] = {
|
||||
position = { ['x'] = 1986.1240234375, ['y'] = 3053.8747558594, ['z'] = 47.215171813965 },
|
||||
reward = math.random(500,5000),
|
||||
nameofstore = "Yellow Jack. (Sandy Shores)",
|
||||
lastrobbed = 0
|
||||
},
|
||||
["ocean_liquor"] = {
|
||||
position = { ['x'] = -2959.33715820313, ['y'] = 388.214172363281, ['z'] = 14.0432071685791 },
|
||||
reward = math.random(1000,10000),
|
||||
nameofstore = "Robs Liquor. (Great Ocean Higway)",
|
||||
lastrobbed = 0
|
||||
},
|
||||
["sanandreas_liquor"] = {
|
||||
position = { ['x'] = -1219.85607910156, ['y'] = -916.276550292969, ['z'] = 11.3262157440186 },
|
||||
reward = math.random(1000,10000),
|
||||
nameofstore = "Robs Liquor. (San andreas Avenue)",
|
||||
lastrobbed = 0
|
||||
},
|
||||
["grove_ltd"] = {
|
||||
position = { ['x'] = -43.4035377502441, ['y'] = -1749.20922851563, ['z'] = 29.421012878418 },
|
||||
reward = math.random(1000,10000),
|
||||
nameofstore = "LTD Gasoline. (Grove Street)",
|
||||
lastrobbed = 0
|
||||
},
|
||||
["mirror_ltd"] = {
|
||||
position = { ['x'] = 1160.67578125, ['y'] = -314.400451660156, ['z'] = 69.2050552368164 },
|
||||
reward = math.random(1000,10000),
|
||||
nameofstore = "LTD Gasoline. (Mirror Park Boulevard)",
|
||||
lastrobbed = 0
|
||||
},
|
||||
["littleseoul_twentyfourseven"] = {
|
||||
position = { ['x'] = -709.17022705078, ['y'] = -904.21722412109, ['z'] = 19.215591430664 },
|
||||
reward = math.random(1000,10000),
|
||||
nameofstore = "24/7. (Little Seoul)",
|
||||
lastrobbed = 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
local rob = false
|
||||
local robbers = {}
|
||||
ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
function get3DDistance(x1, y1, z1, x2, y2, z2)
|
||||
return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2) + math.pow(z1 - z2, 2))
|
||||
end
|
||||
|
||||
RegisterServerEvent('esx_holdup:toofar')
|
||||
AddEventHandler('esx_holdup:toofar', function(robb)
|
||||
local source = source
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
rob = false
|
||||
for k, v in pairs(xPlayers) do
|
||||
if v.job.name == 'police' then
|
||||
TriggerClientEvent('esx:showNotification', k, '~r~ Braquage annulé à: ~b~' .. Stores[robb].nameofstore)
|
||||
TriggerClientEvent('esx_holdup:killblip', k)
|
||||
end
|
||||
end
|
||||
if(robbers[source])then
|
||||
TriggerClientEvent('esx_holdup:toofarlocal', source)
|
||||
robbers[source] = nil
|
||||
TriggerClientEvent('esx:showNotification', source, '~r~ Le braquage à été annulé: ~b~' .. Stores[robb].nameofstore)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_holdup:rob')
|
||||
AddEventHandler('esx_holdup:rob', function(robb)
|
||||
|
||||
local source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
|
||||
if Stores[robb] then
|
||||
|
||||
local store = Stores[robb]
|
||||
|
||||
if (os.time() - store.lastrobbed) < 600 and store.lastrobbed ~= 0 then
|
||||
|
||||
|
||||
TriggerClientEvent('esx:showNotification', source, 'Ce magasin a déjà été braqué. Veuillez attendre: ' .. (1800 - (os.time() - store.lastrobbed)) .. "secondes.")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local cops = 0
|
||||
for k, v in pairs(xPlayers) do
|
||||
if v.job.name == 'police' then
|
||||
cops = cops + 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if rob == false then
|
||||
|
||||
if(cops > 1)then
|
||||
|
||||
rob = true
|
||||
for k, v in pairs(xPlayers) do
|
||||
if v.job.name == 'police' then
|
||||
TriggerClientEvent('esx:showNotification', k, '~r~ Braquage en cours à: ~b~' .. store.nameofstore)
|
||||
TriggerClientEvent('esx_holdup:setblip', k, Stores[robb].position)
|
||||
end
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:showNotification', source, 'Vous avez commencé à braquer ' .. store.nameofstore .. ', ne vous éloignez pas!')
|
||||
TriggerClientEvent('esx:showNotification', source, 'L\'alarme à été déclenché ')
|
||||
TriggerClientEvent('esx:showNotification', source, 'Tenez la position pendant 5min et l\'argent est à vous! ')
|
||||
TriggerClientEvent('esx_holdup:currentlyrobbing', source, robb)
|
||||
Stores[robb].lastrobbed = os.time()
|
||||
robbers[source] = robb
|
||||
local savedSource = source
|
||||
SetTimeout(300000, function()
|
||||
|
||||
if(robbers[savedSource])then
|
||||
|
||||
rob = false
|
||||
TriggerClientEvent('esx_holdup:robberycomplete', savedSource, job)
|
||||
if(xPlayer)then
|
||||
|
||||
xPlayer.addAccountMoney('black_money', store.reward)
|
||||
TriggerClientEvent('esx:showNotification', source, '~r~ Braquage terminé.~s~ ~h~ Fuie!')
|
||||
for k, v in pairs(xPlayers) do
|
||||
if v.job.name == 'police' then
|
||||
TriggerClientEvent('esx:showNotification', k, '~r~ Braquage terminé à: ~b~' .. store.nameofstore)
|
||||
TriggerClientEvent('esx_holdup:killblip', k)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, 'Il faut minimum ~b~2 policiers~s~ en ville pour braquer.')
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, '~r~Un braquage est déjà en cours.')
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user