Defines the cw.dermaRequest library, which lets the server show a player a Derma text prompt, confirmation query or message box and receive the answer.

cw.dermaRequest:RequestString and cw.dermaRequest:RequestConfirmation take a callback that runs on the server once the client answers over the dermaRequestCallback message.

Summary

Methods

Returns a new request ID.
Shows a player a Derma message box.
Asks a player to confirm or cancel in a Derma query window.
Asks a player to type a string into a Derma text prompt.
Send(id, recv)client internal
Sends the answer to a Derma request back to the server.
Validate(player, data)server internal
Returns whether a request answer from a client is valid.

Methods

Returns a new request ID.

IDs are the current Unix time plus a counter that increases with every call.

Returns

  • Number The request ID

cw.dermaRequest:Message(player, message, title, button)

server gamemodes/catwork/gamemode/core/libraries/sh_dermarequest.lua:100

Shows a player a Derma message box.

Parameters

  • player Player The player to show the message to
  • message String Message text
  • title String optional, defaults to nil Window title
  • button String optional, defaults to nil Text of the close button

cw.dermaRequest:RequestConfirmation(player, title, question, Callback)

server gamemodes/catwork/gamemode/core/libraries/sh_dermarequest.lua:86

Asks a player to confirm or cancel in a Derma query window.

The client answers true for confirm and false for cancel, but cw.dermaRequest:Validate rejects falsy answers, so the callback only runs when the player confirms.

Parameters

  • player Player The player to ask
  • title String Window title
  • question String Question shown in the window
  • Callback Function Called with true when the player confirms

See also

cw.dermaRequest:RequestString(player, title, question, default, Callback)

server gamemodes/catwork/gamemode/core/libraries/sh_dermarequest.lua:67

Asks a player to type a string into a Derma text prompt.

The callback runs when the player submits the prompt; closing the prompt drops the request.

cw.dermaRequest:RequestString(
  player,
  '#Command_Charphysdesc_RequestTitle',
  '#Command_Charphysdesc_RequestText',
  player:GetDTString(STRING_PHYSDESC),
  function(result)
    player:RunClockworkCmd(self.name, result)
  end
)

Parameters

  • player Player The player to ask
  • title String Window title
  • question String Text shown above the input box
  • default String Text the input box starts with
  • Callback Function Called with the entered String

See also

cw.dermaRequest:Send(id, recv)

client internal gamemodes/catwork/gamemode/core/libraries/sh_dermarequest.lua:151

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the Derma request receivers.

Sends the answer to a Derma request back to the server.

Parameters

  • id Number The request ID received from the server
  • recv Any The answer: the entered String or the confirmation Boolean

cw.dermaRequest:Validate(player, data)

server internal gamemodes/catwork/gamemode/core/libraries/sh_dermarequest.lua:113

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the dermaRequestCallback Cable receiver.

Returns whether a request answer from a client is valid.

The answer must name a pending request that was sent to the same player and carry the kind of recv value that request expects: a string for a text prompt, true for a confirmation.

Parameters

  • player Player The player who sent the answer
  • data Map The answer, with id and recv keys

Returns

  • Boolean Whether the answer is valid

Defined in