Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ESX.RegisterServerCallback(‘Hideout_VehFinance:PlayerLogin’, function(source,cb)
- local xPlayer = ESX.GetPlayerFromId(source)
- local tick = 0
- while not xPlayer and tick < 100 do
- Citizen.Wait(0)
- tick = tick + 1
- local xPlayer = ESX.GetPlayerFromId(source)
- end
- local data = MySQL.Sync.fetchAll('SELECT * FROM owned_vehicles WHERE owner=@owner',{['@owner'] = xPlayer.getIdentifier()})
- if not data or not data[1] then return; end
- local cbData = false
- for k,v in pairs(data) do
- if v.finance > 0 and v.financetimer <= 0 then
- if not cbData then cbData = {}; end
- table.insert(cbData, v)
- end
- end
- cb(cbData)
- end)
- AddEventHandler(“playerConnecting”, function()
- local src = source
- local identifiers, steamIdentifier = GetPlayerIdentifiers(source)
- for _, v in pairs(identifiers) do
- if string.find(v, "steam") then
- steamIdentifier = v
- break
- end
- end
- table.insert(JVF.PlayerTable, {sourceID = steamIdentifier, timeJoined = GetGameTimer()})
- end)
- AddEventHandler(‘playerDropped’, function()
- local identifiers, steamIdentifier = GetPlayerIdentifiers(source)
- for _, v in pairs(identifiers) do
- if string.find(v, "steam") then
- steamIdentifier = v
- break
- end
- end
- local timeJoined, ky
- for k,v in pairs(JVF.PlayerTable) do
- if v.sourceID == steamIdentifier then timeJoined = v.timeJoined; ky = k; end
- end
- if not timeJoined then return; end
- local identifier = steamIdentifier
- local data = MySQL.Sync.fetchAll("SELECT * FROM owned_vehicles WHERE owner=@identifier",{['@identifier'] = identifier})
- if not data then return; end
- for k,v in pairs(data) do
- if v.finance and v.finance > 0 then
- MySQL.Sync.execute('UPDATE owned_vehicles SET financetimer=@financetimer WHERE plate=@plate', {['@financetimer'] = math.floor(v.financetimer - (((GetGameTimer() - timeJoined) / 1000) / 60)), ['@plate'] = v.plate} )
- end
- end
- table.remove(JVF.PlayerTable, ky)
- end)
- AddEventHandler(‘onResourceStart’, function()
- local identifiers, steamIdentifier = GetPlayerIdentifiers(source)
- for _, v in pairs(identifiers) do
- if string.find(v, "steam") then
- steamIdentifier = v
- break
- end
- end
- local timeJoined, ky
- for k,v in pairs(JVF.PlayerTable) do
- if v.sourceID == steamIdentifier then timeJoined = v.timeJoined; ky = k; end
- end
- if not timeJoined then return; end
- local identifier = steamIdentifier
- local data = MySQL.Sync.fetchAll("SELECT * FROM owned_vehicles WHERE owner=@identifier",{['@identifier'] = identifier})
- if not data then return; end
- for k,v in pairs(data) do
- if v.finance and v.finance > 0 then
- MySQL.Sync.execute('UPDATE owned_vehicles SET financetimer=@financetimer WHERE plate=@plate', {['@financetimer'] = math.floor(v.financetimer - (((GetGameTimer() - timeJoined) / 1000) / 60)), ['@plate'] = v.plate} )
- end
- end
- table.remove(JVF.PlayerTable, ky)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement