Musicians¶
hobbs_musicians, version 2.0.1
Overview¶
A musician for every saloon on your server. Your saloon staff hire him at the bar, pick what he plays, and he walks over to his spot and starts. Guests who like the music drop a tip or ask for a different instrument. The tips land in a jar for that saloon, and staff empty it into their pocket as cash.
The music itself comes from the game. Every instrument is a scenario that Red Dead already ships, so the animation, the prop and the sound are the real ones, nothing is faked. Nine instruments are included: piano, banjo, mandolin, blues guitar, guitar, harmonica, concertina, jaw harp and fiddle.
Everything you can change is in config.lua and locales.lua, the rest is encrypted.
How it plays¶
- A player with the saloon job walks to the management spot of their saloon. A prompt opens with the name of the saloon and the first instrument.
- They browse with the arrow keys through the instruments and the auto entries, and confirm with E.
- The musician appears at his spawn point, walks over to the stage and starts playing. If they picked an auto entry, he starts with a random instrument and changes to another random one every few minutes.
- While he plays, staff at the management spot can switch him to a different instrument, stop him with Backspace, or collect the tips with G. The collect prompt shows the current balance.
- Guests who stand near the musician see a tip prompt. They pick an amount with the arrow keys and give it with E. The money leaves their cash and goes into the saloon's jar.
- Guests can also pick an instrument and send a request with G. Every online staff member of that saloon gets a message with the guest's name and the wish. Whether the musician actually plays it is up to the staff.
- When staff stop the music, the musician packs up, walks back to where he came from and disappears.
Requirements¶
| Resource | Why |
|---|---|
vorp_core |
Jobs of the characters, cash for tips and payouts, the bottom-of-screen messages |
oxmysql |
The tip jar of every saloon is stored in the database |
nss_libs |
All prompts, the browsing with the arrow keys and the key handling |
None of them is optional. Each saloon is tied to one or more VORP job names, so you need those jobs in VORP before the prompts show for anybody. Read Getting started if you set up one of my scripts for the first time.
Installation¶
- Unpack the resource into your
resourcesfolder and keep the folder namehobbs_musicians. - There is no SQL file to run. The script creates the table
hobbs_musicians_tipson its own at the first start, with one row per saloon in your config. That table only holds the tip balance. - There are no items to add.
- Create the jobs you want to use in VORP. The config ships with
Saloon_BW,Saloon_VH,Saloon_VAL,Saloon_SD,Saloon_RHOandSaloon_ARM, one per saloon. Rename them to the jobs you already have, or create these. -
Add the resource to
server.cfgafter its dependencies: -
Set
Config.Langand go throughConfig.npcsinconfig.lua, see below. - On the first start, give a character one of the jobs, walk to the
managePosof that saloon and check that the prompt opens. If it does, the job, the position and the database all work.
Note
The row in the tip table is tied to the position of the saloon in Config.npcs. The first entry is location 1, the second is 2, and so on. Add new saloons at the end of the list, and do not reorder the list once tips have been collected, or the balances swap saloons.
Configuration¶
All settings live in config.lua. All texts and the instrument names live in locales.lua.
Language¶
English, German and French are included. Every prompt, message and instrument name comes from locales.lua. To add a language, copy one of the Locales.xx blocks, translate it and set Config.Lang to its key. If the key does not exist, the script falls back to English.
Keys¶
Config.KeyStop = 0x156F7119 -- Backspace: stop the musician
Config.KeyConfirm = 0xCEFD9220 -- E: confirm, switch, give tip
Config.KeyLeft = 0xA65EBAB4 -- Left arrow: previous entry
Config.KeyRight = 0xDEB34313 -- Right arrow: next entry
Config.KeyCollect = 0x760A9C6F -- G: collect tips, send request
The values are RedM control hashes. Change them if one of these keys already does something else on your server. For example, if G opens a menu on your server, give Config.KeyCollect a different hash.
Distances¶
Config.ManageDist = 1.5 -- to managePos, staff prompts
Config.TipDist = 2.0 -- to playPos, guest prompts
How close a player has to stand before the prompts show. ManageDist is measured from managePos and only matters for staff. TipDist is measured from playPos, the spot where the musician plays, and only matters for guests while he is playing. I kept the staff distance tight so the prompt does not pop up for everyone walking past the bar. If your stage is in a corner that guests cannot reach, raise TipDist to 3.0 so they can tip from the next table.
Tips¶
TipAmounts is the list guests browse through, in the order given. A tip is taken from the guest's cash and added to the jar of that saloon. A guest without enough cash gets a message and nothing happens. The server checks every tip against this list, so a modified client cannot send a different amount.
Set TipEnabled = false and all guest prompts disappear, the tip prompt and the request prompt, and staff lose the collect prompt. The table stays, nothing is deleted.
Want bigger spenders? Set Config.TipAmounts = { 1.00, 5.00, 10.00, 25.00 }.
Requests¶
Config.WishEnabled = true
Config.WishCooldown = 30 -- seconds between two requests of the same player
With requests on, guests get a second prompt next to the tip prompt where they pick an instrument and send it with G. The server then tells every online player who has one of the saloon's jobs: "Name Surname requests: Fiddle". A request does not change anything on its own, staff decide whether to switch.
WishCooldown is how long a player has to wait after one request before the next one goes through. In between they only see "Wait a moment before your next request." I added this because a bored guest can otherwise spam the whole staff. Raise it to 120 on a busy server, or set WishEnabled = false if you do not want requests at all.
Note that the request prompt only shows while TipEnabled is true, and only when the musician has more than one instrument to choose from.
Auto play¶
Every number in AutoPlayIntervals adds one "Auto (n min)" entry after the instruments in the staff prompt. Pick one and the musician starts with a random instrument, then every n minutes he stops, changes to another random one from his list and plays on. The change takes about ten seconds, during which he sits without an instrument. Switching by hand or stopping him ends the auto mode.
The timer for the auto mode runs in the game of the staff member who started it. If that player logs out, the musician keeps playing the current instrument but does not change any more.
Set AutoPlayEnabled = false and the staff prompt lists only the instruments. If you only want long sets, use Config.AutoPlayIntervals = { 15, 30 }.
Instruments¶
Config.Instruments = {
{ id = "piano", scenario = "PROP_HUMAN_PIANO_RIVERBOAT", prop = nil, usePianoHeading = true },
{ id = "banjo", scenario = "PROP_HUMAN_SEAT_CHAIR_BANJO", prop = "p_banjo01x", usePianoHeading = false },
{ id = "mandolin", scenario = "PROP_HUMAN_SEAT_BENCH_MANDOLIN", prop = "p_mandolin01x", usePianoHeading = false },
{ id = "blues", scenario = "PROP_HUMAN_SEAT_CHAIR_BLUES_GUITAR", prop = "p_guitar01x", usePianoHeading = false },
{ id = "guitar", scenario = "PROP_HUMAN_SEAT_CHAIR_GUITAR", prop = "p_guitar01x", usePianoHeading = false },
{ id = "harmonica", scenario = "PROP_HUMAN_SEAT_BENCH_HARMONICA", prop = nil, usePianoHeading = false },
{ id = "concertina", scenario = "PROP_HUMAN_SEAT_BENCH_CONCERTINA", prop = "p_cs_concertina01x", usePianoHeading = false },
{ id = "jawharp", scenario = "PROP_HUMAN_SEAT_BENCH_JAW_HARP", prop = nil, usePianoHeading = false },
{ id = "fiddle", scenario = "PROP_HUMAN_SEAT_BENCH_FIDDLE", prop = nil, usePianoHeading = false, femaleOnly = true },
}
| Key | Meaning |
|---|---|
id |
Key of the name in locales.lua under instruments. Shown in every prompt and message |
scenario |
The game scenario the musician plays. It brings the animation and the sound |
prop |
The prop the scenario spawns, so the script can clean it up when he switches or stops. nil when the scenario has none |
usePianoHeading |
true turns the musician by the saloon's headingPiano, false by its headingOther |
femaleOnly |
Only offered when the saloon's musician model is female |
The list is the order the prompt shows. Remove an entry and it is gone everywhere, from the staff prompt, the auto mode and the guest requests. The piano is a world object, so the musician has to sit at a real piano for it. A saloon without a headingPiano simply does not offer the piano.
The script decides whether a model is female by its name: a_f_, s_f_, cs_f, u_f_ and mp_f count as female. The fiddle scenario only works with women, which is why it is marked femaleOnly.
If you do not want the jaw harp in your saloons, delete its line. Nothing else needs changing.
Locations¶
Config.npcs = {
{
name = "Saloon Valentine",
model = "A_M_M_ValFarmer_01",
AllowedJobs = { "Saloon_VAL" },
headingPiano = 100.04,
headingOther = 292.65,
spawnPos = { x = -315.04, y = 812.54, z = 121.08 },
walkToPos = { x = -311.77, y = 799.1, z = 118.99 },
playPos = { x = -312.35, y = 799.02, z = 118.48 },
managePos = { x = -314.77, y = 808.48, z = 118.98 },
},
-- ...
}
| Key | Meaning |
|---|---|
name |
Shown in the header of every prompt of this saloon |
model |
Ped model of the musician. A female model unlocks the femaleOnly instruments |
AllowedJobs |
VORP job names that may hire, switch and stop the musician and collect the tips |
headingPiano |
Direction the musician faces at the piano. Leave the line out if the saloon has no piano, then the piano is not offered there |
headingOther |
Direction he faces for every other instrument |
spawnPos |
Where he appears, and where he walks back to when stopped before he vanishes. Put it out of sight, a back room or behind the building |
walkToPos |
Where he walks to after appearing, right next to the stage |
playPos |
The exact spot he plays on. The guest prompts show around this point |
managePos |
Where staff have to stand to see their prompts, usually behind the bar |
Six saloons are included as examples: Blackwater, Van Horn, Valentine, Saint Denis, Rhodes and Armadillo. They are a starting point, replace them with your own places and your own job names. More than one job can manage the same musician, AllowedJobs = { "Saloon_VAL", "Mayor" } lets both in.
Tip
playPos and the headings decide whether the musician sits properly on the stool or hangs in the air. Stand on the spot yourself, note your coordinates and heading, and move the values in small steps until the piano looks right.
Commands and keys¶
There are no chat commands. Everything runs through prompts that open when you stand on the right spot.
Staff, at managePos, with one of the saloon's jobs:
| Key | Action |
|---|---|
| Left / Right | Browse instruments and auto entries, or the instrument to switch to |
| E | Hire the musician with the selected entry, or switch to the selected instrument while he plays |
| Backspace | Stop the musician |
| G | Collect the tips. The prompt shows the current balance |
Guests, near playPos, while the musician plays:
| Key | Action |
|---|---|
| Left / Right | Browse tip amounts, or the instrument to request |
| E | Give the selected tip |
| G | Send the selected request |
A staff member standing at managePos sees the staff prompts only, not the guest prompts of the same saloon.
FAQ¶
The prompt does not show at the bar.
Three things have to be true: the character has one of the jobs in AllowedJobs of that saloon, the player stands within ManageDist of managePos, and the musician is not just arriving or leaving. The job is read from VORP a few seconds after the character is picked and again every time it changes, so a fresh job takes effect without a relog. If nothing shows at all, check the job name in VORP against the config, it has to match exactly.
Guests see no tip prompt.
Guest prompts need TipEnabled = true, at least one entry in TipAmounts, a playing musician and a player within TipDist of playPos. The request prompt also needs WishEnabled = true and more than one instrument on the list.
The piano is not in the list.
The saloon has no headingPiano. Without it the piano is hidden for that saloon on purpose, because the musician would sit in the void.
The fiddle is missing.
It is marked femaleOnly and the saloon's model is male. Use a female model or remove the flag, though the scenario is made for women.
The musician sits next to the piano or hangs in the air.
playPos and headingPiano have to match the real piano. Adjust them in small steps. The same goes for headingOther and the chair or bench the other scenarios use.
Where does the money go?
A tip is taken from the guest's cash and written to the jar of that saloon in hobbs_musicians_tips. The server checks that the musician is playing and that the amount is one of TipAmounts. Collecting pays the whole balance in cash to the staff member who presses G and sets the jar to zero. Nothing is created out of thin air, every dollar in the jar came from a guest.
Two staff members collect at the same time. Only one gets the money. The payout is locked per saloon and the balance is cleared in one step, so the second one sees "No tips available." and nobody gets paid twice.
Can somebody trigger the events from a modified client? The server checks the job for hiring, stopping and collecting, the amount and the playing musician for tips, and the instrument, the playing musician and the cooldown for requests. Anything that does not fit is dropped without a reply.
What happens on a restart? The musicians are removed, on the server and on the client that spawned them, and the active list is cleared. The tip balances stay in the database and are there after the restart. Staff hire the musician again.
Does it cost performance? One loop checks the distance to every saloon once per second while nobody is near, and ten times per second while someone stands at a prompt. The musician is a normal networked ped, there is one per saloon at most.
How do I add a saloon?
Copy one block in Config.npcs, add it at the end of the list, set the job, the model, the four positions and the headings, and restart the resource. The new row in the tip table is created at the start.
Changelog¶
2.0.1¶
First release.