Registering Papers
From this section, you can learn how to create papers and use them.
Last updated
From this section, you can learn how to create papers and use them.
Last updated
local API = exports["no-newspaper"]
local WeazelNews = API:RegisterPaper({
id = "weazelnews",
label = "Weazel News",
canPublish = function(source)
local player = ESX.GetPlayerFromId(source)
return player and player.job.name == "weazelnews"
end,
canDelete = function(source)
local player = ESX.GetPlayerFromId(source)
return player and player.job.name == "weazelnews"
end
})
local function PrintArticles(articles)
for _, article in pairs(articles) do
print(article.id)
print(article.header)
print(article.author)
print(article.content)
print(article.image)
print(article.date)
end
end
local function PrintAllArticles()
local articles = WeazelNews:GetAllArticles()
PrintArticles(articles)
end
local function PrintArticlesByDate(date)
local articles = WeazelNews:GetArticles(date)
PrintArticles(articles)
end
RegisterNetEvent("jail:player", function(source, months)
local player = ESX.GetPlayerFromId(source)
if not player then return end
local fullname = player.get("firstname") .. " " .. player.get("lastname")
WeazelNews:Publish({
header = "Jail Sentence",
author = "Bolingbroke Penitentiary",
content = fullname .. " sentenced for " .. months .. " months in jail!"
})
end)