Skip to content

Commit

Permalink
Update 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuraiDevCo authored Aug 19, 2024
1 parent 95ef106 commit cadd3a3
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 6 deletions.
1 change: 1 addition & 0 deletions config/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SDC.NotificationSystem = "framework" -- ['mythic_old', 'mythic_new', 'tnotify',

SDC.FriendCodeLength = 6 --The Length Of Friend Codes (MAX IS 12)
SDC.ClaimFriendCodePlaytimeMax = 120 --This is how long a player has to claim friend codes before it locks (In Mins)
SDC.MaxClaimableFriendCodes = 3 --This is how many friend codes can be claimed in total!

SDC.CheckCodesInterval = 5 --This is how often it will check outdated codes(In Mins)
SDC.UpdatePlayersInDatabase = 5 --This is how often it will update the database with player playtime(In Mins)
Expand Down
9 changes: 8 additions & 1 deletion config/lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ SDC.Lang = {
CodeCreator15 = "Expires In",
CodeCreator16 = "Enter Days",
CodeCreator17 = "Enter Hours",
CodeCreator18 = "No Required Jobs Set!",
CodeCreator19 = "Required Job(s)",
CodeCreator20 = "Job Name Required",
CodeCreator21 = "Job Grade Required",
CodeCreator22 = "(If You Put Grade Required As -1 It Will Remove The Job!)",
Days = "Days",
Hours = "Hours",
UnableToCreateCode = "Unable To Create Code Due To Missing Identifier!",
Expand All @@ -64,5 +69,7 @@ SDC.Lang = {
PlayerClaimedFriendCode = "Player Claimed Friend Code",
PlayerClaimedServerCode = "Player Claimed Server Code",
PlayerClaimedRewards = "Player Claimed Rewards",
PlayerCreatedCode = "Player Created Code"
PlayerCreatedCode = "Player Created Code",
MissingRequiredJob = "Cant Claim Server Code! Missing Required Job/Grade For This Code!",
ClaimedMaxFriendCodes = "Already Claimed Maximum Amount Of Friend Codes Allowed!"
}
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ games { 'gta5' }

author 'HoboDevCo#3011'
description 'SDC | Codes Script'
version '1.0.3'
version '1.0.4'

shared_script {
"@ox_lib/init.lua",
Expand Down
49 changes: 49 additions & 0 deletions src/client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,55 @@ AddEventHandler("SDCC:Client:OpenCodeCreator", function()
})
end

local joblist = nil
if newCodeData.RewardData.NeededJob then
local gotone = false
for k,v in pairs(newCodeData.RewardData.NeededJob) do
gotone = true
if joblist then
joblist = joblist..", "..k.."("..v..")"
else
joblist = k.."("..v..")"
end
end
if not gotone then
newCodeData.RewardData["NeededJob"] = nil
joblist = nil
end
end
if not joblist then
joblist = SDC.Lang.CodeCreator18
end
table.insert(tab, {
title = SDC.Lang.CodeCreator19,
description = joblist,
icon = 'building-user',
onSelect = function()
local input = lib.inputDialog(SDC.Lang.CodeCreator19, {
{type = 'input', label = SDC.Lang.CodeCreator20, required = true},
{type = 'number', label = SDC.Lang.CodeCreator21, description = SDC.Lang.CodeCreator22, required = true},
})

if input and input[1] and input[2] then
if input[2] == -1 then
if newCodeData.RewardData["NeededJob"] and newCodeData.RewardData["NeededJob"][input[1]] then
newCodeData.RewardData["NeededJob"][input[1]] = nil
end
else
if newCodeData.RewardData["NeededJob"] then
newCodeData.RewardData["NeededJob"][input[1]] = input[2]
else
newCodeData.RewardData["NeededJob"] = {[input[1]] = input[2]}
end
end
TriggerEvent("SDCC:Client:OpenCodeCreator")
else
TriggerEvent("SDCC:Client:OpenCodeCreator")
end
end,
})


local list = nil
for k,v in pairs(newCodeData.RewardData.Items) do
if list then
Expand Down
26 changes: 22 additions & 4 deletions src/server/server.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
CodeCreators = { --This is where you add all your code creators, must match the license you have checking above!
--Example: "license:b57267ca8ac5ee2e6218821d610f9aa9ff30a1c2"
"license:fb86adde57d900f7a4c512143568feed0b3606c0",
"license:b57267ca8ac5ee2e6218821d610f9aa9ff30a1c2"
}


Webhooks = { --Put Discord Webhook Links In these
ClaimFriendCode = "",
ClaimServerCode = "",
RedeemRewards = "",
CreateCode = ""
ClaimFriendCode = "https://discord.com/api/webhooks/1266006374614302730/cfcouf9Dgt3FcBprD1h9BoNHZ04EHeFbFWGWOwVIfZ5Ygt_y2VTWAQXD08MdMFNeFYJL",
ClaimServerCode = "https://discord.com/api/webhooks/1266006374614302730/cfcouf9Dgt3FcBprD1h9BoNHZ04EHeFbFWGWOwVIfZ5Ygt_y2VTWAQXD08MdMFNeFYJL",
RedeemRewards = "https://discord.com/api/webhooks/1266006340174876776/MfFUubI7OYqEfqGu_9Rlh-AAHsnIHLHZwrPH4PhT4H0BaF_ohtJac0DzSfKB9h-pw8gk",
CreateCode = "https://discord.com/api/webhooks/1266006304787398790/2QmKCrL9McnlN6nKIl92awIEW5pTejnxRyfMu1dUqMb8Woql_iBMxXp9-z56ywgqci61"
}


Expand Down Expand Up @@ -156,6 +158,11 @@ AddEventHandler("SDCC:Server:CheckCode", function(daCode)
return
end

if #pCodes_identifier[ident].UsedFCodes >= SDC.MaxClaimableFriendCodes then
TriggerClientEvent("SDCC:Client:Notification", src, SDC.Lang.ClaimedMaxFriendCodes, "error")
return
end

if canClaim then
table.insert(pCodes_identifier[ident].UsedFCodes, daCode)
table.insert(pCodes_code[pCodes_identifier[ident].Code].UsedFCodes, daCode)
Expand Down Expand Up @@ -303,6 +310,17 @@ AddEventHandler("SDCC:Server:CheckGlobalCode", function(daCode)
end

if canClaim then
if cCodes[daCode].RewardData["NeededJob"] then
local job, grade = GetJobAndGrade(src)
local good = false

if not job or not cCodes[daCode].RewardData["NeededJob"][job] or grade < tonumber(cCodes[daCode].RewardData["NeededJob"][job]) then
TriggerClientEvent("SDCC:Client:Notification", src, SDC.Lang.MissingRequiredJob, "error")
return
end
end


local itemstring = "None"
table.insert(pCodes_identifier[ident].UsedCodes, daCode)
table.insert(pCodes_code[pCodes_identifier[ident].Code].UsedCodes, daCode)
Expand Down
18 changes: 18 additions & 0 deletions src/server/server_customize_me.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,22 @@ function GiveMoney(src, amt)
local xPlayer = ESX.GetPlayerFromId(src)
xPlayer.addAccountMoney('money', amt)
end
end

function GetJobAndGrade(src)
if SDC.Framework == "qb-core" then
local Player = QBCore.Functions.GetPlayer(src)
if Player.PlayerData and Player.PlayerData.job then
return Player.PlayerData.job.name, Player.PlayerData.job.grade.level
else
return nil
end
elseif SDC.Framework == "esx" then
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer.job and xPlayer.job.name then
return xPlayer.job.name, xPlayer.job.grade
else
return nil
end
end
end

0 comments on commit cadd3a3

Please sign in to comment.