Skip to content

Commit

Permalink
Fixing native money
Browse files Browse the repository at this point in the history
  • Loading branch information
actuallykane committed Jan 4, 2019
1 parent 4d28794 commit fd61518
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
32 changes: 7 additions & 25 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,6 @@ AddEventHandler("playerSpawned", function()
DecorSetInt(PlayerPedId(), k, v)
end

if enableNative[1] then
N_0xc2d15bef167e27bc()
SetPlayerCashChange(1, 0)
Citizen.InvokeNative(0x170F541E1CADD1DE, true)
SetPlayerCashChange(-1, 0)
end

if enableNative[2] then
SetMultiplayerBankCash()
Citizen.InvokeNative(0x170F541E1CADD1DE, true)
SetPlayerCashChange(0, 1)
SetPlayerCashChange(0, -1)
end

TriggerServerEvent('playerSpawn')
end)

Expand All @@ -112,35 +98,31 @@ RegisterNetEvent('es:displayMoney')
AddEventHandler('es:displayMoney', function(a)
enableNative[1] = true

-- Found by FiveM forum user @Lobix300
N_0xc2d15bef167e27bc()
SetPlayerCashChange(1, 0)
Citizen.InvokeNative(0x170F541E1CADD1DE, true)
SetPlayerCashChange(a, 0)
SetMultiplayerHudCash(a, 0)
StatSetInt(GetHashKey("MP0_WALLET_BALANCE"), a)
end)

RegisterNetEvent('es:displayBank')
AddEventHandler('es:displayBank', function(a)
enableNative[2] = true

-- Found by FiveM forum user @Lobix300
SetMultiplayerBankCash()
SetPlayerCashChange(0, 1)
Citizen.InvokeNative(0x170F541E1CADD1DE, true)
SetPlayerCashChange(0, a)
end)

RegisterNetEvent("es:addedMoney")
AddEventHandler("es:addedMoney", function(m, native)
AddEventHandler("es:addedMoney", function(m, native, current)

if not native then
SendNUIMessage({
addcash = true,
money = m
})
else
Citizen.InvokeNative(0x170F541E1CADD1DE, true)
SetPlayerCashChange(math.floor(m), 0)
SetMultiplayerHudCash(current, 0)
StatSetInt(GetHashKey("MP0_WALLET_BALANCE"), current)
end

end)
Expand All @@ -153,8 +135,8 @@ AddEventHandler("es:removedMoney", function(m, native, current)
money = m
})
else
Citizen.InvokeNative(0x170F541E1CADD1DE, true)
SetPlayerCashChange(-math.floor(m), 0)
SetMultiplayerHudCash(current, 0)
StatSetInt(GetHashKey("MP0_WALLET_BALANCE"), current)
end
end)

Expand Down
16 changes: 10 additions & 6 deletions server/classes/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ function CreatePlayer(source, permission_level, money, bank, identifier, license
self.money = m

if((prevMoney - newMoney) < 0)then
TriggerClientEvent("es:addedMoney", self.source, math.abs(prevMoney - newMoney), tonumber(settings.defaultSettings.nativeMoneySystem))
TriggerClientEvent("es:addedMoney", self.source, math.abs(prevMoney - newMoney), (settings.defaultSettings.nativeMoneySystem == "1"))
else
TriggerClientEvent("es:removedMoney", self.source, math.abs(prevMoney - newMoney), tonumber(settings.defaultSettings.nativeMoneySystem))
TriggerClientEvent("es:removedMoney", self.source, math.abs(prevMoney - newMoney), (settings.defaultSettings.nativeMoneySystem == "1"))
end

if settings.defaultSettings.nativeMoneySystem == "0" then
print("setmoney!!!!!!!!!!")
TriggerClientEvent('es:activateMoney', self.source , self.money)
end
else
Expand Down Expand Up @@ -83,8 +84,9 @@ function CreatePlayer(source, permission_level, money, bank, identifier, license

self.money = newMoney

TriggerClientEvent("es:addedMoney", self.source, m, tonumber(settings.defaultSettings.nativeMoneySystem))
TriggerClientEvent("es:addedMoney", self.source, m, (settings.defaultSettings.nativeMoneySystem == "1"), self.money)
if settings.defaultSettings.nativeMoneySystem == "0" then
print("addmoney!!!!!!!!!!")
TriggerClientEvent('es:activateMoney', self.source , self.money)
end
else
Expand All @@ -99,8 +101,9 @@ function CreatePlayer(source, permission_level, money, bank, identifier, license

self.money = newMoney

TriggerClientEvent("es:removedMoney", self.source, m, tonumber(settings.defaultSettings.nativeMoneySystem))
if settings.defaultSettings.nativeMoneySystem ~= "0" then
TriggerClientEvent("es:removedMoney", self.source, m, (settings.defaultSettings.nativeMoneySystem == "1"), self.money)
if settings.defaultSettings.nativeMoneySystem == "0" then
print("removemoney!!!!!!!!!!")
TriggerClientEvent('es:activateMoney', self.source , self.money)
end
else
Expand Down Expand Up @@ -134,11 +137,12 @@ function CreatePlayer(source, permission_level, money, bank, identifier, license
end

rTable.displayMoney = function(m)
if type(m) == "number" then
if type(m) == "number" then
if not self.moneyDisplayed then
if settings.defaultSettings.nativeMoneySystem ~= "0" then
TriggerClientEvent("es:displayMoney", self.source, math.floor(m))
else
print("displaymoney!!!!!!!!!!")
TriggerClientEvent('es:activateMoney', self.source , self.money)
end

Expand Down
2 changes: 1 addition & 1 deletion server/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ settings.defaultSettings = {
['startingBank'] = GetConvar('es_startingBank', '0'),
['enableRankDecorators'] = GetConvar('es_enableRankDecorators', 'false'),
['moneyIcon'] = GetConvar('es_moneyIcon', '$'),
['nativeMoneySystem'] = GetConvar('es_nativeMoneySystem', '0'),
['nativeMoneySystem'] = GetConvar('es_nativeMoneySystem', '1'),
['commandDelimeter'] = GetConvar('es_commandDelimeter', '/'),
['enableLogging'] = GetConvar('es_enableLogging', 'false'),
['enableCustomData'] = GetConvar('es_enableCustomData', 'false')
Expand Down

0 comments on commit fd61518

Please sign in to comment.