Esc to clear, Enter to open the best match, click an export to open it in its page
Building on WHIP
Testing and performance
Tools for trying your resource before players do, and for measuring what it costs on the player's game and the server.
Testing
| To test | Use |
|---|---|
| Your inventory screen, without the game | node whip_core/dev/inventory-preview/preview.js my_inventory_ui runs it in Chrome with sample scenes (the renderer seat) |
| A Director card or scenario | TestDirectorCard(type, props, { player = source }), TestDirectorScenario (Director cards) |
| Something done to another player, alone | Pass { charId = n } for a second character of yours, then log in as them to see it |
| Two players at once | Two FiveM clients on one PC, same account, different characters. Turn off Config.BlockOwnCharacterTransfers on a test server to move money between them |
| Dying, healing, a broken car | /w → Kill Me, Restore Player Cores, Repair Vehicle (Dev Tools) |
| What your events did | /whip → System → Monitor: each SecureEvent call, the reason for a refusal, and how long your handler took |
| Errors you missed | whiperrors in the server console (F8 in developer mode); GetErrorLog in code |
Measuring#
| Where | Tool | Tells you |
|---|---|---|
| Player's game | /whipcost (developer mode) | Microseconds per frame for each timed section, and each resource's memory. Time your own loops with WhipCost.start() / WhipCost.stop('my loop', t) (client_script '@whip_core/lib/cost.lua'), never with a Wait between them |
| Player's game | MeasureFrames({ seconds }) | FPS, the worst 1%, and frames over 33 and 50 ms: compare with your resource started and stopped |
| Server | whipcost [seconds] in the console | The same for server sections marked with WhipCost (server_script '@whip_core/lib/cost.lua'), by CPU time |
| Server | /whip → System → Monitor | How long each SecureEvent and SecureCallback handler took, database waits included |
| Either | profiler record 500, then profiler view | Every resource's time per frame in Chrome's performance view. With setr whip_profiling 1, whip_core's handlers are named by event. Captures inflate costs about five times: compare captures, not budgets |
The usual cost is a loop running every frame (Wait(0)). Wait on an event instead, and check the loops you must keep with /whipcost.
What an export costs#
Cheapest first. Call the first two as often as you need; the rest when something happens, never every frame.
| Cost | For example | Means |
|---|---|---|
| Memory | HasItem, GetItemCount, IsPlayerClockedOn, GetPlayerJob, GetBalance after its first read | Microseconds |
| A copy | GetPlayer, GetVehicle, StoreRead | From memory, but the table is serialised on its way to you. Keep what you need rather than re-reading every frame |
| Sends to a game | NotifyPlayer, ShowBlip, ShowPlayerText, SetPlayerMetadata | Network traffic: fine per action, wrong in a loop over every player |
| Waits on the database | Ensure*, bank reads, ChargePlayer, PayPlayer, AddItem, SetVehicleData | Marked WAITS: milliseconds. Call from a thread or handler, and re-read after |
| Waits on the other side or the player | Server Progress, SkillCheck; client Callback, ResolveVehicle, Input | WAITS too: a round trip (200 ms at 200 ms ping), or as long as the player takes |