|
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
local invaderlist = {}
RegisterNetEvent('lifeinvader:instert')
AddEventHandler('lifeinvader:instert', function(text)
local xPlayer = ESX.GetPlayerFromId(_source)
table.insert(invaderlist, {name = GetPlayerName(_source), text = text })
end)
ESX.RegisterServerCallback('delion_tablet:getstarted', function(src, cb)
local xPlayer = ESX.GetPlayerFromId(src)
local xInfo = {}
local vehicles = 0
local properties = 0
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @identifier', {['@identifier'] = xPlayer.identifier}, function(result1)
for i,k in pairs(result1) do
vehicles = vehicles + 1
end
xInfo.vehicles = vehicles
MySQL.Async.fetchAll('SELECT * FROM owned_properties WHERE owner = @identifier', {['@identifier'] = xPlayer.identifier}, function(result2)
for i,k in pairs(result2) do
properties = properties + 1
end
xInfo.properties = properties
MySQL.Async.fetchAll("SELECT firstname, lastname FROM users WHERE identifier = @identifier", { ["@identifier"] = xPlayer.identifier }, function(result)
xInfo.fullname = result[1].firstname .. ' ' .. result[1].lastname
cb(xInfo, serveritems)
end)
end)
end)
end)
ESX.RegisterServerCallback('del_tablet:loadImmos', function(source, cb)
local ownedImmos = {}
local s = source
local x = ESX.GetPlayerFromId(s)
MySQL.Async.fetchAll('SELECT * FROM owned_properties WHERE `owner` = @owner', {['@owner'] = x.identifier}, function(properties)
for _,v in pairs(properties) do
table.insert(ownedImmos, {name = v.name, rented = v.rented, price = v.price})
end
cb(ownedImmos)
end)
end)
ESX.RegisterServerCallback('delion_tablet:loadVehicles', function(source, cb)
local ownedCars = {}
local s = source
local x = ESX.GetPlayerFromId(s)
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE `owner` = @owner', {['@owner'] = x.identifier}, function(vehicles)
for _,v in pairs(vehicles) do
local vehicle = json.decode(v.vehicle)
table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate})
end
cb(ownedCars)
end)
end)
ESX.RegisterServerCallback('delion_tablet:loadUsers', function(source, cb)
local userlist = {}
local s = source
local x = ESX.GetPlayerFromId(s)
MySQL.Async.fetchAll('SELECT * FROM users WHERE `identifier` = @identifier', {['@identifier'] = x.identifier}, function(result)
table.insert(userlist, {bank = result[1].bank, firstname = result[1].firstname, lastname = result[1].lastname, job = result[1].job, job_grade = result[1].job_grade, phone_number = result[1].phone_number})
end)
Citizen.Wait(1000)
cb(userlist)
end)
ESX.RegisterServerCallback('delion_tablet:invadermessages',function(source,cb)
if invaderlist ~= nil then
cb(invaderlist)
end
end)
ESX.RegisterServerCallback('delion_tablet:getItemAmount', function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
local qtty = xPlayer.getInventoryItem(item).count
cb(qtty)
end)
RegisterServerEvent('bank:transfer')
AddEventHandler('bank:transfer', function(to, amountt)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local zPlayer = ESX.GetPlayerFromId(to)
local balance = 0
if zPlayer ~= nil and GetPlayerEndpoint(to) ~= nil then
balance = xPlayer.getAccount('bank').money
zbalance = zPlayer.getAccount('bank').money
if tonumber(_source) == tonumber(to) then
TriggerClientEvent(Config.notificationstrigger, _source, Config.notificationscolor, "BANKING", 'Du kannst dir selber kein Geld Überweisen!')
else
if balance <= 0 or balance < tonumber(amountt) or tonumber(amountt) <=
0 then
TriggerClientEvent('notifications', _source, "red", "BANKING", 'Du hast zu wenig Geld!')
else
xPlayer.removeAccountMoney('bank', tonumber(amountt))
zPlayer.addAccountMoney('bank', tonumber(amountt))
TriggerClientEvent(Config.notificationstrigger, _source, Config.notificationscolor, "BANKING", 'Du überwest ' ..amountt.. '$ zur ID:' ..to.. '' )
TriggerClientEvent(Config.notificationstrigger, to, Config.notificationscolor, "BANKING", 'Du bekommst ' ..amountt.. '$ von ' .._source.. '' )
end
end
end
end)
|
|