OPX//77
opx_infinitydealership

Events

Last updated on

Network, local and host-wide events of the dealership module.

opx:net:dealership:ask

Client → server. Ask for the dealers of the caller's bucket and the stock. Sent at start and every POLL_MS. One per player per second is answered.

TriggerServerEvent('opx:net:dealership:ask')

opx:net:dealership:sync

Server → client. Dealers of the bucket.

RegisterNetEvent('opx:net:dealership:sync', function(payload) end)
  • payload: table — { spots }, each key, label, kind, x, y, z, heading, bucket

opx:net:dealership:stock

Server → client. Stock per kind.

RegisterNetEvent('opx:net:dealership:stock', function(payload) end)
  • payload: table — { kinds = { garage = rows, avpad = rows } }
    • each row key, label, class, price, text (text: the formatted price)

opx:net:dealership:buy

Client → server. Buy. Cooldown COOLDOWN_MS plus the request window.

TriggerServerEvent('opx:net:dealership:buy', dealerKey, entryKey, garageKey)
  • dealerKey: string
  • entryKey: string
  • garageKey?: string

opx:net:dealership:answer

Server → client. Verdict of a buy or an accepted offer.

RegisterNetEvent('opx:net:dealership:answer', function(ok, error, entryKey, value) end)
  • ok: boolean
  • error?: string
  • entryKey?: string
  • value?: table — the Buy value

opx:net:dealership:offer

Client → server. A salesperson offers a car to a player.

TriggerServerEvent('opx:net:dealership:offer', buyerId, entryKey)
  • buyerId: integer
  • entryKey: string

opx:net:dealership:offered

Server → client. Sent to the buyer: the offer to answer.

RegisterNetEvent('opx:net:dealership:offered', function(offer) end)
  • offer: table — { token, entry, model, price, text, dealer, label, kind, timeoutMs }
    • no seller since PR #93 (it carried the seller's account name); text is the price formatted with OPX.Locale.Money
    • kind: the dealer's kind, so the buyer's screen lists only garages a vehicle of that kind may be filed under.

opx:net:dealership:decide

Client → server. The buyer's answer.

TriggerServerEvent('opx:net:dealership:decide', token, yes, destKey)
  • token: number
  • yes: boolean
  • destKey?: string — the buyer's garage; only sent with a yes.

opx:net:dealership:settled

Server → client. Sent to the seller: what became of the offer. A refused acceptance is reported too.

RegisterNetEvent('opx:net:dealership:settled', function(result) end)
  • result: table — { ok, error?, entry, model?, cut?, company?, banked? }

opx:net:dealership:withdrawn

Server → client. Sent to the buyer: the offer ended without their answer (it expired, or the seller left). The client closes the offer screen if token is the offer on it.

RegisterNetEvent('opx:net:dealership:withdrawn', function(payload) end)
  • payload: table — { token, error }
    • error: 'dealership.offerExpired' or 'dealership.sellerGone'

opx:on:dealership:sold

Server, host-wide. A sale went through. Every server resource hears it; see Public server events.

AddEventHandler('opx:on:dealership:sold', function(playerId, payload) end)
  • playerId: integer
  • payload: table
    • Counter sale: { kind = 'counter', citizenId, plate, entry, record, dealer, garage, price, currency }
    • Player-to-player: { kind = 'offer', citizenId, plate, entry, record, dealer, garage, price, currency, seller, sellerCitizenId, company, commission, banked, pending }
      • garage: the buyer's chosen garage, nil for the default.
      • pending: true when the company share went to the opx77_company_pending ledger instead of the account.

opx:on:dealership:decision

Client, local. Every verdict, local refusals included. Only handlers inside opx_infinity's client hear it.

AddEventHandler('opx:on:dealership:decision', function(decision) end)
  • decision: table — { ok, error?, entry?, plate?, model?, dealer?, garage?, price?, queued?, commission?, banked?, source }
    • source: key, server, client, target, offer, sale or the caller's origin.
    • withdrawn: true when the offer was withdrawn by the server.

On this page