Updated the script a bit. After you pickup cash or write in the amount to multiply you can now write "w" to multiply the result with the rate(default 1.8)
The script does NOT count platinums when picked up, write the total amount in the channel instead.
Fixed crash when writing letters without any function in the channel.
Formatted the strings.
Code:
-- Calculation ----------------------------------------------------------------------------------------------------------
rate = 1.8
function multi(f)
Result1 = f * rate -- value for 'Most recent calculation' in the HUD.
win = Result1 -- Storing the calc result to multiply further when the guy playing is winning.
ProcessDebugMessage('Calculator', ''..f..' * '..rate..' = '.. string.format('%.2f', Result1) ..'k') -- The calculation in the channel.
HudUpdate() -- Updating the HUD values.
end
-- Channel
CalculatorChannel = Channel.Open('Calculator', onSpeak, onClose)
function ProcessDebugMessage(speaker, message)
CalculatorChannel:SendOrangeMessage(speaker, message)
end
ProcessDebugMessage('Calculator', 'Type a figure to multiply with '..rate..' ')
ProcessDebugMessage('Calculator', 'Type "w" to continue counting a winning streak')
registerNativeEventListener(EVENT_SELF_CHANNELSPEECH, 'onChannelSpeak')
onChannelSpeak = function(channel, message)
local message = message:lower()
if message == "w" then
if win ~= nil then
ProcessDebugMessage(''..c..' ['..level..']', ''..message..'')
winresult = win * rate
win = win * rate
print(''..winresult..'k')
HudUpdate()
ProcessDebugMessage('Calculator', ''.. string.format('%.2f', winresult) ..'k')
else
ProcessDebugMessage(''..c..' ['..level..']', ''..message..'')
print('There is nothing to multiply with '..rate..'')
ProcessDebugMessage('Calculator', 'There is nothing to multiply with '..rate..'')
end
elseif message ~= string.match(message, '%a+') and message > "0" then
ProcessDebugMessage(''..c..' ['..level..']', ''..message..'')
f = message
multi(f)
elseif message == string.match(message, '%a+') then
ProcessDebugMessage(''..c..' ['..level..']', ''..message..'')
end
end
level = Self.Level()
c = Self.Name()
-- HUD -----------------------------------------------------------------------------------------------------------------
local HUDTitle = HUD.CreateTextDisplay(66, 32, "Most recent calculation", 255, 255, 255)
local HUDData = {}
local data = {}
data.update = ""
data.label = HUD.CreateTextDisplay(66, 46 , data.update, 225, 225, 225)
HUDData = data
function HudUpdate()
local update = string.format('%.2f', win)
HUDData.label:SetText(update)
end
-- Auto-Calculation ----------------------------------------------------------------------------------------------------
oldValue = 0
start = 0
Module.New('MoneyCounter', function(mod)
if start == 0 then
oldValue = Self.ItemCount(3043)
start = 1
end
newValue = Self.ItemCount(3043)
if oldValue ~= newValue then
count = newValue - oldValue
if not (newValue < oldValue) then
Result2 = ''.. count * rate * 10 ..'k'
win = count * rate * 10
print(''..Result2..'')
ProcessDebugMessage('Calculator', ''..Result2..'')
HudUpdate()
end
oldValue = Self.ItemCount(3043)
end
mod:Delay(50)
end)
print("Successfully loaded the script.")
2083ee2dceb4e4ba4866a78e5a48a8d7.png