安装 Steam
登录
|
语言
繁體中文(繁体中文)
日本語(日语)
한국어(韩语)
ไทย(泰语)
български(保加利亚语)
Čeština(捷克语)
Dansk(丹麦语)
Deutsch(德语)
English(英语)
Español-España(西班牙语 - 西班牙)
Español - Latinoamérica(西班牙语 - 拉丁美洲)
Ελληνικά(希腊语)
Français(法语)
Italiano(意大利语)
Bahasa Indonesia(印度尼西亚语)
Magyar(匈牙利语)
Nederlands(荷兰语)
Norsk(挪威语)
Polski(波兰语)
Português(葡萄牙语 - 葡萄牙)
Português-Brasil(葡萄牙语 - 巴西)
Română(罗马尼亚语)
Русский(俄语)
Suomi(芬兰语)
Svenska(瑞典语)
Türkçe(土耳其语)
Tiếng Việt(越南语)
Українська(乌克兰语)
报告翻译问题








-- File: media/lua/client/BTSE_PayAtPump.lua
-- Check first: only run if BTSE_Economy mod is installed
if not getActivatedMods():contains("BTSE_Economy") then return end
-- Main module
BTSE_PayAtPump = {}
-- ==================================================================
-- PRICE CONFIGURATION SECTION (change the numbers below for non-coders)
BTSE_PayAtPump.PRICE_PETROL = 1.20
BTSE_PayAtPump.PRICE_DIESEL = 0.90
BTSE_PayAtPump.PRICE_LPG = 0.60
-- ==================================================================
-- 1) initPurchaseFuel: setup when starting fuel purchase
local function initPurchaseFuel(self)
local tex = self.fuelStation:getTextureName()
self.isFuelPump = tex:find("fossoil") or tex:find("gas2go")
self.prevFuel = 0
self.deltaFuel = 0
return self
end
-- 2) getPricePerLitre: retrieve price from configuration section
local function getPricePerLitre(self)
if self.fuelType == "Diesel" then return BTSE_PayAtPump.PRICE_DIESEL
elseif self.fuelType == "LPG" then return BTSE_PayAtPump.PRICE_LPG
else return BTSE_PayAtPump.PRICE_PETROL
end
end
-- 3) roundMoney: round to 2 decimal places for cents
local function roundMoney(amount)
return math.floor(amount * 100 + 0.5) / 100
end
-- 4) payForFuel: send server command to deduct BTSE balance
local function payForFuel(self)
if not self.isFuelPump then return end
local cost = roundMoney(self.deltaFuel * getPricePerLitre(self))
if cost <= 0 then return end
-- Send command to server BTSE_Economy to deduct balance
-- args: { amount = cost }
sendClientCommand("btse_economy", "deductMoney", { amount = cost })
end
-- 5) updateFuelPurchase: called repeatedly during the fueling action
local function updateFuelPurchase(self, startAmt, targetAmt)
if not self.isFuelPump then return end
local currentFuel = targetAmt
and (targetAmt - startAmt) * self:getJobDelta()
or startAmt
self.deltaFuel = currentFuel - self.prevFuel
self.prevFuel = currentFuel
payForFuel(self)
end
-- 6) handleEmergencyStop: handle abrupt stop, charge for any remaining fuel
local function handleEmergencyStop(self)
payForFuel(self)
end
-- 7) Override for vehicle refueling
require "Vehicles/TimedActions/ISRefuelFromGasPump"
local origNew = ISRefuelFromGasPump.new
local origUpd = ISRefuelFromGasPump.update
local origStop = ISRefuelFromGasPump.stop
function ISRefuelFromGasPump:new(character, part, fuelStation, time)
local action = origNew(self, character, part, fuelStation, time)
initPurchaseFuel(action)
return action
end
function ISRefuelFromGasPump:update()
origUpd(self)
updateFuelPurchase(self, self.tankStart, self.tankTarget)
end
function ISRefuelFromGasPump:stop()
handleEmergencyStop(self)
origStop(self)
end
-- 8) Override for jerry can filling
require "TimedActions/ISTakeFuel"
local origNew2 = ISTakeFuel.new
local origUpd2 = ISTakeFuel.update
local origStop2 = ISTakeFuel.stop
function ISTakeFuel:new(character, fuelStation, petrolCan, time)
local action = origNew2(self, character, fuelStation, petrolCan, time)
initPurchaseFuel(action)
return action
end
function ISTakeFuel:update()
origUpd2(self)
updateFuelPurchase(self, self.itemStart, self.itemTarget)
end
function ISTakeFuel:stop()
handleEmergencyStop(self)
origStop2(self)
end
-- File: media/lua/server/BTSE_PayAtPump_Server.lua
-- Ensure server handles deductMoney command
BTSE.Commands.Economy.deductMoney = function(playerObj, args)
local cost = args.amount or 0
-- Subtract the player's balance on the BTSE server data
local success = BTSE.Data:subtractBalance(playerObj, cost)
if not success then
-- If it fails (insufficient funds), send a failure message back to client
sendClientCommand(playerObj, "btse_economy", "transactionFailed", { reason = "Insufficient funds" })
end
end
-- Notes:
-- 1) Place client file under media/lua/client, server file under media/lua/server.
-- 2) For non-coders: to change fuel prices, update variables in the PRICE CONFIGURATION SECTION.