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:
stringThe contact identifierReturns:
result:
table or falselocal result = exports['av_contacts']:getContact("garbage_job") if result then --[[ { identifier:string, name:string, default:boolean, coords:table, xp:number, level: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, level: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:
stringAn unique identifier for the contact.name:
stringName used for display.coords:
tableCoords where the contact is located {x:number, y:number, z:number}avatar?:
stringAvatar used for contact list.description:
stringDescription used for contact list.default?:
booleanShow this contact by default.max?:
numberMax level available for this contact (every 100XP is 1 level)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, max = 5, } 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:
numberThe player server ID.identifier:
stringThe contact identifier.Returns:
result:
booleanIt 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:
numberThe player server ID.identifier:
stringThe contact identifier.Returns:
result:
booleanReturn 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:
numberThe player server IDidentifier:
stringThe contact identifierxp:
numberThe reputation to addReturns:
result:
booleanIt 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:
numberThe player server IDidentifier:
stringThe contact identifierxp:
numberThe reputation to removeReturns:
result:
booleanIt 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:
numberThe player server IDReturns:
result:
tableReturns 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, level:number, description:string, avatar:string, } ]]-- end end
getContact(playerId, 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:
playerId:
numberThe player server IDidentifier:
stringThe contact identifierReturns:
result:
table or falselocal contact = exports['av_contacts']:getContact(source, "garbage_job") if contact then print(json.encode(contact, {indent = true})) --[[ { identifier:string, name:string, default:boolean, coords:table, xp:number, level:number, description:string, avatar:string, } ]]-- end
Last updated