Event Encryption API 1. Instructions 2. Events 2.1 Register a client event 2.2 Trigger a client event 2.3 Register a server event 2.3 Trigger a server event 3. Callbacks 3.1 Register a client callback 3.2 Trigger a client callback 3.3 Register a server callback 3.3 Trigger a server callback
Menu API 1. Instructions 2. Configuration 3. Menu 3.1 Create a menu 3.2 Delete a menu 3.3 Open a menu 3.4 Close a menu 3.5 Toggle a menu 4. Items 4.1 Colorinput 4.2 Dropdown 4.3 Execute 4.4 Inputfield 4.5 Spacer 4.6 Submenu 4.7 Toggle 5. Features 5.1 Delete an item 5.2 Check existance 5.3 Get value 5.4 Set value 5.5 Set title 5.6 Toggle an item 6. External features 6.1 Colorpalette 6.2 Inputfield 6.3 Play sound
CarFX
Event Encryption API
1. Instructions
With the Event Encryption API you prevent cheaters from abusing events of other scripts. This script encrypts the communication done by event. Event \"crawlers\", like Eulen for example, will no longer show the events in their list. Further all data will be unreadable in the event log. Cheaters will no longer be able to find events or understand them in order to edit and use them for their advantage.
2. Events
Events can be used to trigger code on or transmit data to the opposite side (on a server / client environment).
2.1 Register a client event
An event has to be registered in order for your code to be "notified" when it has been triggered.
lua
AddEventHandler("EVENTNAME", function(data)
--data = string sent when triggering the event
end)
javascript
on("EVENTNAME", (data) => {
//data = string sent when triggering the event
});
Explaination
EVENTNAME
The name or identifier of the event.
data
The received data.
2.2 Trigger a client event
Use this on the server side to trigger a event registered on the client side.
lua
exports["pc_eventencryption"]:send("EVENTNAME", playerId, "send data")
javascript
exports["pc_eventencryption"]["send"]("EVENTNAME", playerId, "send data");
Explaination
EVENTNAME
The name or identifier of the event.
playerId
The player ID of the player to trigger the event on (-1 for all players).
send data
The data to send.
2.3 Register a server event
An event has to be registered in order for your code to be "notified" when it has been triggered.
lua
AddEventHandler("EVENTNAME", function(playerId, data)
--data = string sent when triggering the event
end)
javascript
on("EVENTNAME", (playerId, data) => {
//data = string sent when triggering the event
});
Explaination
EVENTNAME
The name or identifier of the event.
playerId
The player ID of the player that has triggered the event.
data
The received data.
2.4 Trigger a server event
Use this on the client side to trigger an event registered on the server side.
lua
exports["pc_eventencryption"]:send("EVENTNAME", "send data")
javascript
exports["pc_eventencryption"]["send"]("EVENTNAME", "send data");
Explaination
EVENTNAME
The name or identifier of the event.
send data
The data to send.
3. Callbacks
Callbacks can be used to gather information or check the result of a request (for example if a command was successful or returned an error).
3.1 Register a client callback
A callback has to be registered in order for your code to be \"notified\" when it has been triggered.
lua
AddEventHandler("EVENTNAME", function(data, cb)
--data = string sent when triggering the event
--cb = function for callback, can only be called once
cb("send data back")
end)
javascript
on("EVENTNAME", (data, cb) => {
//data = string sent when triggering the event
//cb = function for callback, can only be called once
cb("send data back");
});
Explaination
EVENTNAME
The name or identifier of the event.
data
The received data.
cb
The function that can be called to return data. This can only be called once.
3.2 Trigger a client callback
Use this on the server side to trigger a callback registered on the client side.
lua
exports["pc_eventencryption"]:sendCb("EVENTNAME", playerId, "send data", function(data)
--data = data returned via callback function
end)
javascript
exports["pc_eventencryption"]["sendCb"]("EVENTNAME", playerId, "send data", (data) => {
//data = data returned via callback function
});
Explaination
EVENTNAME
The name or identifier of the event.
playerId
The player ID of the player to trigger the event on.
send data
The data to send.
data
The received data.
3.3 Register a server callback
A callback has to be registered in order for your code to be \"notified\" when it has been triggered.
lua
AddEventHandler("EVENTNAME", function(playerId, data, cb)
--data = string sent when triggering the event
--cb = function for callback, can only be called once
cb("send data back")
end)
javascript
on("EVENTNAME", (playerId, data, cb) => {
//data = string sent when triggering the event
//cb = function for callback, can only be called once
cb("send data back");
});
Explaination
EVENTNAME
The name or identifier of the event.
playerId
The player ID of the player that has triggered the event.
data
The received data.
cb
The function that can be called to return data. This can only be called once.
3.4 Trigger a server callback
Use this on the client side to trigger a callback registered on the server side.
lua
exports["pc_eventencryption"]:sendCb("EVENTNAME", "send data", function(data)
--data = data returned via callback function
end)
javascript
exports["pc_eventencryption"]["sendCb"]("EVENTNAME", "send data", (data) => {
//data = data returned via callback function
});
Explaination
EVENTNAME
The name or identifier of the event.
send data
The data to send.
data
The received data.
1. Instructions
With the Event Encryption API you prevent cheaters from abusing events of other scripts. This script encrypts the communication done by event. Event \"crawlers\", like Eulen for example, will no longer show the events in their list. Further all data will be unreadable in the event log. Cheaters will no longer be able to find events or understand them in order to edit and use them for their advantage.
2. Events
Events can be used to trigger code on or transmit data to the opposite side (on a server / client environment).
2.1 Register a client event
An event has to be registered in order for your code to be "notified" when it has been triggered.
AddEventHandler("EVENTNAME", function(data)
--data = string sent when triggering the event
end)
on("EVENTNAME", (data) => {
//data = string sent when triggering the event
});
Explaination
The name or identifier of the event.
The received data.
2.2 Trigger a client event
Use this on the server side to trigger a event registered on the client side.
exports["pc_eventencryption"]:send("EVENTNAME", playerId, "send data")
exports["pc_eventencryption"]["send"]("EVENTNAME", playerId, "send data");
Explaination
The name or identifier of the event.
The player ID of the player to trigger the event on (-1 for all players).
The data to send.
2.3 Register a server event
An event has to be registered in order for your code to be "notified" when it has been triggered.
AddEventHandler("EVENTNAME", function(playerId, data)
--data = string sent when triggering the event
end)
on("EVENTNAME", (playerId, data) => {
//data = string sent when triggering the event
});
Explaination
The name or identifier of the event.
The player ID of the player that has triggered the event.
The received data.
2.4 Trigger a server event
Use this on the client side to trigger an event registered on the server side.
exports["pc_eventencryption"]:send("EVENTNAME", "send data")
exports["pc_eventencryption"]["send"]("EVENTNAME", "send data");
Explaination
The name or identifier of the event.
The data to send.
3. Callbacks
Callbacks can be used to gather information or check the result of a request (for example if a command was successful or returned an error).
3.1 Register a client callback
A callback has to be registered in order for your code to be \"notified\" when it has been triggered.
AddEventHandler("EVENTNAME", function(data, cb)
--data = string sent when triggering the event
--cb = function for callback, can only be called once
cb("send data back")
end)
on("EVENTNAME", (data, cb) => {
//data = string sent when triggering the event
//cb = function for callback, can only be called once
cb("send data back");
});
Explaination
The name or identifier of the event.
The received data.
The function that can be called to return data. This can only be called once.
3.2 Trigger a client callback
Use this on the server side to trigger a callback registered on the client side.
exports["pc_eventencryption"]:sendCb("EVENTNAME", playerId, "send data", function(data)
--data = data returned via callback function
end)
exports["pc_eventencryption"]["sendCb"]("EVENTNAME", playerId, "send data", (data) => {
//data = data returned via callback function
});
Explaination
The name or identifier of the event.
The player ID of the player to trigger the event on.
The data to send.
The received data.
3.3 Register a server callback
A callback has to be registered in order for your code to be \"notified\" when it has been triggered.
AddEventHandler("EVENTNAME", function(playerId, data, cb)
--data = string sent when triggering the event
--cb = function for callback, can only be called once
cb("send data back")
end)
on("EVENTNAME", (playerId, data, cb) => {
//data = string sent when triggering the event
//cb = function for callback, can only be called once
cb("send data back");
});
Explaination
The name or identifier of the event.
The player ID of the player that has triggered the event.
The received data.
The function that can be called to return data. This can only be called once.
3.4 Trigger a server callback
Use this on the client side to trigger a callback registered on the server side.
exports["pc_eventencryption"]:sendCb("EVENTNAME", "send data", function(data)
--data = data returned via callback function
end)
exports["pc_eventencryption"]["sendCb"]("EVENTNAME", "send data", (data) => {
//data = data returned via callback function
});
Explaination
The name or identifier of the event.
The data to send.
The received data.
Menu API
1. Instructions
This Menu API allows your scripts to build native UI menus in seconds. No need to run any loop within your script, the Menu API does it all.
2. Configuration
config_primaryColor = {0, 25, 150, 200}
config_secondaryColor = {0, 20, 0, 200}
config_textColor = {255, 255, 255, 255}
config_menuPosition = {0.88, 0.15}
config_maxItemsPerPage = 10
Explaination
The color of the title bar and selected item
The color of the background of the menu
The text color
The menu position from 0 to 1 (first x, then y)
Maximum amount of items shown at a time
3. Menu
A menu is basically a container for the options the user can interact with. You can create and manage multiple menus within one single script.
3.1 Create a menu
First you have to create a menu.
exports["pc_menuapi"]:createMenu("MENUNAME", "TITLE", --[[ cb_exit ]] function()
-- this function is called when the user exits the menu
end)
exports["pc_menuapi"]["createMenu"]("MENUNAME", "TITLE", /* cb_exit */ () => {
// this function is called when the user exits the menu
});
Explaination
The name or identifier of the menu.
The name of the menu, visible to the user.
A function called when the user has closed the menu. This is optional.
3.2 Delete a menu
Deleting a menu does also delete all items in it.
exports["pc_menuapi"]:deleteMenu("MENUNAME")
exports["pc_menuapi"]["deleteMenu"]("MENUNAME");
Explaination
The name or identifier of the menu.
3.3 Open a menu
This makes sure a menu is displayed.
exports["pc_menuapi"]:openMenu("MENUNAME", true --[[ canMove ]], true --[[ canExit ]])
exports["pc_menuapi"]["openMenu"]("MENUNAME", true /* canMove */, true /* canExit */);
Explaination
The name or identifier of the menu.
Defines if a user can move around whilst the menu is open.
Defines if a user can close the menu.
3.4 Close a menu
This makes sure a menu is closed.
exports["pc_menuapi"]:closeMenu("MENUNAME")
exports["pc_menuapi"]["closeMenu"]("MENUNAME");
Explaination
The name or identifier of the menu.
3.5 Toggle a menu
This opens a menu if it is currently closed or viceversa.
exports["pc_menuapi"]:toggleMenu("MENUNAME", true --[[ canMove ]], true --[[ canExit ]])
exports["pc_menuapi"]["toggleMenu"]("MENUNAME", true /* canMove */, true /* canExit */);
Explaination
The name or identifier of the menu.
Defines if a user can move around whilst the menu is open.
Defines if a user can close the menu.
4. Items
Features allow your script to gain more control over an existing menu.
4.1 Colorinput
A colorinput allows the user to pick a color from the RGB-spectrum. It will be returned as RGB and HEX.
exports["pc_menuapi"]:createColorinput("MENUNAME", "NAME", "PARENTNAME", "TITLE", {r, g, b} --[[ default value ]], function() --[[ cb_hover ]]
-- this function is called when the user hovers over this item
end, function(newValue) --[[ cb_enter ]]
-- this function is called when the user selects this item
end, function() --[[ cb_exit ]]
-- this function is called when the user closes the color palette
end)
exports["pc_menuapi"]["createColorinput"]("MENUNAME", "NAME", "PARENTNAME", "TITLE", [r, g, b] /* default value */, () /* cb_hover */ => {
// this function is called when the user hovers over this item
}, (newValue) /* cb_enter */ => {
// this function is called when the user selects this item
}, () /* cb_exit */ => {
// this function is called when the user closes the color palette
});
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The name or identifier of the parent.
The name of the menu, visible to the user.
The default color to display. This has to be RGB.
The first function is called when the user hovers over this item.
The second function is called when the user moves the color picker.
The color selected by the user in this format:
{{r, g, b}, "#hex"}The third function is called when the user closes the colorpicker.
4.2 Dropdown
This is not really a dropdown, but it lets the user select one option and returns the index.
exports["pc_menuapi"]:createDropdown("MENUNAME", "NAME", "PARENTNAME", "TITLE", 1 --[[ default value starting at index 1 ]], function(option) --[[ cb_hover ]]
-- this function is called when the user hovers over the dropdown or an option
end, function(option) --[[ cb_enter ]]
-- this function is called when the user enters the dropdown or selects an option
end, function() --[[ cb_exit ]]
-- this function is called when the user exits the dropdown
end)
exports["pc_menuapi"]:setDropdownOptions("MENUNAME", "NAME", {"Option 1", "Option 2", "Option 3"})
exports["pc_menuapi"]["createDropdown"]("MENUNAME", "NAME", "PARENTNAME", "TITLE", 1 /* default value starting at index 1 */, (option) /* cb_hover */ => {
// this function is called when the user hovers over the dropdown or an option
}, (option) /* cb_enter */ => {
// this function is called when the user enters the dropdown or selects an option
}, () /* cb_exit */ => {
// this function is called when the user exits the dropdown
});
exports["pc_menuapi"]["setDropdownOptions"]("MENUNAME", "DROPDOWNNAME", ["Option 1", "Option 2", "Option 3"])
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The name or identifier of the parent.
The name of the menu, visible to the user.
The index (starting at 1) of the default option to select.
The first function is called when the user hovers over this item or an option (
option will be undefined or the index of the hovered option).
The second function is called when the user enters the dropdown or selects an option (
option will be undefined or the index of the hovered option).
The third function is called when the user exits the dropdown.
4.3 Execute
Let the user trigger an action.
exports["pc_menuapi"]:createExecute("MENUNAME", "NAME", "PARENTNAME", "TITLE", function() --[[ cb_hover ]]
-- this function is called when the user hovers over this item
end, function() --[[ cb_enter ]]
-- this function is called when the user selects this item
end)
exports["pc_menuapi"]["createExecute"]("MENUNAME", "NAME", "PARENTNAME", "TITLE", () /* cb_hover */ => {
// this function is called when the user hovers over this item
}, () /* cb_enter */ => {
// this function is called when the user selects this item
});
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The name or identifier of the parent.
The name of the menu, visible to the user.
The first function is called when the user hovers over this item.
The second function is called when the user selects this item.
4.4 Inputfield
An inputfield allows the user to write text.
exports["pc_menuapi"]:createInputfield("MENUNAME", "NAME", "PARENTNAME", "TITLE", "value" --[[ default value ]], function() --[[ cb_hover ]]
-- this function is called when the user hovers over this item
end, function(newValue) --[[ cb_enter ]]
-- this function is called when the user entered text
end)
exports["pc_menuapi"]["createInputfield"]("MENUNAME", "NAME", "PARENTNAME", "TITLE", "value" /* default value */, () /* cb_hover */ => {
// this function is called when the user hovers over this item
}, (newValue) /* cb_enter */ => {
// this function is called when the user entered text
});
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The name or identifier of the parent.
The name of the menu, visible to the user.
The first function is called when the user hovers over this item.
The second function is called when the user entered text.
The entered text.
4.5 Spacer
This can be used to display information or just simply add an empty space to your menu layout.
exports["pc_menuapi"]:createSpacer("MENUNAME", "NAME", "PARENTNAME", "TITLE", function()
-- this function is called when the user hovers over this item
end)
exports["pc_menuapi"]["createSpacer"]("MENUNAME", "NAME", "PARENTNAME", "TITLE", () => {
// this function is called when the user hovers over this item
});
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The name or identifier of the parent.
The name of the menu, visible to the user.
4.6 Submenu
This creates a folder-like structure in your menu, it can contain further items.
exports["pc_menuapi"]:createSubmenu("MENUNAME", "NAME", "PARENTNAME", "TITLE", function() --[[ cb_hover ]]
-- this function is called when the user hovers over this item
end, function() --[[ cb_enter ]]
-- this function is called when the user enters the submenu
end, function() --[[ cb_exit ]]
-- this function is called when the user exits the submenu
end)
exports["pc_menuapi"]["createSubmenu"]("MENUNAME", "NAME", "PARENTNAME", "TITLE", () /* cb_hover */ => {
// this function is called when the user hovers over this item
}, () /* cb_enter */ => {
// this function is called when the user enters the submenu
}, () /* cb_exit */ => {
// this function is called when the user exits the submenu
});
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The name or identifier of the parent.
The name of the menu, visible to the user.
The first function is called when the user hovers over this item.
The second function is called when the user enters the submenu.
The third function is called when the user exits the submenu.
4.7 Toggle
A toggle can be used to let the user turn things off and on.
exports["pc_menuapi"]:createToggle("MENUNAME", "NAME", "PARENTNAME", "TITLE", false --[[ default value ]], function() --[[ cb_hover ]]
-- this function is called when the user hovers over this item
end, function(newValue) --[[ cb_enter ]]
-- this function is called when the user selects this item
end)
exports["pc_menuapi"]["createToggle"]("MENUNAME", "NAME", "PARENTNAME", "TITLE", false /* default value */, () /* cb_hover */ => {
// this function is called when the user hovers over this item
}, (newValue) /* cb_enter */ => {
// this function is called when the user selects this item
});
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The name or identifier of the parent.
The name of the menu, visible to the user.
The first function is called when the user hovers over this item.
The second function is called when the user toggles this item.
Returns the new value inform of a boolean.
5. Features
Features allow your script to gain more control over an existing menu.
5.1 Delete an item
Deletes items or submenus recursively.
exports["pc_menuapi"]:delete("MENUNAME", "ITEMNAME")
exports["pc_menuapi"]["delete"]("MENUNAME", "ITEMNAME");
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
5.2 Check existance
Returns a boolean indicating if an item exists.
exports["pc_menuapi"]:exists("MENUNAME", "ITEMNAME")
exports["pc_menuapi"]["exists"]("MENUNAME", "ITEMNAME");
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
5.3 Get value
Returns the current value of an item (colorinput, dropdown, inputfield or toggle).
exports["pc_menuapi"]:getValue("MENUNAME", "ITEMNAME")
exports["pc_menuapi"]["getValue"]("MENUNAME", "ITEMNAME");
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
5.4 Set value
Sets the value of an item (colorinput, dropdown, inputfield or toggle).
exports["pc_menuapi"]:setValue("MENUNAME", "ITEMNAME", "NEWVALUE")
exports["pc_menuapi"]["setValue"]("MENUNAME", "ITEMNAME", "NEWVALUE");
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The new value of the item.
5.5 Set title
Set a new title for an existing item.
exports["pc_menuapi"]:setTitle("MENUNAME", "ITEMNAME", "NEWTITLE")
exports["pc_menuapi"]["setTitle"]("MENUNAME", "ITEMNAME", "NEWTITLE");
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
The new title.
5.6 Toggle an item
Activate or deactivate an item. Inactive items are still displayed, but will be "locked" and have no more interactions (hover and enter callbacks).
exports["pc_menuapi"]:setEnabled("MENUNAME", "ITEMNAME", true --[[ enabled ]])
exports["pc_menuapi"]["setEnabled"]("MENUNAME", "ITEMNAME", true /* enabled */);
Explaination
The name or identifier of the menu.
The name or identifier of the item to create.
Wether to activate or deactivate the item.
6. External features
Externals features can be called from any script without having to create whole a menu.
6.1 Colorpalette
Let the user pick a color from the RGB-spectrum.
TriggerEvent("pc_menuapi:colorpalette", {r, g, b} --[[ default value ]], function(value)
-- this function gets called when ever the user has moved the color selector
end)
emit("pc_menuapi:colorpalette", [r, g, b] /* default value */, (value) => {
// this function gets called when ever the user has moved the color selector
});
Explaination
The default color to display when opening the color picker.
This function will be called when ever the user moves the color picker returning the selected color in the following format:
{{r, g, b}, "#HEX"}6.2 Inputfield
Let the user enter a text.
TriggerEvent("pc_menuapi:inputfield", "TITLE", function(value)
-- this function is called when the user has entered a text
end)
emit("pc_menuapi:inputfield", "TITLE", (value) => {
// this function is called when the user has entered a text
});
Explaination
A title to display whilst showing the inputfield.
This function will be called once when the user confirmed the entered text (which will be returned).
6.3 Play sound
This allows you to play frontend audio files (.ogg). The audio file has to be stored in the
sounds-folder in the Menu API.
TriggerEvent("pc_menuapi:sound", "SOUND")
emit("pc_menuapi:sound", "SOUND");
Explaination
The name of the audio file (without the .ogg file extension).