forked from Simnation/Main
34 lines
1,010 B
Lua
34 lines
1,010 B
Lua
![]() |
local QBCore = exports['qb-core']:GetCoreObject()
|
||
|
|
||
|
-- Geld prüfen
|
||
|
QBCore.Functions.CreateCallback('train:server:canAfford', function(source, cb, price)
|
||
|
local Player = QBCore.Functions.GetPlayer(source)
|
||
|
if Player then
|
||
|
local money = Player.PlayerData.money[Config.DefaultCurrency]
|
||
|
if money >= price then
|
||
|
Player.Functions.RemoveMoney(Config.DefaultCurrency, price)
|
||
|
cb(true)
|
||
|
else
|
||
|
cb(false)
|
||
|
end
|
||
|
else
|
||
|
cb(false)
|
||
|
end
|
||
|
end)
|
||
|
|
||
|
-- Journey Log
|
||
|
RegisterNetEvent('train:server:logJourney', function(from, to, price)
|
||
|
if not Config.DebugOptions.logJourneys then return end
|
||
|
|
||
|
local src = source
|
||
|
local Player = QBCore.Functions.GetPlayer(src)
|
||
|
|
||
|
if Player then
|
||
|
print(string.format("[TRAIN] %s (%s) - %s → %s ($%d)",
|
||
|
Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname,
|
||
|
Player.PlayerData.citizenid,
|
||
|
from, to, price
|
||
|
))
|
||
|
end
|
||
|
end)
|