We provide various open source functions into our Advanced Drug Sales resource that enables you to add further customization and/or add third-party resource integrations.
Client
The functions below can be found in lation_selling/client/functions.lua
CanSell() - Function that allows or rejects a player from selling
-- Empty function that checks if a drug sale can continue or not
-- Must return true to proceed, or return false to cancel
--- @param zoneId number Zone ID
CanSell = function(zoneId)
if IsPedInAnyVehicle(cache.ped, true) then
ShowNotification(Strings.Notify.noVehicle, 'error')
return false
end
return true
end
Server
The functions below can be found in lation_selling/server/functions.lua
DrugSold() - Function that is trigger on a drug sale transaction
-- Empty function that is triggered on drug sales
-- Can be used with XP systems, gang scripts, etc
--- @param source number Player ID
--- @param zoneId number Zone ID
--- @param item string Drug/item name
--- @param quantity number Quantity sold
--- @param value number Total money paid to player
DrugSold = function(source, zoneId, item, quantity, value)
-- Below is an example implementation of how you could use this function
-- In this example, we'll check if the player is a gang member and if so
-- Add reputation/notoriety to their gang upon a drug sale
-- First, let's check if they are in a gang:
local inGang = true
-- If we were using something like t1ger_gangsystem we would replace
-- "true" with the proper export, aka: exports['t1ger_gangsystem']:GetPlayerGangId(source)
if inGang then
-- inGang returned true or something greater than 0, so now we work within
-- This if-then statement. So if inGang then..
-- Let's only add reputation/notoriety if they are selling a specific item..
if item == 'special_drug' then
-- Now we know this player is in a gang, and is selling this special drug
-- So now let's add some reputation/notoriety to their gang!
local addNotoriety = 100
-- But, maybe we should change how much notoriety is added based
-- On how many of this special drug they sold.. so let's do it!
local totalToAdd = math.floor(addNotoriety * quantity)
-- Here we just multiply the addNotoriety by the total quantity sold
-- So if they sold x3 special_drug then they would get 300 notoriety
-- Now we would place our export/event below to add it!
-- exports['t1ger_gangsystem']:PlusGangNotoriety(inGang, totalToAdd)
end
end
-- If a player was not in a gang then the code would do nothing!
-- This is a simple example to demonstrate one of the many, many
-- Options you have with a function like this, enjoy <3
end
Warning
It is important to note however, any & all edits made in these various functions are your responsibility. We do not provide support for, nor assist with, adding or editing custom functionality into our resources.