Merge branch 'main' into refactor-1

This commit is contained in:
Csoki
2022-11-26 18:29:57 +01:00
26 changed files with 279 additions and 296 deletions
+12 -12
View File
@@ -680,18 +680,18 @@ function ESX.Game.GetVehicleProperties(vehicle)
customPrimaryColor = {GetVehicleCustomPrimaryColour(vehicle)}
end
local customXenonColorR, customXenonColorG, customXenonColorB = GetVehicleXenonLightsCustomColor(vehicle)
local customXenonColor = nil
if customXenonColorR and customXenonColorG and customXenonColorB then
customXenonColor = {customXenonColorR, customXenonColorG, customXenonColorB}
end
local hasCustomSecondaryColor = GetIsVehicleSecondaryColourCustom(vehicle)
local customSecondaryColor = nil
if hasCustomSecondaryColor then
customSecondaryColor = {GetVehicleCustomSecondaryColour(vehicle)}
end
local extras = {}
local hasCustomXenonColor, customXenonColorR, customXenonColorG, customXenonColorB = GetVehicleXenonLightsCustomColor(vehicle)
local customXenonColor = nil
if hasCustomXenonColor then
customXenonColor = {customXenonColorR, customXenonColorG, customXenonColorB}
end
local hasCustomSecondaryColor = GetIsVehicleSecondaryColourCustom(vehicle)
local customSecondaryColor = nil
if hasCustomSecondaryColor then
customSecondaryColor = {GetVehicleCustomSecondaryColour(vehicle)}
end
local extras = {}
for extraId = 0, 12 do
if DoesExtraExist(vehicle, extraId) then
+4
View File
@@ -13,6 +13,10 @@ CreateThread(function()
end
end)
RegisterNetEvent("esx:requestModel", function(model)
ESX.Streaming.RequestModel(model)
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
ESX.PlayerData = xPlayer
@@ -19,6 +19,12 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
if Config.Multichar then self.license = 'license'.. identifier:sub(identifier:find(':'), identifier:len()) else self.license = 'license:'..identifier end
ExecuteCommand(('add_principal identifier.%s group.%s'):format(self.license, self.group))
Player(self.source).state:set("identifier", self.identifier, true)
Player(self.source).state:set("license", self.license, true)
Player(self.source).state:set("job", self.job, true)
Player(self.source).state:set("group", self.group, true)
Player(self.source).state:set("name", self.name, true)
function self.triggerEvent(eventName, ...)
TriggerClientEvent(eventName, self.source, ...)
@@ -78,6 +84,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
function self.setGroup(newGroup)
ExecuteCommand(('remove_principal identifier.%s group.%s'):format(self.license, self.group))
self.group = newGroup
Player(self.source).state:set("group", self.group, true)
ExecuteCommand(('add_principal identifier.%s group.%s'):format(self.license, self.group))
end
@@ -87,6 +94,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
function self.set(k, v)
self.variables[k] = v
Player(self.source).state:set(k, v, true)
end
function self.get(k)
@@ -170,6 +178,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
function self.setName(newName)
self.name = newName
Player(self.source).state:set("name", self.name, true)
end
function self.setAccountMoney(accountName, money, reason)
@@ -360,6 +369,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
TriggerEvent('esx:setJob', self.source, self.job, lastJob)
self.triggerEvent('esx:setJob', self.job)
Player(self.source).state:set("job", self.job, true)
else
print(('[es_extended] [^3WARNING^7] Ignoring invalid ^5.setJob()^7 usage for ID: ^5%s^7, Job: ^5%s^7'):format(self.source, job))
end
+15 -17
View File
@@ -62,23 +62,21 @@ end
---@param Properties table
---@param cb function
function ESX.OneSync.SpawnVehicle(model, coords, heading, Properties, cb)
model = type(model) == 'string' and joaat(model) or model
Properties = Properties or {}
local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
CreateThread(function()
local player = nil
for _, playerId in ipairs(GetPlayers()) do
ESX.GetVehicleType(model, playerId, function(Type)
local SpawnedEntity = CreateVehicleServerSetter(model, Type, vector, heading)
Wait(250)
local NetworkId = NetworkGetNetworkIdFromEntity(SpawnedEntity)
Properties.NetId = NetworkId
Entity(SpawnedEntity).state:set('VehicleProperties', Properties, true)
cb(NetworkId)
end)
break
end
end)
model = type(model) == 'string' and joaat(model) or model
Properties = Properties or {}
local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
TriggerClientEvent("esx:requestModel", -1, model)
CreateThread(function()
local xPlayer = ESX.OneSync.GetClosestPlayer(vector, 200)
ESX.GetVehicleType(model, xPlayer.id, function(Type)
local SpawnedEntity = CreateVehicleServerSetter(model, Type, vector, heading)
Wait(250)
local NetworkId = NetworkGetNetworkIdFromEntity(SpawnedEntity)
Properties.NetId = NetworkId
Entity(SpawnedEntity).state:set('VehicleProperties', Properties, true)
cb(NetworkId)
end)
end)
end
+2 -2
View File
@@ -2,13 +2,13 @@
A Core Resource that Allows the player to Pick their characters, Name, Gender, Height and Date-of-birth.
![Preview](https://cdn.discordapp.com/attachments/714118962568364106/997871502798094426/Screenshot_51.png)
![Preview](./preview.png)
# Infomation
## Requirements
[esx_skin](./../esx_skin/README.md)
[esx_skin](./../esx_skin/README.md)
## Commands
+6 -6
View File
@@ -10,12 +10,12 @@ end)
RegisterNetEvent('esx_identity:setPlayerData', function(data)
SetTimeout(1, function()
ESX.SetPlayerData("name", ('%s %s'):format(data.firstName, data.lastName))
ESX.SetPlayerData('firstName', data.firstName)
ESX.SetPlayerData('lastName', data.lastName)
ESX.SetPlayerData('dateofbirth', data.dateOfBirth)
ESX.SetPlayerData('sex', data.sex)
ESX.SetPlayerData('height', data.height)
ESX.SetPlayerData("name", ('%s %s'):format(data.firstName, data.lastName))
ESX.SetPlayerData('firstName', data.firstName)
ESX.SetPlayerData('lastName', data.lastName)
ESX.SetPlayerData('dateofbirth', data.dateOfBirth)
ESX.SetPlayerData('sex', data.sex)
ESX.SetPlayerData('height', data.height)
end)
end)
+1 -3
View File
@@ -1,9 +1,7 @@
ALTER TABLE `users`
ADD COLUMN `firstname` VARCHAR(16) NULL DEFAULT NULL,
ADD COLUMN `lastname` VARCHAR(16) NULL DEFAULT NULL,
ADD COLUMN `dateofbirth` VARCHAR(10) NULL DEFAULT NULL,
ADD COLUMN `sex` VARCHAR(1) NULL DEFAULT NULL,
ADD COLUMN `height` INT NULL DEFAULT NULL
;
;
+5 -4
View File
@@ -6,10 +6,12 @@ description 'ESX Identity'
lua54 'yes'
version '1.8.5'
shared_script '@es_extended/imports.lua'
shared_scripts {
'@es_extended/imports.lua',
'@es_extended/locale.lua',
}
server_scripts {
'@es_extended/locale.lua',
'@oxmysql/lib/MySQL.lua',
'locales/*.lua',
'config.lua',
@@ -17,7 +19,6 @@ server_scripts {
}
client_scripts {
'@es_extended/locale.lua',
'locales/*.lua',
'config.lua',
'client/main.lua'
@@ -31,4 +32,4 @@ files {
'html/css/style.css',
}
dependency 'es_extended'
dependency 'es_extended'
+15 -75
View File
@@ -1,23 +1,24 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="nui://game/ui/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet">
<title>ESX Identity</title>
</head>
<body onkeydown="TriggeredKey(this)">
<div class="dialog">
<div class="title"><b>IDENTITY</b></div>
<!-- <img id="logo" height="110px" width="332px"> > -->
<form id="register" name="register" action="#">
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif";>First Name</div>
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name"><br>
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif";>Last Name</div>
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name"><br>
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif", sans-serif;>Date of Birth (MM/DD/YYYY)</div>
<input id="dateofbirth" type="date" name="dateofbirth" class="" placeholder="Date of Birth (dd/mm/yyyy)" min="01/01/1900" max="01/01/2010" onfocus="(this.type='date')"><br>
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif", sans-serif;>Height</div>
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif">First Name</div>
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name" minlength="3" maxlength="8" pattern="[a-zA-Z]*"><br>
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif">Last Name</div>
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name" minlength="3" maxlength="10" pattern="[a-zA-Z]*"><br>
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif">Date of Birth (MM/DD/YYYY)</div>
<input id="dateofbirth" type="date" name="dateofbirth" class="" min="1900-01-01" max="2010-01-01" onfocus="(this.type='date')"><br>
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif">Height</div>
<input id="height" type="number" class="" name="height" min="120" max="220" placeholder="Height (cm)"><br>
<center>
<div class="radio-toolbar">
@@ -32,74 +33,13 @@
</form>
<center><font size="1px" color="green">If the submit button doesn't work, please ensure that you've entered the fields correctly.</font></center>
</div>
<script>
const allRanges = document.querySelectorAll(".range-wrap");
allRanges.forEach(wrap => {
const range = wrap.querySelector(".range");
const bubble = wrap.querySelector(".bubble");
range.addEventListener("input", () => {
setBubble(range, bubble);
});
setBubble(range, bubble);
});
function setBubble(range, bubble) {
const val = range.value;
const min = range.min ? range.min : 0;
const max = range.max ? range.max : 100;
const newVal = Number(((val - min) * 100) / (max - min));
bubble.innerHTML = 'Height: ' + val;
bubble.style.left = `calc(${newVal}% + (${8 - newVal * 0.15}px))`;
}
var myFirstName = document.getElementById('firstname');
var myLastName = document.getElementById('lastname');
var myDOB = document.getElementById('dateofbirth');
var myHeight = document.getElementById('height');
function isNumber(e) {
var key=e.which || e.KeyCode;
if ( key >=48 && key <= 57) {
return true;
}
else {
return false;
}
}
function checkDOB() {
var date = new Date($('#dateofbirth').val());
day = date.getDate();
month = date.getMonth() + 1;
year = date.getFullYear();
if (isNaN(month) || isNaN(day) || isNaN(year)) {
myDOB.style.backgroundColor = '#E06666';
myDOB.style.color = 'black';
}
else {
var dateInput = [day, month, year].join('/');
var regExp = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var dateArray = dateInput.match(regExp);
if (dateArray == null){
return false;
}
month = dateArray[1];
day= dateArray[3];
year = dateArray[5];
}
}
<script>
function TriggeredKey(e) {
var keycode;
if (window.event) keycode = window.event.keyCode;
if (window.event.keyCode == 13 || window.event.keyCode == 27) return false;
}
</script>
<script src="js/script.js" type="text/javascript"></script>
<script src="js/script.js"></script>
</body>
</html>
+36 -33
View File
@@ -1,35 +1,38 @@
$(function() {
$.post('http://esx_identity/ready', JSON.stringify({}))
$(document).ready(function () {
$.post("http://esx_identity/ready", JSON.stringify({}));
window.addEventListener('message', function(event) {
if (event.data.type === "enableui") {
document.body.style.display = event.data.enable ? "block" : "none"
}
})
window.addEventListener("message", function (event) {
if (event.data.type === "enableui") {
event.data.enable ? $(document.body).show() : $(document.body).hide();
}
});
$("#register").submit(function(event) {
event.preventDefault() // Prevent form from submitting
// Verify date
var date = $("#dateofbirth").val()
var dateCheck = new Date($("#dateofbirth").val())
if (dateCheck == "Invalid Date") {
date == "invalid"
} else {
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(dateCheck)
const mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(dateCheck)
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(dateCheck)
var formattedDate = `${da}/${mo}/${ye}`
$.post('http://esx_identity/register', JSON.stringify({
firstname: $("#firstname").val(),
lastname: $("#lastname").val(),
dateofbirth: formattedDate,
sex: $("input[type='radio'][name='sex']:checked").val(),
height: $("#height").val()
}))
}
})
})
$("#register").submit(function (event) {
event.preventDefault();
const dateCheck = new Date($("#dateofbirth").val());
const year = new Intl.DateTimeFormat("en", { year: "numeric" }).format(
dateCheck
);
const month = new Intl.DateTimeFormat("en", { month: "2-digit" }).format(
dateCheck
);
const day = new Intl.DateTimeFormat("en", { day: "2-digit" }).format(
dateCheck
);
const formattedDate = `${day}/${month}/${year}`;
$.post(
"http://esx_identity/register",
JSON.stringify({
firstname: $("#firstname").val(),
lastname: $("#lastname").val(),
dateofbirth: formattedDate,
sex: $("input[type='radio'][name='sex']:checked").val(),
height: $("#height").val(),
})
);
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 943 KiB

+33 -33
View File
@@ -2,6 +2,20 @@ local playerIdentity = {}
local alreadyRegistered = {}
local multichar = ESX.GetConfig().Multichar
local function deleteIdentityFromDatabase(xPlayer)
MySQL.query.await(
'UPDATE users SET firstname = ?, lastname = ?, dateofbirth = ?, sex = ?, height = ?, skin = ? WHERE identifier = ?',
{nil, nil, nil, nil, nil, nil, xPlayer.identifier})
if Config.FullCharDelete then
MySQL.update.await('UPDATE addon_account_data SET money = 0 WHERE account_name IN (?) AND owner = ?',
{{'bank_savings', 'caution'}, xPlayer.identifier})
MySQL.prepare.await('UPDATE datastore_data SET data = ? WHERE name IN (?) AND owner = ?',
{'\'{}\'', {'user_ears', 'user_glasses', 'user_helmet', 'user_mask'}, xPlayer.identifier})
end
end
local function deleteIdentity(xPlayer)
if alreadyRegistered[xPlayer.identifier] then
xPlayer.setName(('%s %s'):format(nil, nil))
@@ -20,20 +34,6 @@ local function saveIdentityToDatabase(identifier, identity)
{identity.firstName, identity.lastName, identity.dateOfBirth, identity.sex, identity.height, identifier})
end
local function deleteIdentityFromDatabase(xPlayer)
MySQL.query.await(
'UPDATE users SET firstname = ?, lastname = ?, dateofbirth = ?, sex = ?, height = ?, skin = ? WHERE identifier = ?',
{nil, nil, nil, nil, nil, nil, xPlayer.identifier})
if Config.FullCharDelete then
MySQL.update.await('UPDATE addon_account_data SET money = 0 WHERE account_name IN (?) AND owner = ?',
{{'bank_savings', 'caution'}, xPlayer.identifier})
MySQL.prepare.await('UPDATE datastore_data SET data = ? WHERE name IN (?) AND owner = ?',
{'\'{}\'', {'user_ears', 'user_glasses', 'user_helmet', 'user_mask'}, xPlayer.identifier})
end
end
local function checkDate(str)
if string.match(str, '(%d%d)/(%d%d)/(%d%d%d%d)') ~= nil then
local d, m, y = string.match(str, '(%d+)/(%d+)/(%d+)')
@@ -293,6 +293,25 @@ if Config.UseDeferrals then
end
end)
else
local function setIdentity(xPlayer)
if alreadyRegistered[xPlayer.identifier] then
local currentIdentity = playerIdentity[xPlayer.identifier]
xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName))
xPlayer.set('firstName', currentIdentity.firstName)
xPlayer.set('lastName', currentIdentity.lastName)
xPlayer.set('dateofbirth', currentIdentity.dateOfBirth)
xPlayer.set('sex', currentIdentity.sex)
xPlayer.set('height', currentIdentity.height)
TriggerClientEvent('esx_identity:setPlayerData', xPlayer.source, currentIdentity)
if currentIdentity.saveToDatabase then
saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
end
playerIdentity[xPlayer.identifier] = nil
end
end
local function checkIdentity(xPlayer)
MySQL.single('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = ?',
{xPlayer.identifier}, function(result)
@@ -319,25 +338,6 @@ else
end)
end
local function setIdentity(xPlayer)
if alreadyRegistered[xPlayer.identifier] then
local currentIdentity = playerIdentity[xPlayer.identifier]
xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName))
xPlayer.set('firstName', currentIdentity.firstName)
xPlayer.set('lastName', currentIdentity.lastName)
xPlayer.set('dateofbirth', currentIdentity.dateOfBirth)
xPlayer.set('sex', currentIdentity.sex)
xPlayer.set('height', currentIdentity.height)
TriggerClientEvent('esx_identity:setPlayerData', xPlayer.source, currentIdentity)
if currentIdentity.saveToDatabase then
saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
end
playerIdentity[xPlayer.identifier] = nil
end
end
if not multichar then
AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
deferrals.defer()
+10 -5
View File
@@ -1,16 +1,21 @@
Debug = ESX.GetConfig().EnableDebug
---@param message any
---@param type string
local IsShowing = false
---@param message string
---@param Type string
local function TextUI(message, type)
IsShowing = true
SendNUIMessage({
action = 'show',
message = message or 'ESX-TextUI',
type = type or 'info'
message = message and message or 'ESX-TextUI',
type = type == 0 and "info" or type
})
end
local function HideUI()
if not IsShowing then
return
end
IsShowing = false
SendNUIMessage({
action = 'hide'
})
+1 -1
View File
@@ -1,5 +1,5 @@
Locales['en'] = {
['allowlist_check'] = 'Checking you are Allowlisted.',
['allowlist_check'] = 'Checking if you are Allowlisted.',
['not_allowlisted'] = 'You Must be Allowlisted to join this server!',
['allowlist_empty'] = 'There Are no allowlists saved for this server.',
['license_missing'] = 'Error: Your Identifier is missing!',
+5 -5
View File
@@ -1,8 +1,8 @@
Locales['hu'] = {
['allowlist_check'] = 'Ellenőrzi, hogy fent vagy-e az engedélyezett listára.',
['allowlist_check'] = 'Ellenőrizzük fent vagy-e a menők listáján.',
['not_allowlisted'] = 'Engedélyezettnek kell lenned ahhoz, hogy csatlakozz ehhez a szerverhez!',
['allowlist_empty'] = 'Ehhez a szerverhez nincsenek mentett engedélyezési listák.',
['license_missing'] = 'Hiba: Te Identifier-ed hiányzik!',
['help_allowlist_add'] = 'jétékos felvéltele a allowlist-re',
['help_allowlist_load'] = 'allowlist újratöltése',
['allowlist_empty'] = 'Ehhez a szerverhez nincsenek mentett engedélyezési lista.',
['license_missing'] = 'Hiba: Te azonosítód hiányzik!',
['help_allowlist_add'] = 'játékos felvétele az engedélyezettek listájára',
['help_allowlist_load'] = 'engedélyezési lista újratöltése',
}
+11
View File
@@ -29,6 +29,17 @@ ensure esx_banking
Run the banking.sql into your database. Done.
```
# If you want to create a bank log in another script, you can do it this way! Only server side!
```
exports["esx_banking"]:logTransaction(source,logType,amount)
- First param: source - player source
- Second param: logType - WITHDRAW,DEPOSIT,TRANSFER_RECEIVE you can only use these log types!
- Third param: amount - The amount to be logged
For example: exports["esx_banking"]:logTransaction(source,"WITHDRAW",200)
```
# Legal
### License
esx_banking - banking script for ESX
+24 -76
View File
@@ -1,9 +1,10 @@
local PlayerData, ActivateBlips, Peds = {}, {}, {}
local ActivateBlips = {}
local PlayerLoaded = true
local isInMarker, isInAtmMarker, isInMenu, isMarkerShowed = false, false, false, false
local _GetEntityCoords, _PlayerPedId
-- Functions
-- Listen for keypress while player inside the marker
local function Listen4Key()
CreateThread(function()
@@ -46,57 +47,6 @@ local function RemoveBlips()
ActivateBlips = {}
end
-- Ped Handler
local function PedHandler(ids)
local tmpPeds = {}
for _, id in pairs(ids) do
if not Peds[id] then
if not HasModelLoaded(Config.Peds[id].Model) then
RequestModel(Config.Peds[id].Model)
Wait(100)
while not HasModelLoaded(Config.Peds[id].Model) do
Wait(10)
end
end
local npc = CreatePed(6, Config.Peds[id].Model, Config.Peds[id].Position + vector4(0, 0, -1, 0), false,
false)
TaskStartScenarioInPlace(npc, Config.Peds[id].Scenario, 0, true)
SetEntityInvincible(npc, true)
SetEntityProofs(npc, true, true, true, true, true, true, 1, true)
SetBlockingOfNonTemporaryEvents(npc, true)
FreezeEntityPosition(npc, true)
SetPedDiesWhenInjured(npc, false)
SetEntityCanBeDamaged(npc, false)
SetPedCanRagdollFromPlayerImpact(npc, false)
SetPedCanRagdoll(npc, false)
SetEntityAsMissionEntity(npc, true, true)
SetEntityDynamic(npc, false)
Peds[id] = npc
end
end
for id, handle in pairs(Peds) do
local del = true
for i = 1, #ids do
if ids[i] == id then
del = false
tmpPeds[id] = handle
end
end
if del then
DeletePed(handle)
end
end
Peds = tmpPeds
end
function OpenUi(atm)
atm = atm or false
isInMenu = true
@@ -129,7 +79,7 @@ function OpenUi(atm)
end
local function CloseUi()
SetNuiFocus(false)
SetNuiFocus(false, false)
isInMenu = false
SendNUIMessage({
showMenu = false
@@ -144,8 +94,7 @@ end
local function ShowMarker(coord)
CreateThread(function()
while isMarkerShowed do
DrawMarker(20, coord.x, coord.y, coord.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.2, 0.2, 187, 255, 0, 255,
false, true, 2, nil, nil, false)
DrawMarker(20, coord.x, coord.y, coord.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.2, 0.2, 187, 255, 0, 255, false, true, 2, false, nil, nil, false)
Wait(0)
end
end)
@@ -159,19 +108,6 @@ local function StartThread()
_PlayerPedId = PlayerPedId()
_GetEntityCoords = GetEntityCoords(_PlayerPedId)
if Config.EnablePeds then
local closestPed = {}
for i = 1, #Config.Peds do
local distance = #(_GetEntityCoords - Config.Peds[i].Position.xyz)
if distance <= Config.DrawMarker then
closestPed[#closestPed + 1] = i
end
end
PedHandler(closestPed)
end
if IsPedOnFoot(PlayerPedId()) then
local closestBank = {}
@@ -261,6 +197,21 @@ RegisterNetEvent('esx_banking:closebanking', function()
CloseUi()
end)
RegisterNetEvent('esx_banking:PedHandler', function(netIdTable)
local npc
for i = 1, #netIdTable do
npc = NetworkGetEntityFromNetworkId(netIdTable[i])
TaskStartScenarioInPlace(npc, Config.Peds[i].Scenario, 0, true)
SetEntityProofs(npc, true, true, true, true, true, true, true, true)
SetBlockingOfNonTemporaryEvents(npc, true)
FreezeEntityPosition(npc, true)
SetPedCanRagdollFromPlayerImpact(npc, false)
SetPedCanRagdoll(npc, false)
SetEntityAsMissionEntity(npc, true, true)
SetEntityDynamic(npc, false)
end
end)
RegisterNetEvent('esx_banking:updateMoneyInUI')
AddEventHandler('esx_banking:updateMoneyInUI', function(doingType, bankMoney, money)
SendNUIMessage({
@@ -275,23 +226,20 @@ end)
-- Resource starting
AddEventHandler('onResourceStart', function(resource)
if resource ~= GetCurrentResourceName() then
return
end
if resource ~= GetCurrentResourceName() then return end
StartThread()
end)
-- Enables it on player loaded
RegisterNetEvent('esx:playerLoaded', function()
StartThread()
end)
end)
-- Resource stopping
AddEventHandler('onResourceStop', function(resource)
if resource ~= GetCurrentResourceName() then
return
end
if resource ~= GetCurrentResourceName() then return end
RemoveBlips()
if isInMenu then
CloseUi()
end
end)
end)
+2 -2
View File
@@ -1,8 +1,8 @@
Config = {
Debug = false,
DrawMarker = 10,
Locale = 'en',
EnablePeds = true,
Locale = GetConvar('esx:locale', 'en'),
EnablePeds = true,
AtmModels = {`prop_fleeca_atm`, `prop_atm_01`, `prop_atm_02`, `prop_atm_03`},
Banks = {
{
+1 -1
View File
@@ -4,7 +4,7 @@ game 'gta5'
description 'ESX banking'
lua54 'yes'
version '1.8.5'
version '1.8.6'
shared_scripts {
'@es_extended/imports.lua',
+3 -3
View File
@@ -268,8 +268,8 @@
"LAUNGAGE": {
"your_money_title":"saldo",
"your_money_desc":"qui puoi vedere il saldo attuale e contanti.",
"your_money_cash":"i tuoi soldi",
"your_money_bank":"il tuo saldo bancario",
"your_money_cash_label":"i tuoi soldi",
"your_money_bank_label":"il tuo saldo bancario",
"withdraw":"RITIRARE",
"deposit":"DEPOSITARE",
"transfer":"TRASFERIMENTO",
@@ -289,7 +289,7 @@
"timeLabel":"tempo",
"searchInputPlaceholder":"Cerca ...",
"_comment": "tabella Opzioni complete della lingua: inglese, ungherese, italiana puoi trovare qui tutte le lingue: https://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/",
"tableFullLanguage":"Italiano"
"tableFullLanguage":"Italian"
}
}
}
@@ -758,6 +758,7 @@ $(document).ready(function(){
if(data.openATM){
ATMRender()
type = "ATM"
transaction.setData(transData,languageText)
}
else{
type = "BANK"
+71 -15
View File
@@ -1,3 +1,5 @@
local spawnedPeds, netIdTable = {}, {}
-- get keys utils
local function get_key(t)
local key
@@ -9,28 +11,34 @@ end
-- Resource starting
AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
if (GetCurrentResourceName() ~= resourceName) then return end
if Config.EnablePeds then BANK.CreatePeds() end
local twoMonthMs = (os.time() - 5259487) * 1000
MySQL.Sync.fetchScalar('DELETE FROM banking WHERE time < ? ', {twoMonthMs})
end)
AddEventHandler('onResourceStop', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then return end
if Config.EnablePeds then BANK.DeletePeds() end
end)
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
if not Config.EnablePeds then return end
TriggerClientEvent('esx_banking:PedHandler', playerId, netIdTable)
end)
-- event
RegisterServerEvent('esx_banking:doingType')
AddEventHandler('esx_banking:doingType', function(typeData)
if source == nil then
return
end
if (typeData == nil) then
return
end
if source == nil then return end
if (typeData == nil) then return end
local source = source
local xPlayer = ESX.GetPlayerFromId(source)
local identifier = xPlayer.getIdentifier()
local money = xPlayer.getAccount('money').money
local bankMoney = xPlayer.getAccount('bank').money
local amount
local key = get_key(typeData)
if typeData.deposit then
@@ -43,9 +51,7 @@ AddEventHandler('esx_banking:doingType', function(typeData)
amount = tonumber(typeData.pincode)
end
if not tonumber(amount) then
return
end
if not tonumber(amount) then return end
amount = ESX.Math.Round(amount)
if amount == nil or (not typeData.pincode and amount <= 0) then
@@ -114,8 +120,58 @@ ESX.RegisterServerCallback("esx_banking:checkPincode", function(source, cb, inpu
cb(pincode > 0)
end)
function logTransaction(targetSource,key,amount)
if targetSource == nil then
print("ERROR: TargetSource nil!")
return
end
if key == nil then
print("ERROR: Do you need use these: WITHDRAW,DEPOSIT,TRANSFER_RECEIVE")
return
end
if type(key) ~= "string" or key == '' then
print("ERROR: Do you need use these: WITHDRAW,DEPOSIT,TRANSFER_RECEIVE and can only be string type!")
return
end
if amount == nil then
print("ERROR: Amount value is nil! Add some numeric value to the amount!")
return
end
local xPlayer = ESX.GetPlayerFromId(tonumber(targetSource))
if xPlayer ~= nil then
local bankCurrentMoney = xPlayer.getAccount('bank').money
BANK.LogTransaction(targetSource, string.upper(key), amount, bankCurrentMoney)
else
print("ERROR: xPlayer is nil!")
end
end
exports("logTransaction", logTransaction)
-- bank functions
BANK = {
CreatePeds = function()
for i = 1, #Config.Peds do
local model = Config.Peds[i].Model
local coords = Config.Peds[i].Position
spawnedPeds[i] = CreatePed(0, model, coords.x, coords.y, coords.z, coords.w, true, true)
netIdTable[i] = NetworkGetNetworkIdFromEntity(spawnedPeds[i])
while not DoesEntityExist(spawnedPeds[i]) do Wait(50) end
end
Wait(100)
TriggerClientEvent('esx_banking:PedHandler', -1, netIdTable)
end,
DeletePeds = function()
for i = 1, #spawnedPeds do
DeleteEntity(spawnedPeds[i])
spawnedPeds[i] = nil
end
end,
Withdraw = function(amount, xPlayer)
xPlayer.addAccountMoney('money', amount)
xPlayer.removeAccountMoney('bank', amount)
@@ -132,7 +188,7 @@ BANK = {
xPlayer.removeAccountMoney('bank', amount)
xTarget.addAccountMoney('bank', amount)
bankMoney = xTarget.getAccount('bank').money
local bankMoney = xTarget.getAccount('bank').money
BANK.LogTransaction(xTarget.source, "TRANSFER_RECEIVE", amount, bankMoney)
TriggerClientEvent("esx:showNotification", xTarget.source, TranslateCap('receive_transfer', amount, xPlayer.source),
"success")
@@ -143,7 +199,7 @@ BANK = {
MySQL.update('UPDATE users SET pincode = ? WHERE identifier = ? ', {amount, identifier})
end,
LogTransaction = function(playerId, logType, amount, bankMoney)
if source == nil then
if playerId == nil then
return
end
local xPlayer = ESX.GetPlayerFromId(playerId)
@@ -151,5 +207,5 @@ BANK = {
MySQL.insert('INSERT INTO banking (identifier, type, amount, time, balance) VALUES (?, ?, ?, ?, ?)',
{identifier, logType, amount, os.time() * 1000, bankMoney})
end
end
}
+9 -1
View File
@@ -14,6 +14,12 @@ ESX.RegisterServerCallback('esx_joblisting:getJobsList', function(source, cb)
cb(jobs)
end)
function IsJobAvailable(job)
local jobs = ESX.GetJobs()
local JobToCheck = jobs[job]
return not JobToCheck.whitelisted
end
function IsNearCentre(player)
local Ped = GetPlayerPed(player)
local PedCoords = GetEntityCoords(Ped)
@@ -37,11 +43,13 @@ AddEventHandler('esx_joblisting:setJob', function(job)
local xPlayer = ESX.GetPlayerFromId(source)
local jobs = getJobs()
if xPlayer and IsNearCentre(source) then
if xPlayer and IsNearCentre(source) and IsJobAvailable(job) then
if ESX.DoesJobExist(job, 0) then
xPlayer.setJob(job, 0)
else
print("[^1ERROR^7] Tried Setting User ^5".. source .. "^7 To Invalid Job - ^5"..job .."^7!")
end
else
print("[^3WARNING^7] User ^5".. source .. "^7 Attempted to Exploit ^5`esx_joblisting:setJob`^7!")
end
end)
+1 -1
View File
@@ -79,7 +79,7 @@ AddEventHandler('esx_lscustom:refreshOwnedVehicle', function(vehicleProps)
local vehicle = json.decode(result.vehicle)
if vehicleProps.model == vehicle.model then
MySQL.update('UPDATE owned_vehicles SET vehicle = ? WHERE plate = ?', {json.encode(vehicleProps), vehicleProps.plate})
Customs[tostring(source)][tostring(vehicleProps.plate)].props = props
Customs[tostring(source)][tostring(vehicleProps.plate)].props = vehicleProps
else
print(('[^3WARNING^7] Player ^5%s^7 Attempted To upgrade with mismatching vehicle model'):format(xPlayer.source))
end
+1 -1
View File
@@ -5,7 +5,7 @@ Locales['en'] = {
["rot_left_right"] = "Left/Right",
["rot_up_down"] = "Up/Down",
["zoom"] = "Zoom In/Out",
["zoom_level"] = "Zoom Level: %s %",
["zoom_level"] = "Zoom Level: %s %%",
["night_vision"] = "Toggle Night Vision",
["clipboard"] = "Link Copied To ~b~Cipboard",
["picture_taken"] = "Picture Taken!",