Exports
getContact(identifier)
Use this export to retrieve the info from a contact, including the player reputation.
If the player hasn't meet the contact yet the export will return false, unless the contact config field default is set to true.
Params:
identifier:
string
The contact identifierReturns:
result:
table or false
local result = exports['av_contacts']:getContact("garbage_job") if result then --[[ { identifier:string, name:string, default:boolean, coords:table, xp:number, description:string, avatar:string, } ]]-- else print("Player doesn't know this contact yet") end
getContacts()
Returns a table with all the contacts known by the player.
local result = exports['av_contacts']:getContacts() if result and next(result) then for identifier, contact in pairs(result) do print(json.encode(contact, {indent = true})) --[[ { identifier:string, name:string, default:boolean, coords:table, xp:number, description:string, avatar:string, } ]]-- end end
newContact(data)
Use this export from an external script to register a new contact in the contact list configuration.
Params:
data:
table
identifier:
string
An unique identifier for the contact.name:
string
Name used for display.coords:
table
Coords where the contact is located {x:number, y:number, z:number}avatar?:
string
Avatar used for contact list.description:
string
Description used for contact list.default?:
boolean
Show this contact by default.local data = { identifier = "av_scripts", name = "AV Scripts", avatar = "https://files.fivemerr.com/images/303c36b5-0730-4d9f-b1c8-e61725a233d3.png", coords = {x = 129.10, y = 19.87, z = 20.55}, description = "The best laptop available for Fivem", default = true, } local registered = exports['av_contacts']:newContact(data) print("Registered?", registered)
addContact(playerId, identifier)
Trigger this export when the player meets a contact, this will register the contact in the player contacts list.
Params:
playerId:
number
The player server ID.identifier:
string
The contact identifier.Returns:
result:
boolean
It will return true if the contact is registered successfully or false if the player already had this contact on his list.local registered = exports['av_contacts']:addContact(source,"garbage_job") print("Registered?", registered)
removeContact(playerId, identifier)
Use this export to remove a contact from the player contacts list and remove his reputation with the contact.
Params:
playerId:
number
The player server ID.identifier:
string
The contact identifier.Returns:
result:
boolean
Return true if the contact was removed or false if the contact didn't exists in player list OR you added a non existing contact identifier.local removed = exports['av_contacts']:removeContact(source,"garbage_job") print("Removed?", removed)
addXP(playerId, identifier, xp)
Add reputation to the relationship between the player and the selected contact.
Params:
playerId:
number
The player server IDidentifier:
string
The contact identifierxp:
number
The reputation to addReturns:
result:
boolean
It will only return false if the export receives a null value, or if the player ID and/or contact identifier don't exist.local added = exports['av_contacts']:addXP(source,"garbage_job",25) print("Added?", added)
removeXP(playerId, identifier, xp)
Remove reputation to the relationship between the player and the contact.
Params:
playerId:
number
The player server IDidentifier:
string
The contact identifierxp:
number
The reputation to removeReturns:
result:
boolean
It will return false if any parameter is null or invalid, or if the player has no existing relationship with the specified contact.local removed = exports['av_contacts']:removeXP(source, "garbage_job", 25) print("Removed?", removed)
getContacts(playerId)
Params:
playerId:
number
The player server IDReturns:
result:
table
Returns a table with all the contacts known by the player.local contacts = exports['av_contacts']:getContacts(source) if contacts and next(contacts) then for _, v in pairs(contacts) do print(json.encode(v, {indent = true})) --[[ { identifier:string, name:string, default:boolean, coords:table, xp:number, description:string, avatar:string, } ]]-- end end
Last updated