The phone and WHIP
whip_phone is a satellite. It builds the phone from whip_core's exports, as your resource would, and keeps only what is the phone's own, the numbers, contacts, texts, calls and block lists, in its own tables. Everything else, from the items in your pockets to the money in the Bank app, is whip_core's and follows whip_core's rules.
Each part below names the whip_core system it uses, so you know where to look when something about the phone changes, and how to build something like it. Its registrations are in Whip.register, so they come back after a whip_core restart.
The phone and the SIM are items
| What | How |
|---|---|
The phone and sim_card items | whip_phone's own, made with RegisterItem. A SIM card's number shows as 689-555-0142 (format = 'phone') |
| The SIM tray | A panel item (RegisterPanelItem) with one slot that takes SIM cards. The card is kept in the phone's metadata, so a SIM goes where its phone goes. A change refreshes an open phone, and a call on the number that left ends |
| A SIM's number | RegisterItemDefaultMetadata with forBuyer. whip_core tells the generator who the card is for, so a SIM bought or given is a new number of theirs, and one made for nobody is blank |
| Use opens that phone | RegisterUseHandler returning false, so the phone isn't used up |
| The strip's Phone slot | RegisterAccessorySlot holds slot 1 to phones while whip_phone runs, and whip_core puts its own slot back when it stops |
| A SIM leaving its holder | whip_core:inventory:changed: any change to their pockets checks their call again |
Every request is a SecureCallback
An app never names its number or reaches the database. Its request goes through the phone's page and whip_phone's client to a whip_core SecureCallback, and the server works out the phone and SIM again from what the player carries. So rate limits, the player and refusals (return false, 'why') are whip_core's, and someone who takes your SIM is your number from their next request.
app.request('send', { number, text }) the app, in the phone's page
→ whip_phone's client: the NUI callback 'request' only names under whip_phone: or an app's own
→ Whip.core:Callback('whip_phone:messages:send', args)
→ SecureCallback('whip_phone:messages:send', ...) the server, with the playerwhip_core hands a handler only the params its schema names, so every phone callback names one, args of type 'any', and checks each field it reads. Your app's callbacks do the same (Phone apps).
The screen, the hands and the controls
| While the phone is out | whip_core |
|---|---|
| Chat and prompts make way, and the HUD stays | SetScreenOpen(true, 'phone', { keepHud = true }) |
| The vehicle dial moves out of the phone's way | SetScreenArea, with where the phone sits |
| Combat, looking round and the weapon wheel are held off, and Esc is the phone's | BlockControls with Config.BlockControls and controls 199 and 200 |
| A drawn gun is put away first | FreeHands, which asks whip_gunny to holster it |
| The phone, or the tablet, in hand | PlayEmote with Config.Emotes. A player already in an emote is left as they are |
| A controller drives it | Whip.padScreen reads the pad and hands the page its buttons, since FiveM's browser can't read a gamepad |
| D-pad up, and Phone on the wheel | RegisterPadAction('phone'); AddAction with at = { radial = true } and require = { item = 'phone' }, so only a player carrying one sees it |
| F3 does nothing while chat or another screen has the keys | IsGameInputFree |
| A death or a logout puts it away | whip_core:player:died, whip_core:player:logout |
Calls are voice lines
whip_phone plays no call audio itself. Answering opens a voice line with Whip.voice('OpenLine', …) on whichever voice system runs, with Config.CallSound as its sound and Config.SpeakerRange for speaker. Mute and speaker are the line's SetLineMuted and SetLineSpeaker, and hanging up closes it. While Whip.voiceSystem() is nil, dialling is refused and every phone shows Config.VoiceDownText until whip_core:voice:systemChanged says one is back.
The call volume slider is the player setting voice.callVolume, read and changed with SetPlayerSetting, which is why the phone and the pause menu change the same value.
Bank and Business are whip_core's
The Bank app calls whip_core's bank exports with the player as the one acting, so the bank's rules apply as they do anywhere: a transfer needs withdraw access, only an account's owner closes it, and Config.MaxExtraAccounts caps savings and shared accounts. The Business app calls the job exports with the player as by, so ranks and their permissions decide who hires, fires and promotes. Both act as the character holding the phone, and update live from whip_core:bank:balanceChanged and the whip_core:job:* events.
The nearby list for sharing and hiring shows names by CanSeePlayerName, and anyone else is picked by character ID. An invite is checked against the bank's or the job's rules again when it's accepted.
whip_core's questions ring on the phone
whip_phone registers the 'phone' ask channel. A yes or no question whip_core asks on it, such as the Director's job invite, shows on the player's phone with Decline and Accept when they carry a phone, the Phone app is installed and voice runs. Otherwise whip_core asks on screen. The answer goes back with AnswerAsk, and a question whip_core gives up on comes down off the phone.
The Director
- Lore characters. Each one (
GetLoreCharacters) gets a number, kept up to date bywhip_core:lore:changed. - Cards. Give Contact, Send Text and Phone Call are whip_phone's
Whip.cardcards, in the Lore group. Phone Call plays its recording through the voice bot,Whip.voice('CreateVoiceBot', …), and in a builder's Test it rings only the builder. - Skill check games. The seven games are
Whip.skillCheckGameregistrations, soSkillCheckand the Skill Check card offer them. Each one'scanStartrefuses a player with no phone, and the phone plays it withRunApp.
Pictures, names and developer mode
- A contact card's picture passes
CheckPicture, so it takes the same sites as a lore character's (Picture links accepted in/whip→ Settings → Config → Server). - Names on the phone are the characters' (
GetCharacterNames), so a rename reaches it. - The Skill Check Tester shows only with developer mode on:
HasDevToolsandwhip_core:devtools:modeChangedon the client, andHasDevToolsagain on the server for every request it makes./lorecallis aWhip.commandwithdev = true. /whip→ Phones is whip_core's panel. It edits whip_phone's tables by number, then tells whip_phone to read them again, which refreshes every open phone.
Where to look#
| To see how to | Read |
|---|---|
| Register items, a panel item, a metadata generator and an accessory slot | server/items.lua |
| Work out what a player carries on every request, never trusting the page | server/sim.lua: Sim.phoneOf, Sim.resolve |
| Answer an NUI page's requests with SecureCallbacks | client/main.lua: the 'request' callback; server/main.lua: PhoneSchema; server/contract.lua |
| Take the screen, the controls and the hands, and give them back | client/main.lua: setOpen, inHand |
| Read a controller for an NUI page | client/main.lua: Whip.padScreen |
| Calls on a voice line, and an ask channel | server/calls.lua: openLine, RegisterAskChannel |
| Act as the player through whip_core's bank and jobs | server/bank.lua, server/business.lua |
| Director cards, and a developer command | server/lore.lua |
| Skill check games of your own | shared/skillgames.lua, server/skillgames.lua, client/main.lua (RunApp) |
| Let other resources add to yours, each owning what it added | client/main.lua: RegisterModule |