cityrp.interaction
Interactions are a configurable menu that can appear on any entity when a user holds use on it.
If an entity has normal use functionality, behaviour will be modified to the following: Hold E: Show interaction menu Tap E: Regular entity use functionality Don't register interactions in this file, do it in some plugin or something. Data structure for an interaction looks like the following, everything is required unless otherwise stated: data = {
id = "Interaction ID", -- The id of the interaction, must be unique for the given class
name = "Interaction Name", -- The name of the interaction
description = "Interaction Description", -- The description of the interaction
condition = function(client, ent) -- The condition to check if the interaction should be shown, do context dependent checks here
return true -- True if the interaction should be shown, false if not
end,
action = function(client, ent) -- The action to perform when the interaction is clicked
print("Clicked!")
end
}
Functions
cityrp.interaction.Get(string, id)
View source »Gets an interaction by entity and id
Parameters
-
string
The entity class to get the interaction from
-
id
The id of the interaction
Returns
-
table
The interaction
cityrp.interaction.GetAllByClass(string)
View source »Gets all interactions by entity
Parameters
-
string
The entity class to get the interactions fromn
Returns
-
table
All interactions for this entity
cityrp.interaction.Has(entity)
View source »Checks if an entity has any interactions
Parameters
-
entity
The entity to check for interactions
Returns
-
boolean
If there is an interacton or not
cityrp.interaction.Register(string, id, data)
View source »Register an interaction
Parameters
-
string
The entity class to register the interaction on
-
id
The id of the interaction
-
data
The data of the interaction
cityrp.interaction.Start(client, entity)
View source »Start the interaction menu on an entity, this will also start the menu on the client. This is intended to be used after a player succesfully indicates they wish to see the interaction menu on an entity.
Parameters
-
client
Player who is calling the interaction menu
-
entity
Entity call the interaction menu on
cityrp.interaction.Use(client, id, entity)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Use an interaction on an entity
Parameters
-
client
Player who is using the interaction
-
id
The id of the interaction
-
entity
Entity to use the interaction on
Fields
cityrp.interaction
View source »Create the initial table for interactions