CityRP Documentation Repository

cityrp.legacy.functions

Generic shared legacy functions.

Functions

Servercityrp.GetByID(id) → boolean|PlayerSource ☍

Get a user by their user ID.

Parameters

  • idnumberThe UserID to search for.

Returns

  1. boolean|PlayerThe found player, or false if none was found.
Servercityrp.replacecodes(ply, str) → stringSource ☍

Replace player substitution codes in a string.

Parameters

  • plyPlayer?The player to get data from.
  • strstringThe string to replace codes in.

Returns

  1. stringThe string with codes replaced.
Servercityrp.toBoolean(value) → boolean?Source ☍

Parse a value into a boolean. Unlike GMod's tobool, unrecognized strings return nil instead of true.

Parameters

  • valueanyValue to parse.

Returns

  1. boolean?Parsed boolean, or nil if unrecognized.
Servercomma_value(amount) → stringSource ☍

Create a comma'd value from a number. Identical to string.Comma.

Parameters

  • amountnumberThe input number.

Returns

  1. stringThe comma'd value.
Serverempty(t) → booleanSource ☍

Check if a table is empty.

Parameters

  • ttableThe table to check.

Returns

  1. booleanWhether the table is empty.
ServerFixVehicleCollision(vehicle)Source ☍

Fix the collisions of a vehicle.

Parameters

  • vehicleEntityThe vehicle to fix collisions for.
ServerFormatList(tList, sConjunction, sEmpty) → stringSource ☍

Format a list as a string. Seperates the last item with "and" (or "or"), using commas otherwise. If there is only one item, it returns just that item.

Parameters

  • tListtableInput list to format.
  • sConjunctionstring?Word to separate the last item with, defaults to "and".
  • sEmptystring?Value to return if the list is empty, defaults to "".

Returns

  1. stringFormatted string.
ServerIsInsideBox(pos, point1, point2) → booleanSource ☍

Check if a point is inside a box defined by two corners.

Parameters

  • posVectorThe position to check.
  • point1VectorFirst corner of the box.
  • point2VectorThe opposite corner of the box.

Returns

  1. booleanWhether the pos is inside the box.
ServerLookupEnum(value, prefix) → stringSource ☍

Lookup an enumeration, given its prefix and value.

Parameters

  • valueanyThe value of the enumeration.
  • prefixstringThe prefix of the global to look up.

Returns

  1. stringThe key of the found enum, or an empty string if not found.
Servermsg_admins(msg)Source ☍

Send a message to all connected admins.

Parameters

  • msgstringThe message to send.
Servermsg_devs(msg)Source ☍

Send a message to all connected developers.

Parameters

  • msgstringThe message to send.
Servermsg_mods(msg)Source ☍

Send a message to all connected moderators / admins.

Parameters

  • msgstringThe message to send.
Servermysql_escape(str) → stringSource ☍

Escape a string, for use in mysql statements.

Parameters

  • strstringInput string.

Returns

  1. stringEscaped string.
ServerSetClipboardText(ply, text)Source ☍

Set a player's clipboard text.

Parameters

  • plyPlayerThe player whose clipboard text is to be set.
  • textstringThe text to set.
ServerstringTimeToMins(str) → number?Source ☍

Turn a time string into a number of minutes. Strings with only a number are counted as minutes.

Parameters

  • strstringThe input time string.

Returns

  1. number?Number of minutes, or nil if the string could not be parsed or totals less than zero.
Servertable.copy(orig) → <T>Source ☍

Create a deep copy of a value, including metatables for tables.

Parameters

  • orig<T>The value to copy.

Returns

  1. <T>A deep copy of orig.
Servertable.FullCopy(tab) → table?Source ☍

Create a deep copy of a table, copying vectors and angles by value. table.Copy and table.copy both leave userdata as references, so a copy made with either still shares its vectors and angles with the original. That matters for anything that mutates them in place, which is why the SWEP Construction Kit weapons each used to carry their own version of this. Entities are still copied by reference. Do not use on a table that contains itself, it will recurse forever.

Parameters

  • tabtable?The table to copy.

Returns

  1. table?The copied table, or nil if no table was given.