Company announcements
Opening, closing and free announcements for companies in MrPoulpi UI: configuration, permissions, cooldown and customisation.
Employees of a configured company can send an announcement to every player, as an announcement notification:
| Announcement | Badge | Colour | Message |
|---|---|---|---|
| Opening | Open | green | The company openMessage, otherwise the default text. |
| Closing | Closed | red | The company closeMessage, otherwise the default text. |
| Announcement | Announcement | company type |
Message typed by the employee. |
Employees reach it with the /entreprise command (set by Config.Companies.command) or the Company section of the demo menu.
Setting up companies
Config.Companies = {
enabled = true,
command = 'entreprise',
cooldown = 60,
duration = 10000,
minLength = 3,
maxLength = 120,
staff = 'administration',
list = {
administration = { label = 'Administration', type = 'info' },
realestateagent = {
label = 'Real Estate Agent',
type = 'success',
minGrade = 0,
logo = 'assets/logos/realestate.png',
logoText = 'REA',
openMessage = 'Our offices are open!',
closeMessage = 'Our offices are closed.'
},
mechanic = { label = 'Benny’s', type = 'warning', minGrade = 2 }
}
}
| Field | Description |
|---|---|
key (realestateagent) |
Job name in your framework (job.name). |
label |
Name shown in the announcement and as the menu title. |
type |
Colour of free announcements: success, info, warning or error. info by default. |
minGrade |
Minimum grade to announce. 0 by default. |
logo |
Optional picture: assets/… (file placed in html/assets/) or an https:// address. |
logoText |
Text of the logo square when there is no picture. By default, the initials of the name (three at most). |
openMessage, closeMessage |
Custom messages, as text or as a shared/locales.lua key. |
Other settings are described in the configuration.
Who can announce
- A player whose job is in
listwith a grade at least equal tominGradeannounces on behalf of their company. - Otherwise, if
Config.Companies.staffnames a company of the list and the player has the menu permission, they announce on behalf of that one. Handy for staff and for testing. Setstaff = nilto prevent it. - Otherwise, the player gets “You do not belong to an authorized company”.
In standalone there are no jobs: only the staff rule applies.
Server checks
Everything is checked server side, on every announcement:
- the player’s job and grade;
- the
cooldown, counted per company: two employees cannot announce back to back; - the length of the free message, between
minLengthandmaxLength, after extra spaces are removed; - the
Hooks.CanAnnouncehook, if it returnsfalse.
Every announcement sent goes through Hooks.Log (company_announce event), so to the Discord webhook when one is set.
Logo pictures
Put your logos in html/assets/ (for example html/assets/logos/realestate.png) and give the path starting at assets/. https:// and nui:// addresses work too.
Going further
For other rules (several jobs, gangs, companies stored in a database, opening hours), edit in server/hooks.lua:
Hooks.GetCompany(source): returnsname, dataof the player’s company, ornil;Hooks.CanAnnounce(source, company, kind, message): returnfalseto refuse.kindisopen,closeorcustom.
function Hooks.CanAnnounce(source, company, kind, message)
local hour = tonumber(os.date('%H'))
if kind == 'open' and hour >= 3 and hour < 8 then
Hooks.Notify(source, 'Opening is not allowed between 3 and 8 am', 'error')
return false
end
return true
end