Fix security deposit, now using esx menus

This commit is contained in:
renaiku
2017-08-22 04:32:35 +02:00
parent 5733fdd46e
commit 92c4c73f14
14 changed files with 53 additions and 303 deletions
+1 -5
View File
@@ -2,13 +2,9 @@
[REQUIRES]
- fxserver-esx_addonaccount: https://github.com/FXServer-ESX/fxserver-esx_addonaccount
[KNOWN BUGS]
The bail is not given back when the player disconnect or timeout.
[FEATURES]
- Jobs: Slaughterer, Miner, Fisherman, Journalist, etc...
- Bails
- Security deposit when renting a job vehicle (given back in case of crash, to the amount of damage the vehicle has already taken)
- Easy system to create jobs (samples in jobs folder)
- Item farming jobs
- On Duty system
+1 -14
View File
@@ -22,17 +22,4 @@ client_scripts {
'jobs/slaughterer.lua',
'jobs/textil.lua',
'client/esx_jobs_cl.lua'
}
ui_page 'html/ui.html'
files {
'html/ui.html',
'html/bankgothic.ttf',
'html/pdown.ttf',
'html/css/app.css',
'html/scripts/mustache.min.js',
'html/scripts/app.js',
'html/img/keys/enter.png',
'html/img/keys/return.png'
}
}
+38 -27
View File
@@ -66,13 +66,47 @@ AddEventHandler('esx_jobs:publicTeleports', function(position)
SetEntityCoords(GetPlayerPed(-1), position.x, position.y, position.z)
end)
function OpenMenu()
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'cloakroom',
{
title = _U('cloakroom'),
elements = {
{label = _U('job_wear'), value = 'job_wear'},
{label = _U('citizen_wear'), value = 'citizen_wear'}
}
},
function(data, menu)
if data.current.value == 'citizen_wear' then
onDuty = false
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
end
if data.current.value == 'job_wear' then
onDuty = true
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)
else
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female)
end
end)
end
menu.close()
end,
function(data, menu)
menu.close()
end
)
end
AddEventHandler('esx_jobs:action', function(job, zone)
menuIsShowed = true
if zone.Type == "cloakroom" then
SendNUIMessage({
showMenu = true,
menu = 'cloakroom'
})
OpenMenu()
elseif zone.Type == "work" then
hintToDisplay = "no hint to display"
hintIsShowed = false
@@ -247,29 +281,6 @@ function refreshBlips()
end
end
-- #########################
RegisterNUICallback('select', function(data, cb)
if data.menu == 'cloakroom' then
if data.val == 'citizen_wear' then
onDuty = false
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
end
if data.val == 'job_wear' then
onDuty = true
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)
else
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female)
end
end)
end
end
cb('ok')
end)
function spawncar(spawnPoint, vehicle)
hintToDisplay = "no hint to display"
hintIsShowed = false
Binary file not shown.
-61
View File
@@ -1,61 +0,0 @@
@font-face {
font-family: bankgothic;
src: url('../bankgothic.ttf');
}
@font-face {
font-family: pcdown;
src: url('../pdown.ttf');
}
#controls {
font-family : pcdown;
font-size : 3em;
color : #FFF;
position : absolute;
bottom : 40;
right : 40;
text-shadow:
-1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000
;
}
.controls {
display: none;
}
.menu {
font-family : bankgothic;
min-width : 350px;
background-color: #506be6;
color : #fff;
box-shadow : 0px 0px 50px 0px #000;
position : absolute;
left : 40;
top : 40;
}
.menu .head {
text-align : center;
height : 40px;
line-height : 40px;
}
.menu .menu-items .menu-item {
height : 40px;
display : block;
background-color: #f1f1f1;
box-shadow : inset 1px 0px 0px 1px #b8b8b8;
height : 32px;
line-height : 32px;
color : #3A3A3A;
text-align : center;
}
.menu .menu-items .menu-item.selected {
background-color: #d0d0d0;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

BIN
View File
Binary file not shown.
-168
View File
@@ -1,168 +0,0 @@
(function(){
let DefaultTpl =
'<div class="head">{{title}}</div>' +
'<div class="menu-items">' +
'{{#items}}<div class="menu-item" data-value="{{value}}">{{label}}</div>{{/items}}' +
'</div>'+
'</div>'
;
let DefaultWithTypeAndCountTpl =
'<div class="head">{{title}}</div>' +
'<div class="menu-items">' +
'{{#items}}<div class="menu-item" data-value="{{value}}" data-remove-on-select="{{removeOnSelect}}" data-type="{{type}}" data-count="{{count}}">{{label}}</div>{{/items}}' +
'</div>'+
'</div>'
;
let menus = {
cloakroom : {
title : 'Vestiaire',
visible : false,
current : 0,
hasControl: true,
template : DefaultTpl,
items: [
{label: 'Tenue civile', value: 'citizen_wear'},
{label: 'Tenue de travail', value: 'job_wear'}
]
},
}
let renderMenus = function(){
for(let k in menus){
let elem = $('#menu_' + k);
elem.html(Mustache.render(menus[k].template, menus[k]));
if(menus[k].visible)
elem.show();
else
elem.hide();
}
}
let showMenu = function(menu){
currentMenu = menu;
for(let k in menus)
menus[k].visible = false;
menus[menu].visible = true;
renderMenus();
if(menus[currentMenu].items.length > 0){
$('#menu_' + currentMenu + ' .menu-item').removeClass('selected');
$('#menu_' + currentMenu + ' .menu-item:eq(0)').addClass('selected');
menus[currentMenu].current = 0;
currentVal = menus[currentMenu].items[menus[currentMenu].current].value;
currentType = $('#menu_' + currentMenu + ' .menu-item:eq(0)').data('type');
currentCount = $('#menu_' + currentMenu + ' .menu-item:eq(0)').data('count');
}
isMenuOpen = true
}
let hideMenus = function(){
for(let k in menus)
menus[k].visible = false;
renderMenus();
isMenuOpen = false;
}
let isMenuOpen = false
let currentMenu = null;
let currentControl = null;
let currentVal = null;
let currentType = null;
let currentCount = null;
renderMenus();
window.onData = function(data){
if(data.showMenu === true){
showMenu(data.menu);
}
if(data.showMenu === false){
hideMenus();
}
if(data.move && isMenuOpen){
if(data.move == 'UP'){
if(menus[currentMenu].current > 0)
menus[currentMenu].current--;
}
if(data.move == 'DOWN'){
let max = $('#menu_' + currentMenu + ' .menu-item').length;
if(menus[currentMenu].current < max - 1)
menus[currentMenu].current++;
}
$('#menu_' + currentMenu + ' .menu-item').removeClass('selected');
$('#menu_' + currentMenu + ' .menu-item:eq(' + menus[currentMenu].current + ')').addClass('selected');
currentVal = menus[currentMenu].items[menus[currentMenu].current].value;
currentType = $('#menu_' + currentMenu + ' .menu-item:eq(' + menus[currentMenu].current + ')').data('type');
currentCount = $('#menu_' + currentMenu + ' .menu-item:eq(' + menus[currentMenu].current + ')').data('count');
}
if(data.enterPressed){
if(isMenuOpen) {
$.post('http://esx_jobs/select', JSON.stringify({
menu : currentMenu,
val : currentVal,
type : currentType,
count: currentCount
}))
let elem = $('#menu_' + currentMenu + ' .menu-item.selected')
if(elem.data('remove-on-select') == true){
elem.remove();
menus[currentMenu].items.splice(menus[currentMenu].current, 1)
menus[currentMenu].current = 0;
$('#menu_' + currentMenu + ' .menu-item').removeClass('selected');
$('#menu_' + currentMenu + ' .menu-item:eq(0)').addClass('selected');
currentVal = menus[currentMenu].items[0].value;
currentType = $('#menu_' + currentMenu + ' .menu-item:eq(0)').data('type');
currentCount = $('#menu_' + currentMenu + ' .menu-item:eq(0)').data('count');
}
}
}
if(data.backspacePressed){
if(isMenuOpen && currentMenu == 'cloakroom'){
hideMenus();
}
}
}
window.onload = function(e){ window.addEventListener('message', function(event){ onData(event.data) }); }
})()
-1
View File
File diff suppressed because one or more lines are too long
-15
View File
@@ -1,15 +0,0 @@
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="css/app.css" type="text/css" />
</head>
<body>
<div class="menu" id="menu_cloakroom"></div>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> -->
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="scripts/mustache.min.js"></script>
<script src="scripts/app.js"></script>
</body>
</html>
+1 -1
View File
@@ -5,7 +5,7 @@ Locales['en'] = {
['bank_deposit'] = 'a security deposit of ~g~',
['bank_deposit_r'] = 'a security deposit of ~g~$',
['bank_deposit2'] = '$ ~s~was made to you after your fainting.',
['bank_nodeposit'] = "you did not have a surety",
['bank_nodeposit'] = "you did not have a security deposit",
['foot_work'] = 'you have to be on foot to be able to work.',
['next_point'] = 'go to the next step after completing this one.',
['security_deposit'] = 'the security given will be ~g~$',
+2
View File
@@ -2,6 +2,8 @@ Locales['fr'] = {
--Global menus
['cloakroom'] = 'vestiaire',
['cloak_change'] = 'appuyez sur ~INPUT_PICKUP~ pour vous changer.',
['citizen_wear'] = 'Tenue civile',
['job_wear'] = 'Tenue de travail',
['bank_deposit'] = 'une caution de ~g~',
['bank_deposit_r'] = 'une caution de ~g~$',
['bank_deposit2'] = '$ ~s~vous a été rendue suite à votre évanouissment.',
+10 -11
View File
@@ -5,7 +5,8 @@ ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
AddEventHandler('esx:playerLoaded', function(source)
local xPlayer = ESX.GetPlayerFromId(source)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
xPlayer.set('caution', 0)
end)
@@ -29,19 +30,17 @@ RegisterServerEvent('esx_jobs:giveBackCautionInCaseOfDrop')
AddEventHandler('esx_jobs:giveBackCautionInCaseOfDrop', function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local caution = 0
TriggerEvent('esx_addonaccount:getAccount', 'caution', xPlayer.identifier, function(account)
caution = account.money
local caution = account.money
account.removeMoney(caution)
if caution > 0 then
xPlayer.addAccountMoney('bank', caution)
TriggerClientEvent('esx:showNotification', _source, _U('bank_deposit_g').. caution .. _U('bank_deposit2'))
else
TriggerClientEvent('esx:showNotification', _source, _U('bank_nodeposit'))
end
end)
if caution > 0 then
xPlayer.addAccountMoney('bank', value)
TriggerClientEvent('esx:showNotification', _source, _U('bank_deposit_g').. value .. _U('bank_deposit2'))
else
TriggerClientEvent('esx:showNotification', _source, _U('bank_nodeposit'))
end
end)
local function Work(source, item)