Module cityrp.item

Shared item and item category library.

Module Overview

Shared Functions

cityrp.item.register(item[, base]) Register a new item.
cityrp.item.get(name) Get an item by its name.
cityrp.item.addCat(name, description, access) Add a new category.
cityrp.item.findCat(name) Retrieve a category.

Server Functions

cityrp.item.use(ply, item[, force]) Have a player use an item.
cityrp.item.remove(ply, item) Remove an item from a player (like a hat).
cityrp.item.drop(ply, item, amt[, pos]) Drops an item from a player.
cityrp.item.removemod(ply, item) Special function for removing a player's weapon mods on death.
cityrp.item.destroy(ply, item, amt) Destroys a player's item.
cityrp.item.pickup(ply, item) Pick up a player's vehicle
cityrp.item.sell(ply, item, amt) Sell a players item.
cityrp.item.spawn(class, item, pos, ply) Create an item entity and set the player.
cityrp.item.make(item, pos, ply) Makes an item at the specified position.
cityrp.item.placefood(item, pos, ply) Makes a food entity at the specified position.
cityrp.item.place(ply, item, amt[, pos]) Places an item (i.e.
cityrp.item.give(ply, item, amt, tObj) Give an item to a player.

Shared Functions

cityrp.item.register(item[, base])
Register a new item.

Parameters:

  • item tab The item table to register.
  • base string The uniqueID of the base item to take properties from. (optional)
cityrp.item.get(name)
Get an item by its name.

Parameters:

  • name string The name or unique ID of the item to get.

Returns:

    optional table The item table, or nil if not found.
cityrp.item.addCat(name, description, access)
Add a new category.

Parameters:

  • name string The name of the category to add.
  • description string The description of the category. Defaults to an empty string.
  • access string The access for the category, defaults to 'b'.

Returns:

    number The category index.
cityrp.item.findCat(name)
Retrieve a category.

Parameters:

  • name string Name of the category to find.

Returns:

    table Category data.

Server Functions

cityrp.item.use(ply, item[, force])
Have a player use an item.

Parameters:

  • ply Player The player using an item.
  • item string The item index.
  • force bool Ignore item cooldown. (optional)

Returns:

    boolean Success.
cityrp.item.remove(ply, item)
Remove an item from a player (like a hat).

Parameters:

  • ply Player The player to remove the item from.
  • item string The item index.

Returns:

    boolean Success.
cityrp.item.drop(ply, item, amt[, pos])
Drops an item from a player.

Parameters:

  • ply Player The player to remove the item from.
  • item string The item index.
  • amt number The number of items to drop.
  • pos Vector The position to make the items. (optional)

Returns:

    boolean Success.
cityrp.item.removemod(ply, item)
Special function for removing a player's weapon mods on death. Added this because the other functions had bugs.

Parameters:

  • ply Player The player to remove the item from.
  • item string The item ID to remove.

Returns:

    boolean Success.
cityrp.item.destroy(ply, item, amt)
Destroys a player's item.

Parameters:

  • ply Player The player to remove the item from.
  • item string The item ID to remove.
  • amt number The number of the item to destroy.

Returns:

    boolean Success.
cityrp.item.pickup(ply, item)
Pick up a player's vehicle

Parameters:

  • ply Player The player to pickup.
  • item string The item ID to pickup.

Returns:

    boolean Success.
cityrp.item.sell(ply, item, amt)
Sell a players item.

Parameters:

  • ply Player The player to sell the item from.
  • item string The item ID to sell.
  • amt number The number of items to sell.

Returns:

    boolean Success.
cityrp.item.spawn(class, item, pos, ply)
Create an item entity and set the player.

Parameters:

  • class string The entity class to spawn.
  • item string The item ID to create.
  • pos Vector The position to make the item at.
  • ply Player The player who owns the item.

Returns:

    Entity or boolean Entity created or false.
cityrp.item.make(item, pos, ply)
Makes an item at the specified position.

Parameters:

  • item string The item ID to create.
  • pos Vector The position to make the item at.
  • ply Player The player who owns the item.

Returns:

    Entity or boolean Entity created or false.
cityrp.item.placefood(item, pos, ply)
Makes a food entity at the specified position.

Parameters:

  • item string The item ID to create.
  • pos Vector The position to make the item at.
  • ply Player The player who owns the item.

Returns:

    Entity or boolean Entity created or false.
cityrp.item.place(ply, item, amt[, pos])
Places an item (i.e. food)

Parameters:

  • ply Player The player to sell the item from.
  • item string The item ID to sell.
  • amt number The number of items to place.
  • pos Vector The position to place the items. (optional)

Returns:

    boolean Success.
cityrp.item.give(ply, item, amt, tObj)
Give an item to a player.

Parameters:

  • ply Player The player giving the item.
  • item string The itemID.
  • amt number The number of items to give.
  • tObj Player The player being given to.

Returns:

    boolean Success.