Improved manifest (fixes #13), formatted strings (todo)

This commit is contained in:
ElPumpo
2018-04-24 22:26:20 +02:00
parent 56c27d23c2
commit c6f6dd544b
5 changed files with 246 additions and 221 deletions
+30 -11
View File
@@ -1,20 +1,39 @@
# fxserver_esx_holdup
FXserver ESX Hold Up
# esx_holdup
### Requirements
- [esx_policejob](https://github.com/ESX-Org/esx_policejob)
[REQUIREMENTS]
## Download & Installation
* esx_policejob => https://github.com/ESX-Org/esx_policejob
[INSTALLATION]
1) CD in your resources/[esx] folder
2) Clone the repository
### Using [fvm](https://github.com/qlaffont/fvm-installer)
```
git clone https://github.com/ESX-Org/esx_holdup esx_holdup
fvm install --save --folder=esx esx-org/esx_holdup
```
3) Add this in your server.cfg :
### Using Git
```
cd resources
git clone https://github.com/ESX-Org/esx_holdup [esx]/esx_holdup
```
### Manually
- Download https://github.com/ESX-Org/esx_holdup/archive/master.zip
- Put it in the `[esx]` directory
## Installation
- Add this to your `server.cfg`:
```
start esx_holdup
```
# Legal
### License
esx_holdup - rob stores
Copyright (C) 2015-2018 Jérémie N'gadi
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.
You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/.
+20 -17
View File
@@ -1,24 +1,27 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
description 'ESX Holdup'
version '1.0.1'
client_scripts {
'@es_extended/locale.lua',
'locales/de.lua',
'locales/br.lua',
'locales/en.lua',
'locales/fr.lua',
'locales/sv.lua',
'config.lua',
'client/main.lua'
'@es_extended/locale.lua',
'locales/de.lua',
'locales/br.lua',
'locales/en.lua',
'locales/fr.lua',
'locales/sv.lua',
'config.lua',
'client/main.lua'
}
server_scripts {
'@es_extended/locale.lua',
'locales/de.lua',
'locales/br.lua',
'locales/en.lua',
'locales/fr.lua',
'locales/sv.lua',
'config.lua',
'server/main.lua'
'@es_extended/locale.lua',
'locales/de.lua',
'locales/br.lua',
'locales/en.lua',
'locales/fr.lua',
'locales/sv.lua',
'config.lua',
'server/main.lua'
}
+107 -93
View File
@@ -3,147 +3,161 @@ local store = ""
local blipRobbery = nil
ESX = nil
local Keys = {
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
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)
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)
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
holdingup = true
store = robb
end)
RegisterNetEvent('esx_holdup:killblip')
AddEventHandler('esx_holdup:killblip', function()
RemoveBlip(blipRobbery)
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)
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(_U('robbery_cancelled'))
robbingName = ""
incircle = false
holdingup = false
ESX.ShowNotification(_U('robbery_cancelled'))
robbingName = ""
incircle = false
end)
RegisterNetEvent('esx_holdup:robberycomplete')
AddEventHandler('esx_holdup:robberycomplete', function(robb)
holdingup = false
ESX.ShowNotification(_U('robbery_complete'))
store = ""
incircle = false
holdingup = false
ESX.ShowNotification(_U('robbery_complete'))
store = ""
incircle = false
end)
RegisterNetEvent('esx_holdup:starttimer')
AddEventHandler('esx_holdup:starttimer', function(source)
timer = Stores[store].secondsRemaining
Citizen.CreateThread(function()
while timer > 0 do
Citizen.Wait(0)
Citizen.Wait(1000)
if(timer > 0)then
timer = timer - 1
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if holdingup then
drawTxt(0.66, 1.44, 1.0,1.0,0.4, _U('robbery_of') .. timer .. _U('seconds_remaining'), 255, 255, 255, 255)
end
end
end)
timer = Stores[store].secondsRemaining
Citizen.CreateThread(function()
while timer > 0 do
Citizen.Wait(0)
Citizen.Wait(1000)
if(timer > 0)then
timer = timer - 1
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if holdingup then
drawTxt(0.66, 1.44, 1.0,1.0,0.4, _U('robbery_timer', timer), 255, 255, 255, 255)
elseif
Citizen.Wait(1000)
end
end
end)
end)
Citizen.CreateThread(function()
for k,v in pairs(Stores)do
local ve = v.position
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(_U('shop_robbery'))
EndTextCommandSetBlipName(blip)
end
local blip = AddBlipForCoord(ve.x, ve.y, ve.z)
SetBlipSprite(blip, 156)
SetBlipScale(blip, 0.8)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(_U('shop_robbery'))
EndTextCommandSetBlipName(blip)
end
end)
incircle = false
Citizen.CreateThread(function()
while true do
local pos = GetEntityCoords(GetPlayerPed(-1), true)
while true do
local pos = GetEntityCoords(GetPlayerPed(-1), true)
for k,v in pairs(Stores)do
local pos2 = v.position
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) < 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(_U('press_to_rob') .. 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(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 1.0)then
if (incircle == false) then
DisplayHelpText(_U('press_to_rob') .. v.nameofstore)
end
incircle = true
if IsControlJustReleased(0, Keys['E']) 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
if holdingup then
local pos2 = Stores[store].position
local pos2 = Stores[store].position
if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 13)then
TriggerServerEvent('esx_holdup:toofar', store)
end
end
if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 13)then
TriggerServerEvent('esx_holdup:toofar', store)
end
end
Citizen.Wait(0)
end
Citizen.Wait(0)
end
end)
+13 -20
View File
@@ -1,23 +1,16 @@
Locales['sv'] = {
['robbery_cancelled'] = 'rånet kommer att avbrytas, du får ingenting!',
['robbery_successful'] = 'du lyckades råna och har nu fått ~g~$',
['shop_robbery'] = 'Råna Affär',
['robbery_cancelled'] = 'rånet har avbryts, spring nu!',
['shop_robbery'] = 'råna butik',
['press_to_rob'] = 'tryck ~INPUT_CONTEXT~ för att råna ~b~',
['robbery_of'] = 'store robbery: ~r~',
['seconds_remaining'] = '~w~ sekunder kvar',
['robbery_cancelled_at'] = '~r~ Rånet avbrutet: ~b~',
['robbery_has_cancelled'] = '~r~ rånet har blivit avbrutet: ~b~',
['already_robbed'] = 'denna affär har redan blivit råna, Vänta lite: ',
['seconds'] = 'sekunder.',
['rob_in_prog'] = '~r~ pågående rån vid: ~b~',
['started_to_rob'] = 'du började att råna ',
['do_not_move'] = ', Rör dig inte!',
['alarm_triggered'] = 'larmet har utlösts',
['hold_pos'] = 'stanna i 5 minuter och pengarna är din!',
['robbery_complete'] = '~r~ Rånet avklarat.~s~ ~h~ Spring!',
['robbery_complete_at'] = '~r~ Rånet har blivit avslutat och dom har fått pengar: ~b~',
['min_two_police'] = 'det måste vara minst~b~2 poliser~s~ för att råna.',
['robbery_timer'] = 'butiksrån: ~r~%s~s~ sekunder kvarstår',
['robbery_cancelled_at'] = '~r~Rånet~s~ vid ~b~%s~s~ har avbrytits!',
['recently_robbed'] = 'denna butik har nyligen rånats, du måste vänta ~y~%s~s~ sekunder!',
['rob_in_prog'] = '~r~Det är ett pågående rån vid ~b~%s~s~',
['started_to_rob'] = 'du började att råna ~y~%s~s~, gå inte för långt från butiken!',
['alarm_triggered'] = '~o~Larmet har utlösts~s~',
['hold_pos'] = 'vänta 5 minuter och pengarna är dina!',
['robbery_complete'] = '~r~Rånet är avklarat~s~, förlora polisen!',
['robbery_complete_at'] = '~r~Ett rån lyckades~s~ vid ~y~%s~s~',
['min_police'] = 'det måste vara minst ~b~%s poliser~s~ inne för att du ska kunna ~o~råna butiker~s~.',
['robbery_already'] = '~r~Ett rån pågår redan.',
}
}
+76 -80
View File
@@ -4,105 +4,101 @@ 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 i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_cancelled_at') .. Stores[robb].nameofstore)
TriggerClientEvent('esx_holdup:killblip', xPlayers[i])
end
end
if(robbers[_source])then
TriggerClientEvent('esx_holdup:toofarlocal', _source)
robbers[_source] = nil
TriggerClientEvent('esx:showNotification', _source, _U('robbery_has_cancelled') .. Stores[robb].nameofstore)
end
local _source = source
local xPlayers = ESX.GetPlayers()
rob = false
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_cancelled_at', Stores[robb].nameofstore))
TriggerClientEvent('esx_holdup:killblip', xPlayers[i])
end
end
if(robbers[_source])then
TriggerClientEvent('esx_holdup:toofarlocal', _source)
robbers[_source] = nil
TriggerClientEvent('esx:showNotification', _source, _U('robbery_cancelled_at', 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()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local xPlayers = ESX.GetPlayers()
if Stores[robb] then
if Stores[robb] then
local store = Stores[robb]
local store = Stores[robb]
if (os.time() - store.lastrobbed) < Config.TimerBeforeNewRob and store.lastrobbed ~= 0 then
if (os.time() - store.lastrobbed) < Config.TimerBeforeNewRob and store.lastrobbed ~= 0 then
TriggerClientEvent('esx:showNotification', _source, _U('already_robbed') .. (Config.TimerBeforeNewRob - (os.time() - store.lastrobbed)) .. _U('seconds'))
return
end
TriggerClientEvent('esx:showNotification', _source, _U('recently_robbed', Config.TimerBeforeNewRob - (os.time() - store.lastrobbed)))
return
end
local cops = 0
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
cops = cops + 1
end
end
local cops = 0
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
cops = cops + 1
end
end
if rob == false then
if rob == false then
if(cops >= Config.PoliceNumberRequired)then
if(cops >= Config.PoliceNumberRequired)then
rob = true
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('rob_in_prog') .. store.nameofstore)
TriggerClientEvent('esx_holdup:setblip', xPlayers[i], Stores[robb].position)
end
end
rob = true
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('rob_in_prog', store.nameofstore))
TriggerClientEvent('esx_holdup:setblip', xPlayers[i], Stores[robb].position)
end
end
TriggerClientEvent('esx:showNotification', _source, _U('started_to_rob') .. store.nameofstore .. _U('do_not_move'))
TriggerClientEvent('esx:showNotification', _source, _U('alarm_triggered'))
TriggerClientEvent('esx:showNotification', _source, _U('hold_pos'))
TriggerClientEvent('esx_holdup:currentlyrobbing', _source, robb)
TriggerClientEvent('esx_holdup:starttimer', _source)
Stores[robb].lastrobbed = os.time()
robbers[_source] = robb
local savedSource = _source
SetTimeout(store.secondsRemaining*1000, function()
TriggerClientEvent('esx:showNotification', _source, _U('started_to_rob', store.nameofstore))
TriggerClientEvent('esx:showNotification', _source, _U('alarm_triggered'))
TriggerClientEvent('esx:showNotification', _source, _U('hold_pos'))
TriggerClientEvent('esx_holdup:currentlyrobbing', _source, robb)
TriggerClientEvent('esx_holdup:starttimer', _source)
Stores[robb].lastrobbed = os.time()
robbers[_source] = robb
local savedSource = _source
SetTimeout(store.secondsRemaining * 1000, function()
if(robbers[savedSource])then
if(robbers[savedSource])then
rob = false
TriggerClientEvent('esx_holdup:robberycomplete', savedSource, job)
if(xPlayer)then
rob = false
TriggerClientEvent('esx_holdup:robberycomplete', savedSource, job)
if(xPlayer)then
xPlayer.addAccountMoney('black_money', store.reward)
local xPlayers = ESX.GetPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_complete_at') .. store.nameofstore)
TriggerClientEvent('esx_holdup:killblip', xPlayers[i])
end
end
end
end
end)
else
TriggerClientEvent('esx:showNotification', _source, _U('min_police') .. Config.PoliceNumberRequired .. _U('in_city'))
end
else
TriggerClientEvent('esx:showNotification', _source, _U('robbery_already'))
end
end
xPlayer.addAccountMoney('black_money', store.reward)
local xPlayers = ESX.GetPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_complete_at', store.nameofstore))
TriggerClientEvent('esx_holdup:killblip', xPlayers[i])
end
end
end
end
end)
else
TriggerClientEvent('esx:showNotification', _source, _U('min_police', Config.PoliceNumberRequired))
end
else
TriggerClientEvent('esx:showNotification', _source, _U('robbery_already'))
end
end
end)