Esc to clear, Enter to open the best match, click an export to open it in its page
whip_phone

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

WhatHow
The phone and sim_card itemswhip_phone's own, made with RegisterItem. A SIM card's number shows as 689-555-0142 (format = 'phone')
The SIM trayA 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 numberRegisterItemDefaultMetadata 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 phoneRegisterUseHandler returning false, so the phone isn't used up
The strip's Phone slotRegisterAccessorySlot holds slot 1 to phones while whip_phone runs, and whip_core puts its own slot back when it stops
A SIM leaving its holderwhip_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 player

whip_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 outwhip_core
Chat and prompts make way, and the HUD staysSetScreenOpen(true, 'phone', { keepHud = true })
The vehicle dial moves out of the phone's waySetScreenArea, with where the phone sits
Combat, looking round and the weapon wheel are held off, and Esc is the phone'sBlockControls with Config.BlockControls and controls 199 and 200
A drawn gun is put away firstFreeHands, which asks whip_gunny to holster it
The phone, or the tablet, in handPlayEmote with Config.Emotes. A player already in an emote is left as they are
A controller drives itWhip.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 wheelRegisterPadAction('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 keysIsGameInputFree
A death or a logout puts it awaywhip_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

Pictures, names and developer mode

Where to look#

To see how toRead
Register items, a panel item, a metadata generator and an accessory slotserver/items.lua
Work out what a player carries on every request, never trusting the pageserver/sim.lua: Sim.phoneOf, Sim.resolve
Answer an NUI page's requests with SecureCallbacksclient/main.lua: the 'request' callback; server/main.lua: PhoneSchema; server/contract.lua
Take the screen, the controls and the hands, and give them backclient/main.lua: setOpen, inHand
Read a controller for an NUI pageclient/main.lua: Whip.padScreen
Calls on a voice line, and an ask channelserver/calls.lua: openLine, RegisterAskChannel
Act as the player through whip_core's bank and jobsserver/bank.lua, server/business.lua
Director cards, and a developer commandserver/lore.lua
Skill check games of your ownshared/skillgames.lua, server/skillgames.lua, client/main.lua (RunApp)
Let other resources add to yours, each owning what it addedclient/main.lua: RegisterModule