diff --git a/README.md b/README.md index 403d87c3..7b2d9ed0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/__resource.lua b/__resource.lua index 38393945..4947d088 100644 --- a/__resource.lua +++ b/__resource.lua @@ -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' -} +} \ No newline at end of file diff --git a/client/esx_jobs_cl.lua b/client/esx_jobs_cl.lua index ba16f310..651aec84 100644 --- a/client/esx_jobs_cl.lua +++ b/client/esx_jobs_cl.lua @@ -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 diff --git a/html/bankgothic.ttf b/html/bankgothic.ttf deleted file mode 100644 index f3d8049b..00000000 Binary files a/html/bankgothic.ttf and /dev/null differ diff --git a/html/css/app.css b/html/css/app.css deleted file mode 100644 index f5b568b8..00000000 --- a/html/css/app.css +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/html/img/keys/enter.png b/html/img/keys/enter.png deleted file mode 100644 index 3eb9a1f6..00000000 Binary files a/html/img/keys/enter.png and /dev/null differ diff --git a/html/img/keys/return.png b/html/img/keys/return.png deleted file mode 100644 index a3ca125a..00000000 Binary files a/html/img/keys/return.png and /dev/null differ diff --git a/html/pdown.ttf b/html/pdown.ttf deleted file mode 100644 index 69c76cf3..00000000 Binary files a/html/pdown.ttf and /dev/null differ diff --git a/html/scripts/app.js b/html/scripts/app.js deleted file mode 100644 index 6f0e1a3c..00000000 --- a/html/scripts/app.js +++ /dev/null @@ -1,168 +0,0 @@ -(function(){ - - let DefaultTpl = - '
{{title}}
' + - ''+ - '' - ; - - let DefaultWithTypeAndCountTpl = - '
{{title}}
' + - ''+ - '' - ; - - 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) }); } - -})() \ No newline at end of file diff --git a/html/scripts/mustache.min.js b/html/scripts/mustache.min.js deleted file mode 100644 index 520cfcb9..00000000 --- a/html/scripts/mustache.min.js +++ /dev/null @@ -1 +0,0 @@ -(function defineMustache(global,factory){if(typeof exports==="object"&&exports&&typeof exports.nodeName!=="string"){factory(exports)}else if(typeof define==="function"&&define.amd){define(["exports"],factory)}else{global.Mustache={};factory(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){return typeof object==="function"}function typeStr(obj){return isArray(obj)?"array":typeof obj}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function escapeHtml(string){return String(string).replace(/[&<>"'`=\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}hasTag=false;nonSpace=false}var openingTagRe,closingTagRe,closingCurlyRe;function compileTags(tagsToCompile){if(typeof tagsToCompile==="string")tagsToCompile=tagsToCompile.split(spaceRe,2);if(!isArray(tagsToCompile)||tagsToCompile.length!==2)throw new Error("Invalid tags: "+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+"\\s*");closingTagRe=new RegExp("\\s*"+escapeRegExp(tagsToCompile[1]));closingCurlyRe=new RegExp("\\s*"+escapeRegExp("}"+tagsToCompile[1]))}compileTags(tags||mustache.tags);var scanner=new Scanner(template);var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};Scanner.prototype.scanUntil=function scanUntil(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail="";break;case 0:match="";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;var value;if(cache.hasOwnProperty(name)){value=cache[name]}else{var context=this,names,index,lookupHit=false;while(context){if(name.indexOf(".")>0){value=context.view;names=name.split(".");index=0;while(value!=null&&index")value=this.renderPartial(token,context,partials,originalTemplate);else if(symbol==="&")value=this.unescapedValue(token,context);else if(symbol==="name")value=this.escapedValue(token,context);else if(symbol==="text")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer="";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j - - - - - - - - - - - - - - \ No newline at end of file diff --git a/locales/en.lua b/locales/en.lua index add423f5..427901ec 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -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~$', diff --git a/locales/fr.lua b/locales/fr.lua index d2cc73b1..e8c9a6cb 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -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.', diff --git a/server/esx_jobs_sv.lua b/server/esx_jobs_sv.lua index dca0a4ea..eef5999a 100644 --- a/server/esx_jobs_sv.lua +++ b/server/esx_jobs_sv.lua @@ -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)