Adding new documents

For a example we add a police badge

@vms_documents/server/server.lua search function showDocument, and we adding a new elseif

lines :63 -> :71

elseif type == "id_weapon" then
    playerInfo = {
        ['firstname'] = result[1].firstname,
        ['lastname'] = result[1].lastname,
        ['dob'] = result[1].dateofbirth,
        ['sex'] = result[1].sex,
        ['weapon'] = getLicense(src, "weapon"),
    }
elseif type == "police_badge" then -- unique of type
    playerInfo = { --here we fetch the things we want to be displayed on the document
        ['firstname'] = result[1].firstname, -- It must be because it is required in every document by JS by default
        ['lastname'] = result[1].lastname, -- It must be because it is required in every document by JS by default
        ['dob'] = result[1].dateofbirth, -- It must be because it is required in every document by JS by default
        ['sex'] = result[1].sex,
        ['grade'] = xPlayer.job.grade_label
    }
end

@vms_documents/config.lua search a Config.Documents, and we adding a new table named by unique type from server side

Config.Documents = {
    [...]
    
    ["police_badge"] = {
        item = nil,
        color = "#d92b2b", -- https://htmlcolors.com/google-color-picker
        animation = {"random@atmrobberygen", "a_atm_mugging"}, -- if the player is to have an animation, we type {animDict, animName}
        animationTimeout = 2500, -- time of animation
        header = "POLICE BADGE", -- header on the ui of document
        icon = "local_police", -- icon on the ui of document (https://fonts.google.com/icons)
        notifyText = "You showed a badge.", -- notification to player
     },
 }

@vms_documents/html/app.js search eventListener from message, and we adding a new if to action open

if (data.type == "police_badge") {
    $("#info-3").html(`Sex`) // Here a name of infos
    $("#infoDescription-3").css("color", `${data.documentOptions.color}`)
    $("#infoDescription-3").html(`${data.documentInfos.sex}`)
    $("#info-4").html(`Grade name`) // Here a name of infos
    $("#infoDescription-4").css("color", `${data.documentOptions.color}`)
    $("#infoDescription-4").html(`${data.documentInfos.grade}`) // and we adding here a grade
}

Last updated