Skip to content

Commit

Permalink
Fixed Transfer
Browse files Browse the repository at this point in the history
Now uses ID
  • Loading branch information
Tazi0 committed Jun 9, 2019
1 parent 87a455f commit d1b3a20
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion new_banking/client/html/UI.html
Expand Up @@ -150,7 +150,7 @@
</div>
<div class="input-cont box-shadow">
<label>Who would you like to transfer to?</label>
<input id="to" type="text" placeholder="Last and first name">
<input id="to" type="text" placeholder="ID">
</div>
</div>
<button class="btn btn-green" type="submit">
Expand Down
29 changes: 17 additions & 12 deletions new_banking/server.lua
Expand Up @@ -49,21 +49,26 @@ AddEventHandler('bank:transfer', function(to, amountt)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local zPlayer = ESX.GetPlayerFromId(to)
local balance = 0
balance = xPlayer.getAccount('bank').money
zbalance = zPlayer.getAccount('bank').money

if tonumber(_source) == tonumber(to) then
TriggerClientEvent('chatMessage', _source, "You cannot transfer to your self")
else
if balance <= 0 or balance < tonumber(amountt) or tonumber(amountt) <= 0 then
TriggerClientEvent('chatMessage', _source, "You don't have enough money in the bank.")
--Thanks to (LuCampbell)
TriggerEvent('es:getPlayerFromId', xPlayer, function(user)
if (tonumber(user.money) >= tonumber(amountt)) then
local player = user.identifier
user:removeMoney((amountt))

TriggerEvent('es:getPlayerFromId', zPlayer, function(user2)
local player2 = user2.identifier
user2:addMoney((amountt))
TriggerClientEvent("chatMessage", zPlayer , "You received money ", { 52, 201, 36 }, "You received the sum of "..amountt.." dollars")
TriggerClientEvent("chatMessage", xPlayer, "Payment receipt ", { 255, 0, 0 }, "Your payment of "..amountt.." dollars is done")
end)
else
xPlayer.removeAccountMoney('bank', amountt)
zPlayer.addAccountMoney('bank', amountt)
if (tonumber(user.money) < tonumber(amountt)) then

TriggerClientEvent("chatMessage", player, "", { 255, 0, 0 }, "You do not have enough money")
end
end

end
end)
end)


Expand Down

0 comments on commit d1b3a20

Please sign in to comment.