Skip to content

Commit

Permalink
Merge pull request #6 from iseeyoucopy/main
Browse files Browse the repository at this point in the history
Menu Enhancements and Code Improvements
  • Loading branch information
iseeyoucopy authored Oct 20, 2024
2 parents 75cbc25 + eed4129 commit fdf007f
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 147 deletions.
395 changes: 277 additions & 118 deletions client/main.lua

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Config = {
reissuePrice = 20,
changePhotoPrice = 10,
extendPrice = 10,
expiryDays = 0, -- Set expiry duration by default
defaultPicture = '',
sellNpc = true,
givenCommand = false,
Expand All @@ -52,7 +53,8 @@ Config = {
reissuePrice = 30,
changePhotoPrice = 10,
extendPrice = 10,
defaultPicture = '',
expiryDays = 1, -- Set expiry duration by default
defaultPicture ='',
sellNpc = true,
givenCommand = false,
allowJob = "",
Expand All @@ -63,14 +65,19 @@ Config = {
reissuePrice = 25,
changePhotoPrice = 10,
extendPrice = 10,
defaultPicture = ''
expiryDays = 1, -- Set expiry duration by default
defaultPicture = '',
sellNpc = true,
givenCommand = false,
allowJob = "",
},
lumberlicence = {
displayName = "Lumber Licence",
price = 15,
reissuePrice = 20,
changePhotoPrice = 10,
extendPrice = 10,
expiryDays = 1, -- Set expiry duration by default
defaultPicture = '',
sellNpc = true,
givenCommand = false,
Expand All @@ -82,6 +89,7 @@ Config = {
reissuePrice = 15,
changePhotoPrice = 10,
extendPrice = 10,
expiryDays = 1, -- Set expiry duration by default
defaultPicture = '',
sellNpc = true,
givenCommand = false,
Expand All @@ -93,7 +101,8 @@ Config = {
reissuePrice = 0,
changePhotoPrice = 0,
extendPrice = 0,
defaultPicture = 'https://upload.fixitfy.com.tr/images/FIXITFY-lCnMiZnVCH.png',
expiryDays = 0, -- Set expiry duration by default
defaultPicture = '',
sellNpc = false,
givenCommand = "giveweaponlicense",
allowJob = "doj",
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ dependency {
'bcc-utils'
}

version '0.0.2'
version '0.1.0'
3 changes: 2 additions & 1 deletion languages/de_lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ Locales["de_lang"] = {
GetDocument = "Du hast ein Dokument erhalten: ",
GiveDocument = "Du hast ein Dokument ausgestellt: ",
TargetAlreadyGotDocument = "Die Person besitzt dieses Dokument bereits!",
NoNeedItem = "Dir fehlt folgender Gegenstand: "
NoNeedItem = "Dir fehlt folgender Gegenstand: ",
checkingYourDoc = " - Checking your document"
}
3 changes: 2 additions & 1 deletion languages/en_lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ Locales["en_lang"] = {
GetDocument = "You have received a document: ",
GiveDocument = "You gave a document: ",
TargetAlreadyGotDocument = "The person already has this document!",
NoNeedItem = "You are missing the following item: "
NoNeedItem = "You are missing the following item: ",
checkingYourDoc = " - Checking your document"
}
7 changes: 4 additions & 3 deletions languages/ro_lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ Locales["ro_lang"] = {
YouRevokedDocument = 'Ti-ai anulat documentul',
DontHaveToRevoke = 'Nu ai un document de anulat',
--- New
NoJob = "Nu sunteți autorizat faceți acest lucru!",
GetDocument = "Ați primit un document: ",
NoJob = "Nu sunteți autorizat sa faceți acest lucru!",
GetDocument = "Ati primit un document: ",
GiveDocument = "Ai dat un document: ",
TargetAlreadyGotDocument = "Persoana are deja acest document!",
NoNeedItem = "Vă lipsește următorul articol: "
NoNeedItem = "Va lipseste urmatorul articol: ",
checkingYourDoc = " - Verifica documentul dvs"
}
37 changes: 18 additions & 19 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@ local function devPrint(...)
end
end

-- Function to register a document type as a usable item
local function registerDocumentType(docType)
exports.vorp_inventory:registerUsableItem(docType, function(data)
handleDocumentUse(data.source, docType)
end)
end

-- Function to handle the usage of a document
function handleDocumentUse(src, docType)
function handleDocumentUse(src, docType, docDisplayName)
local User = VORPcore.getUser(src)

if User then
Expand All @@ -27,25 +20,30 @@ function handleDocumentUse(src, docType)
MySQL.query('SELECT * FROM `bcc_documents` WHERE charidentifier = ? AND doc_type = ?', {charidentifier, docType}, function(result)
if result and #result > 0 then
local doc = result[1]
devPrint("Document found:", doc)
devPrint("Document found:", json.encode(doc)) -- Use json.encode to print the table contents
TriggerClientEvent('bcc-documents:client:opendocument', src, docType, doc.firstname, doc.lastname, doc.nickname, doc.job, doc.age, doc.gender, doc.date, doc.picture, doc.expire_date)
else
devPrint("No document found for user:", charidentifier, "docType:", docType)
VORPcore.NotifyLeft(src, _U('GotNoDocument'), "", Config.Textures.cross[1], Config.Textures.cross[2], 5000)
end
-- Close inventory only after event handling
exports.vorp_inventory:closeInventory(src)
end)
else
devPrint("Error: Character data not found for user:", src)
end
else
devPrint("Error: User not found for source:", src)
end
exports.vorp_inventory:closeInventory(src)
end

-- Iterate over each document type and register it
for docType, _ in pairs(Config.DocumentTypes) do
registerDocumentType(docType)
-- Iterate over each document type and register it as a usable item
for docType, docData in pairs(Config.DocumentTypes) do
exports.vorp_inventory:registerUsableItem(docType, function(data)
local src = data.source
exports.vorp_inventory:closeInventory(src) -- Close inventory on use
handleDocumentUse(src, docType, docData.displayName) -- Pass the display name
end)
end

-- Register other server events
Expand All @@ -57,7 +55,8 @@ AddEventHandler('bcc-documents:server:createDocument', function(docType)
local Money = Character.money
local price = Config.DocumentTypes[docType].price
local year = Config.PlayYear
local date, newExpiryDate = os.date(year..'-%m-%d %H:%M:%S')
local date = os.date(year..'-%m-%d %H:%M:%S')
local newExpiryDate = os.date(year..'-%m-%d %H:%M:%S', os.time() + (Config.DocumentTypes[docType].expiryDays * 86400))
local picture = Config.DocumentTypes[docType].defaultPicture

devPrint("Creating document for user:", charidentifier, "docType:", docType)
Expand Down Expand Up @@ -98,7 +97,8 @@ AddEventHandler('bcc-documents:server:createDocumentCommand', function(src, docu
local targetIdentifier = target.charIdentifier
local docType = document
local year = Config.PlayYear
local date, newExpiryDate = os.date(year..'-%m-%d %H:%M:%S')
local date = os.date(year..'-%m-%d %H:%M:%S')
local newExpiryDate = os.date(year..'-%m-%d %H:%M:%S', os.time() + (Config.DocumentTypes[docType].expiryDays * 86400))
local picture = Config.DocumentTypes[docType].defaultPicture
local itemNeedCount = exports.vorp_inventory:getItemCount(src, nil, Config.NeedItemName)
if Config.NeedItem then
Expand Down Expand Up @@ -334,10 +334,9 @@ end)
function RegisterCommands(command, document, job)
RegisterCommand(command, function(source, args, rawCommand)
local src = source
--GiveDoc(src, document, job, args)
TriggerEvent('bcc-documents:server:createDocumentCommand', src, document, job, args)
end)
print("--------------------------------------------------------------")
print("Command Registered!", command)
print("--------------------------------------------------------------")
devPrint("--------------------------------------------------------------")
devPrint("Command Registered!", command)
devPrint("--------------------------------------------------------------")
end
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<0.0.2>
<0.1.0>
See GitHub for details!

0 comments on commit fdf007f

Please sign in to comment.