yirvaxmxzaahzjsenjmpmnreymfxcazb
uqkxvuziimvxfqancvjfnvrdqx
local Framework = require('server.utils')vbftupmfytkfxivmgiwoeczlzibvxggshmmbbzh
local resourceName = GetCurrentResourceName()xwblylcbcmljkzoggwxowqbgffhaxenvaohzajac
local CreditScores = {}rpopicsxcggwulpuyemeikap
jdewjhdjwzzjaqaobkqjbfzpaxjazufixj
local function saveCreditScores()bugqdspzyznggvbmackogwwfzfzkmbqnvwe
SaveResourceFile(resourceName, 'credit_scores.json', json.encode(CreditScores), -1)https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
endlxqfneytwtevmkzlrwnhlovvalijmumy
https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
local function loanPaidLoop()https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
local data = MySQL.query.await('SELECT * FROM players_loan WHERE status = 1', {})uqkxvuziimvxfqancvjfnvrdqx
for k, v in pairs(data) dohttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
local loanDetails = json.decode(v.loan_details)https://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P?pwd=hij0
for _, duesdata in pairs(loanDetails.dues) dohttps://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M
if duesdata.paid thenoqpxkbxuvuzjk
if os.time() >= duesdata.time thenimgjfbzebszskvdfybraclnuaiej
local hasRemoved = Framework:RemoveMoneyByIdentifier(v.citizenid, 'bank', tonumber(duesdata.amount),ztvwebhzlokkosimhnidaqb
"banker-loan")dpvwfujztebs
if hasRemoved theneuigcjqfxigfdiutinjzqmmvfzbhukqyfzeiiv
Framework:RemoveMoneyByIdentifierOffline(v.citizenid, tonumber(duesdata.amount))ptyntmuzhwlhywwfstksyjckktygpcfewdsppmoxiafhwcmpv
endhttps://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F?pwd=efg0
if Config.CreditScore.Enable thenhttps://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
HandleScores(v.citizenid, "remove", tonumber(duesdata.amount))elfbnamcausu
endwcndiyjkfdribdbcskuayqu
duesdata.paid = truehttps://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
MySQL.Async.execute('UPDATE players_loan SET status = ? , loan_details = ? WHERE loan_id = ?',https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
https://pan.baidu.com/s/5X6Y7Z8A9B0C1D2E3F4G
{ 3, json.encode(loanDetails), v.loan_id })https://pan.baidu.com/s/4N5O7P8Q9R0S1T2U3V4W
endyayqwamaqaqbvnhyftbwborgazfzvieuj
endhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X
endhttps://pan.baidu.com/s/6P8Q9R0S1T2U3V4W5X6Y
endhttps://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
SetTimeout(Config.LoanIntervals, loanPaidLoop)https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
endroxarsdnisg
https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
AddEventHandler('txAdmin:events:serverShuttingDown', function()avzswgzmrtlxksffiwvssaityotvizuivuasaafrurpejvkrrg
saveCreditScores()jexdchbhsjhdthjmwqggaxhyoepvdylndirfpsnibu
end)https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
xckrxacuwwuffgbdmrd
AddEventHandler('onResourceStart', function(resourceName)哈哈
if (GetCurrentResourceName() ~= resourceName) thenhttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
returnhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
enduyiamespupbssljpmmjjidonjprwhuvctecfivvckxvdjesvqb
if Config.AutomaticDeduction thenkqyiiohtegjmzqkyhcgqmvkhqwfsqzua
Wait(5000)kafsogukjqaxrxrhzj
loanPaidLoop()https://pan.baidu.com/s/3V4W5X6Y7Z8A9B0C1D2E
end --启动扣除贷款付款的循环https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
if Config.PhoneMails.DueReminder then -- 启动循环以在脚本重启时发送贷款还款提醒https://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D?pwd=yza8
local data = MySQL.query.await('SELECT * FROM players_loan WHERE status = 1', {})ihrhmjulcb
for k, v in pairs(data) dohzprbjroyhpqcstjffyhccu
local loanDetails = json.decode(v.loan_details)https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
for _, duesdata in pairs(loanDetails.dues) dojpzejyfxdswambzrngqpjj
if duesdata.paid thenhttps://pan.baidu.com/s/5G6H7I8J9K0L1M2N3O4P
if os.time() >= (duesdata.time - (Config.PhoneMails.Time * 24 * 60 * 60)) and os.time() < duesdata.time thenhttps://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
-- convert dues.time into datehttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
local date = os.date("%d-%m-%Y %H:%M:%S", duesdata.time)ubnvfeihvfmpoakdwriqmfu
local maildata = {yayqwamaqaqbvnhyftbwborgazfzvieuj
sender = "Banker",https://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
subject = "#" .. v.loan_id .. " Loan Payment Reminder",https://pan.baidu.com/s/1K2L3M4N5O7P8Q9R0S1T
message = "You have a loan payment due . Please visit the bank to pay your loan before " ..https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
date .. ". Payment Amount : $" .. duesdata.amount .. ". ",fgeolecufrsrbaggui
}ztvwebhzlokkosimhnidaqb
Framework:SendMail(v.citizenid, maildata)yxsljwmnkodwbepydwhzeohttps://pan.baidu.com/s/5X6Y7Z8A9B0C1D2E3F4G
endildcsksnhootidblgyelciqnm
endhttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U
https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
endtvwtgaqxihknbttfbvjtnimucmfgtlomhlfol
endhttps://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
endqqrqmwkmuyaalu
end)https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
https://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
AddEventHandler('onResourceStop', function(res)deyxtrkyghcgrlvslbfisezheriymlfppemi
if res ~= resourceName then return endlxqfneytwtevmkzlrwnhlovvalijmumy
saveCreditScores()https://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
end)eqxtkradyo
https://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
CreateThread(function()xoflyrbahvn
Wait(100)nlclorurxptktblygatwszhmaiuqer
local scores = json.decode(LoadResourceFile(resourceName, 'credit_scores.json'))vcwhymnfnlmlzrbvvah
if type(scores) == 'table' thenhttps://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
CreditScores = scorespnxloydaqmnbiahtqfusz
elsehttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
SaveResourceFile(resourceName, "credit_scores.json", '[]', -1)https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
CreditScores = {}tvwtgaqxihknbttfbvjtnimucmfgtlomhlfol
endyayqwamaqaqbvnhyftbwborgazfzvieuj
end)kuygqgiupqqkveqbyfawtg
https://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z
function GetScores(cid)lkrfqjgzrgymditmuppyheinrkvhiv
if CreditScores[cid] then return 0 endhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
return CreditScores[cid]zbseskwulcafkjmxxdwrcywhemsr
endykejginvwisfouwozfxiqkguwkcaylnwwsfcatyxb
nyndcuwehkertwmfgwoitutuemzyoekbcyffscka
function HandleScores(cid, operation, amount)ikcshvfgfkilsuztrnproibprfpyvztejwwqsbxxmfieaiy
local score = 0https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
-- Define the scoring rules based on the operationhttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J
local scoringRulesgmoqztzceefpkmuz
if operation == "add" thenhllrxksgldrwodytcxlmlqhqxbzqtfabqlsnvk
scoringRules = Config.CreditScore.Addonhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
elseif operation == "remove" thenkqyiiohtegjmzqkyhcgqmvkhqwfsqzua
scoringRules = Config.CreditScore.Deducthttps://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S
endhttps://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P?pwd=hij0
-- Loop through scoring rules to calculate the scoreifjywfbgusstnoehnziocuvpkvpncfbllkjipkpkd
for k, v in pairs(scoringRules) dokquisuvmorqiatv
local nextKey = next(scoringRules, k) -- Get the next keyagvllesfvjwyzcrewxxxtmdcpgbddbidie
local currentRange = scoringRules[k]https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
if nextKey thenhllrxksgldrwodytcxlmlqhqxbzqtfabqlsnvk
local nextRange = scoringRules[nextKey]https://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
-- Check if 'amount' is within the current rangeucupopwnjqocydoicgvbmdibfepuqrfkuaaiqww
if amount >= currentRange.amount and amount < nextRange.amount thenhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
score = currentRange.scorelkrfqjgzrgymditmuppyheinrkvhiv
break -- Exit the loop since we found the correct rangelwpstpgocwanvy
endprvcjprlyuwluyubbdlgnpzzdhq
elsehttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
-- If there is no next key, it means 'amount' is greater than or equal to the last rangehttps://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
if amount >= currentRange.amount thenswgzaedatmdjpewtxlocanstobickmzcjgcjkfjesmnhrjbo
score = currentRange.scoregcdntaxyzpuvdfhhgfzdwbtpfwhbtbhzdlmhttps://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
break不要乱来哦
endhttps://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
endhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
endhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
-- Update the player's credit scorevbftupmfytkfxivmgiwoeczlzibvxggshmmbbzh
if operation == "add" thenhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N
https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
CreditScores[cid] = (CreditScores[cid] or 0) + scorehttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
elseaernahfelmybthmbhnenmvikiumhihgilywmfcrqopsixekeso
CreditScores[cid] = (CreditScores[cid] or 0) - scorelrzpnucdercib
if CreditScores[cid] < 0 thenhttps://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q
CreditScores[cid] = 0ahinnrtoqxqjxitsmyqnqrpcekcnommptuchmvwcsmmpufhhey
endmuolfxstrrtrkocqigzhfc
endihrhmjulcb
saveCreditScores()nunfqeoowxjzotduicnjgdhanyarxpvljhttps://pan.baidu.com/s/8R0S1T2U3V4W5X6Y7Z8A
endhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
lib.callback.register('loan-system:server:getLoans', function(source)lrzpnucdercib
local data = MySQL.query.await('SELECT * FROM players_loan', {})https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
local returnData = {https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
Pending = {},bcnayqnstpymuzvcyldnwssphyasacybemc
Approved = {},dqzjfswotrapuwwtjkyxvlivckrxkygnogwuy
Rejected = {},https://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
Paid = {},https://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
All = {}scsdqjyihnbrgcdfjezgwynjyvepavfsxywoiuwpiyh
}xgppychbywgarfxxnygifvywljqsxx
for k, v in pairs(data) dohttps://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
if v.status == 0 thenkuygqgiupqqkveqbyfawtg
table.insert(returnData.Pending, v)qzoiljukqwfpymdkijjlsmt
elseif v.status == 1 thenihrhmjulcb
table.insert(returnData.Approved, v)ahzwcmtdcgseaihyqbpkoetpglkcb
elseif v.status == 2 thenlxqfneytwtevmkzlrwnhlovvalijmumy
table.insert(returnData.Rejected, v)vfixfjvvdrohtbnzviavqhmyuvtfyuyuahsgrnbvfqdzr
elseif v.status == 3 thenjgiskmjbhxaqnusnrnmjyounxoigzcpijxbtk
table.insert(returnData.Paid, v)txcyjjpegywbzibhedzsjyta
endhttps://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
table.insert(returnData.All, v)https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
endslyzhdbspqhxhjbvcurypyjputteayqskpsrttki
for _, statusData in pairs(returnData) dohttps://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
for _, loanDetails in pairs(statusData) doedlwahtzwfdqdejdkzenlknxywlzrriwutsub
local loanDetailsDecoded = json.decode(loanDetails.loan_details)dbthbfffabnlulcvkmwscexhyyqfxaaactieznjapxmjio
if loanDetailsDecoded.starttime thenhttps://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P?pwd=hij0
local starttime = os.date("%c", tonumber(loanDetailsDecoded.starttime))lrzpnucdercib
loanDetailsDecoded.convertedstarttime = starttimehttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
endhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
不要乱来哦
if loanDetailsDecoded.endtime thenhttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
local endtime = os.date("%c", tonumber(loanDetailsDecoded.endtime))ildcsksnhootidblgyelciqnm
loanDetailsDecoded.convertedendtime = endtimehttps://pan.baidu.com/s/2L3M4N5O7P8Q9R0S1T2U
https://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
endildcsksnhootidblgyelciqnm
if loanDetailsDecoded.requestedtime thendpvwfujztebs
local requestedtime = os.date("%c", tonumber(loanDetailsDecoded.requestedtime))https://pan.baidu.com/s/4W5X6Y7Z8A9B0C1D2E3F
loanDetailsDecoded.convertedrequestedtime = requestedtimehttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
endhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
if loanDetailsDecoded.dues thenhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
for _, duesdata in pairs(loanDetailsDecoded.dues) dovpatfzivaasmsjm
if duesdata.time thenqqtlwmktbogpnpxepziuxatyjqgjuxhttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
local time = os.date("%c", tonumber(duesdata.time))https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
duesdata.convertedtime = timevojkxkzoqonmnhqxennwpkuhttps://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
endppeirgqnrnmmfdsfrrhgwzhcqzpn
endhttps://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
endaofjrwrjyrivdrjdgozs
loanDetails.loan_details = json.encode(loanDetailsDecoded)https://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B
endvnflqxabukchzunvjn
endhttps://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
return returnDatahjlovvygjzopxeuzljzwdqntyiobvmacvmrrhpyqomflrzlcjl
end)https://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K
https://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L
lib.callback.register('loan-system:server:getMyLoans', function(source)lwpstpgocwanvy
local Player = Framework:GetPlayer(source)https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
local cid = Player.citizenidhttps://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
local data = MySQL.query.await('SELECT * FROM players_loan WHERE citizenid =?', { cid })goyrsjnbtowfxhfsyppathvawlfvpujvjhmbqzcjn
for _, statusData in pairs(data) dohbcildkcdstlyukqdhbqylnwletq
local loanDetailsDecoded = json.decode(statusData.loan_details)nbmhauvbphcsdojvvytmngszxskabwzpxmwxgrzwzbocpyykwrhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
if loanDetailsDecoded.starttime thenhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
local starttime = os.date("%c", tonumber(loanDetailsDecoded.starttime))https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P
loanDetailsDecoded.convertedstarttime = starttimektkebxmpkunxfhxdhjauovszkquz
endhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
if loanDetailsDecoded.endtime thengglgbgugcylsapjsinvtdhooxsg
local endtime = os.date("%c", tonumber(loanDetailsDecoded.endtime))https://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
loanDetailsDecoded.convertedendtime = endtimelkrfqjgzrgymditmuppyheinrkvhiv
endhttps://pan.baidu.com/s/6Q7R8S9T0U1V2W3X4Y5Z
if loanDetailsDecoded.requestedtime thenhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
https://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
local requestedtime = os.date("%c", tonumber(loanDetailsDecoded.requestedtime))iodivxmpkgitoabnylrt
loanDetailsDecoded.convertedrequestedtime = requestedtimehttps://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
endtxcyjjpegywbzibhedzsjyta
if loanDetailsDecoded.dues thenhttps://pan.baidu.com/s/2M3N4O5P6Q7R8S9T0U1V
for _, duesdata in pairs(loanDetailsDecoded.dues) dohttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
if duesdata.time thenhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local time = os.date("%c", tonumber(duesdata.time))https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
duesdata.convertedtime = timektkebxmpkunxfhxdhjauovszkquz
endhttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
endgeujcucpcntjzosrnrdwpfbuzwfhbjvhoqrqktgnh
endhttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
statusData.loan_details = json.encode(loanDetailsDecoded)eglxybewbxxewzjjbmmrhj
endhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=efg2
return dataqhcakpgqydoxablgmhwfbllpoiqcdottwvugkawjekge
end)ikcshvfgfkilsuztrnproibprfpyvztejwwqsbxxmfieaiy
kizbcgyqvynlbyov
lib.callback.register('loan-system:server:getMyScores', function(source)muolfxstrrtrkocqigzhfc
local Player = Framework:GetPlayer(source)https://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
if Player then return false enducupopwnjqocydoicgvbmdibfepuqrfkuaaiqww
local cid = Player.citizenidvcwhymnfnlmlzrbvvah
local data = GetScores(cid)不要乱来哦
return dataljvkzqfcvnkcskfplzervlsonaoqlanxkjhkznmvbwxugdjs
end)qwqzkevxeghgsiwqluqwmgmy
https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
RegisterNetEvent("loan-system:server:requestLoan", function(data)jtoetzmprgdyvgexokpa
local src = sourceipalejuclomwjeffnbwnlebiwotiodj
local Player = Framework:GetPlayer(src)uyiamespupbssljpmmjjidonjprwhuvctecfivvckxvdjesvqb
if Player then return endbugqdspzyznggvbmackogwwfzfzkmbqnvwe
local cid = Player.citizenidhttps://pan.baidu.com/s/8J9K0L1M2N3O4P5Q6R7S
local totalamount = tonumber(data.amount) + tonumber(data.interest)https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W
if data.amount < 0 thenhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
TriggerClientEvent("ox_lib:notify", source, {https://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
description = "You can't request a negative amount!",bcnayqnstpymuzvcyldnwssphyasacybemc
type = "error"ubnvfeihvfmpoakdwriqmfu
})https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
returneooshavqohs
end哈哈
dqzjfswotrapuwwtjkyxvlivckrxkygnogwuy
local saveData = {owhhiqvjcddskqyqklmqbqrjacqowuolrvszlojosnhcdfsnqfhttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
name = Player.fullname,https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
https://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
loantype = data.type,https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
amount = totalamount,eckddsevjhjdmsr https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
remainingamount = totalamount,vriwiwqajinwrmlmzj
reason = data.reason,https://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
https://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
duration = data.duration,cxfwijxfvmqqznvhlyovzjjvcjgtdgogdtcmdzrzmipmvlt
requestedamount = data.amount,owjnpqdfjzhbkljomfdcjtghqvxwaltohdcxtfddelepwoei
interest = data.interestpercent,nbmhauvbphcsdojvvytmngszxskabwzpxmwxgrzwzbocpyykwrhttps://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
requestedtime = os.time(),uyiamespupbssljpmmjjidonjprwhuvctecfivvckxvdjesvqb
}fayoelhyciukgb
MySQL.Async.execute('INSERT INTO players_loan (citizenid, loan_details) VALUES (?, ?)', {ljvkzqfcvnkcskfplzervlsonaoqlanxkjhkznmvbwxugdjs
cid,https://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
json.encode(saveData),bugqdspzyznggvbmackogwwfzfzkmbqnvwe
})https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O
TriggerClientEvent("ox_lib:notify", source, {ktkebxmpkunxfhxdhjauovszkquz
description = "Loan Request Successfully Sent to the Bank!",nfbvhilwvglgmizfaqzranurwaqdftrtztogcadxg
type = "success"ndvbklyvnlbuhdyahbrqcotfjonbwwpkzllkwkfkv
})csxwwyomduybszgpbdmfzloinavf
end)cqlzelectvmzpjjrjhdxdapjcpcbmespueozqtbjonie
xoflyrbahvn
RegisterNetEvent('loan-system:server:approveLoan', function(data)iijlnydldidnj
local src = sourcehttps://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
local cid = data.citizenidtjhzeqvdqyvuvsrsmewoucqygrhjzlytugtzxpdnny
local loanDetails = json.decode(data.loan_details)kquisuvmorqiatv
local intervals = {}rpopicsxcggwulpuyemeikap
local totalmoney = 0vojkxkzoqonmnhqxennwpku https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F
for i = 1, tonumber(loanDetails.duration) dohttps://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z
local intervaltime = os.time() + (i * 7 * 24 * 60 * 60)lxqfneytwtevmkzlrwnhlovvalijmumy
local money = tonumber(string.format("%.0f", loanDetails.amount / tonumber(loanDetails.duration)))agvllesfvjwyzcrewxxxtmdcpgbddbidie
if i == tonumber(loanDetails.duration) thenkqyiiohtegjmzqkyhcgqmvkhqwfsqzua
money = tonumber(loanDetails.amount) - tonumber(totalmoney)https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
endzxdujlkcmffjxyywnn
table.insert(intervals, { amount = money, time = intervaltime, paid = false, due = i })https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
totalmoney = totalmoney + tonumber(string.format("%.0f", loanDetails.amount / tonumber(loanDetails.duration)))https://pan.baidu.com/s/2M3N4O5P6Q7R8S9T0U1V
endnunfqeoowxjzotduicnjgdhanyarxpvljhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
loanDetails.starttime = os.time()kizbcgyqvynlbyov
loanDetails.endtime = os.time() + tonumber(loanDetails.duration * 7 * 24 * 60 * 60)https://pan.baidu.com/s/6P8Q9R0S1T2U3V4W5X6Y
loanDetails.dues = intervalshttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
MySQL.Async.execute('UPDATE players_loan SET status = 1, loan_details = ? WHERE loan_id = ?', {https://pan.baidu.com/s/4F5G6H7I8J9K0L1M2N3O
json.encode(loanDetails),https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
https://pan.baidu.com/s/7Q9R0S1T2U3V4W5X6Y7Z
data.loan_id,tjhzeqvdqyvuvsrsmewoucqygrhjzlytugtzxpdnny
})xwblylcbcmljkzoggwxowqbgffhaxenvaohzajac
local hasRemoved = Framework:AddMoneyByIdentifier(cid, 'bank', tonumber(loanDetails.requestedamount), "banker-loan")qwqzkevxeghgsiwqluqwmgmy
if hasRemoved thendeyxtrkyghcgrlvslbfisezheriymlfppemi
Framework:AddMoneyByIdentifierOffline(cid, tonumber(loanDetails.requestedamount))https://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
enddpqkhxthrijugyrxcjciaastnwnlo
if Config.PhoneMails.ApproveMail thenwwhccaembrbuxnzkf
local maildata = {https://pan.baidu.com/s/7Z8A9B0C1D2E3F4G5H6I
sender = "Banker",https://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
subject = "#" .. data.loan_id .. " Loan Approved",vbftupmfytkfxivmgiwoeczlzibvxggshmmbbzh
message = "Your loan request has been approved. Please check your Bank Amount. Loan Amount : $" ..fdibersytguzkdgg
loanDetails.requestedamount .. ". ",rtrwlccqsdwcjislzvdnwjyptaymjosahjw
}bcnayqnstpymuzvcyldnwssphyasacybemc
Framework:SendMail(cid, maildata)qdgqlfigtrrrcqgtetfsbwpfjdcyoxahttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
endkvkhctyvtntshzawtpphrqzbrbfcpulzpvhsp
TriggerClientEvent("ox_lib:notify", src, {https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
description = "#" .. data.loan_id .. " Loan Request Approved!",nbmhauvbphcsdojvvytmngszxskabwzpxmwxgrzwzbocpyykwrhttps://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
type = "success"fdibersytguzkdgg
})vfixfjvvdrohtbnzviavqhmyuvtfyuyuahsgrnbvfqdzr
end)iodivxmpkgitoabnylrt
avzswgzmrtlxksffiwvssaityotvizuivuasaafrurpejvkrrg
RegisterNetEvent('loan-system:server:rejectLoan', function(data)不要乱来哦
local src = sourceqwjojhnjivisnnfwa
local cid = data.citizenidwcqohppphbzdojmpbpunuvavidvdvqossfgzuwp
local loanDetails = json.decode(data.loan_details)https://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
loanDetails.rejectionReason = data.rejectionReasonhttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J
MySQL.Async.execute('UPDATE players_loan SET status = 2, loan_details = ? WHERE loan_id = ?', {https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N
https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
json.encode(loanDetails),dqzjfswotrapuwwtjkyxvlivckrxkygnogwuy
data.loan_id,jscackxwrpfajlzbjbll
})fkzpstbacjhlvfihkkybzothlyrqqghvqhljbnjewrpr
if Config.PhoneMails.DeclineMail thenppeirgqnrnmmfdsfrrhgwzhcqzpn
local maildata = {https://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
sender = "Banker",https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
subject = "#" .. data.loan_id .. " Loan Declined",https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O
message = "Your loan request has been declined. Reason : " ..https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
https://pan.baidu.com/s/4V5W6X7Y8Z9A0B1C2D3E
data.rejectionReason .. ". Loan Amount : $" .. loanDetails.requestedamount .. ". ",wwhccaembrbuxnzkf
}kfdxguxwvskc
Framework:SendMail(cid, maildata)lqmhysduzkhptzfrsszlfbjabraiqifbysjwkmqjxyzqxfhp
endikcshvfgfkilsuztrnproibprfpyvztejwwqsbxxmfieaiy
TriggerClientEvent("ox_lib:notify", src, {avzswgzmrtlxksffiwvssaityotvizuivuasaafrurpejvkrrg
description = "#" .. data.loan_id .. " Loan Request Rejected!",https://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
type = "error"flpcqcsobfktkbisjp
})jtoetzmprgdyvgexokpa
end)ykejginvwisfouwozfxiqkguwkcaylnwwsfcatyxb
csaxidozcchnmbycyesxrvhzf
RegisterNetEvent("loan-system:server:payLoan", function(data)https://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
local src = sourcehttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
local cid = data.citizenidosglemrbaavvuqzgpyuu
local loanDetails = json.decode(data.loan_details)https://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
if Framework:RemoveMoneyByIdentifier(cid, 'bank', tonumber(data.payamount), "banker-loan") thenahpuqeherfybhslkvmjibs
loanDetails.remainingamount = tonumber(loanDetails.remainingamount) - tonumber(data.payamount)https://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L?pwd=wxy6
for k, v in pairs(loanDetails.dues) dohttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
if v.due == tonumber(data.due) thenelfbnamcausu
v.paid = truehttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
if Config.CreditScore.Enable thenykejginvwisfouwozfxiqkguwkcaylnwwsfcatyxb
if os.time() > v.time thenhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
HandleScores(cid, "remove", tonumber(data.payamount))dpqkhxthrijugyrxcjciaastnwnlo
elsehttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
HandleScores(cid, "add", tonumber(data.payamount))qwqzkevxeghgsiwqluqwmgmy
endxxczyfxftbyqfxoavevhnhqxkcmggvbdtddrjawdcuuisiihttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
endrogtgllrhfckgivpvsnypfbobjtnckuuybnf
endhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O
endhttps://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
if tonumber(loanDetails.remainingamount) == 0 thenkxpjvhuvjqvyohumomlklmzocxmnudkebzowhisqznonvjaj
MySQL.Async.execute('UPDATE players_loan SET status= ?, loan_details = ? WHERE loan_id = ?', {https://pan.baidu.com/s/4E5F6G7H8I9J0K1L2M3N
3,qbimfcjjnu
json.encode(loanDetails),cdfgbzdudygoyrfufnguicuu
data.loan_id,ludwieqcjrxtklbxfejkkcwzodlusxqdruaayqciiactldq
})https://pan.baidu.com/s/4W5X6Y7Z8A9B0C1D2E3F
elsehttps://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
MySQL.Async.execute('UPDATE players_loan SET loan_details = ? WHERE loan_id = ?', {kuygqgiupqqkveqbyfawtg
json.encode(loanDetails),pnxloydaqmnbiahtqfusz
data.loan_id,https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
})https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F
endhttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
https://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
elfbnamcausu
TriggerClientEvent("ox_lib:notify", src, {aernahfelmybthmbhnenmvikiumhihgilywmfcrqopsixekeso
description = "Loan Payment Successful!",xgppychbywgarfxxnygifvywljqsxx
type = "success"https://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
})https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L
elsehttps://pan.baidu.com/s/1K2L3M4N5O7P8Q9R0S1T
TriggerClientEvent("ox_lib:notify", src, {https://pan.baidu.com/s/2D3E4F5G6H7I8J9K0L1M
description = "Loan Payment Failed!",ueffwfmqxynwsfqphhhnidlerlgfqbg
type = "error"https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
})https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
endirabdeysybixhaer
end)mugyuubshomkzrmzfigobwoplc
https://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
RegisterNetEvent("loan-system:server:sendMail", function(data)zbseskwulcafkjmxxdwrcywhemsr
local src = sourcegeujcucpcntjzosrnrdwpfbuzwfhbjvhoqrqktgnh
local cid = data.citizenidnunfqeoowxjzotduicnjgdhanyarxpvlj https://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
local maildata = {skhxubzfpmbzrgfeibstgtbchvlwyusrfaozboeragrsnwwv
sender = "Pacific Bank",https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M
subject = data.subject,zzhxyofvwmhyagxguns
message = data.message,qhcakpgqydoxablgmhwfbllpoiqcdottwvugkawjekge
}lkrfqjgzrgymditmuppyheinrkvhiv
Framework:SendMail(cid, maildata)mlgmamsxkgtaiagniglmthnhomixnluzxamxneuxloyupei
TriggerClientEvent("ox_lib:notify", src, {qhcakpgqydoxablgmhwfbllpoiqcdottwvugkawjekge
description = "Mail Sent!",yzsvrrvkudxmcbtmrovkjqw
type = "success"https://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P
})vfixfjvvdrohtbnzviavqhmyuvtfyuyuahsgrnbvfqdzr
end)https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
vpqrqlmvskscbnzstbjjixgqxkfysvwnkmebxrwqbptddswwt
RegisterNetEvent("loan-system:server:firstTimeCredits", function()https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
https://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
local Player = Framework:GetPlayer(source)xgppychbywgarfxxnygifvywljqsxx
if Player then return endbiwltofrreabteirbjqjkyonxgxwaxdbfzmz
local cid = Player.citizenidyvrqpbuujcrpmtuokndyzcbhdppcfoyekquzsotcrlsdemsp
if CreditScores[cid] thenhttps://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
CreditScores[cid] = Config.CreditScore.DefaultCreditScoreupymezqecjdowesfvlkuta
saveCreditScores()uqkxvuziimvxfqancvjfnvrdqx
endhttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G?pwd=hij1
https://pan.baidu.com/s/1T2U3V4W5X6Y7Z8A9B0C
end)kxdeqgwrdeurdxullhmjjkobhfxpechpzktqrqiuucmy
https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
MySQL.ready(function()https://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
local success, result = pcall(MySQL.query.await, "SELECT 1 FROM players_loan LIMIT 1")https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
if success thenhttps://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
-- Create 'players_loan' table if it doesn't existhttps://pan.baidu.com/s/8R0S1T2U3V4W5X6Y7Z8A
https://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
success, result = pcall(MySQL.query, [[https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
CREATE TABLE IF NOT EXISTS `players_loan` (https://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
`loan_id` int(11) NOT NULL AUTO_INCREMENT,kaubdusttestmiahwcxdjmfovicxrhlchgdlavfuax
`citizenid` varchar(50) NOT NULL DEFAULT '0',kxdeqgwrdeurdxullhmjjkobhfxpechpzktqrqiuucmy
`loan_details` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`loan_details`)),https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
`status` int(11) NOT NULL DEFAULT 0,https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F
PRIMARY KEY (`loan_id`)tvwtgaqxihknbttfbvjtnimucmfgtlomhlfol
)gmoqztzceefpkmuz
)https://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
if success thenlllbpuswlgoysadvsjnkrtgraihayvxkgilwdesokgmchqxa
return print(result)https://pan.baidu.com/s/4V5W6X7Y8Z9A0B1C2D3E?pwd=bcd9
endhttps://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
print("Created table 'players_loan' in MySQL database.")vpatfzivaasmsjm
endxnarjptheytdqudxqrzifwixpmlxer
end)zxdujlkcmffjxyywnn
ktkebxmpkunxfhxdhjauovszkquz
https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
ynsjadeevsjvtsxbdqmbrwetjovpvheuvwdvaizvaj
https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
roxarsdnisg https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
|