This file represents the Contracts configuration file (sh_contracts.lua)
Settings
Config.Contracts.Settings = { maxContractsActive =3, -- The maximum amount of contracts available at the same time (It includes started and non started contracts), generationInterval = {min =5000, max =15000}, -- The time between new contracts appearing in ms. startInterval = {min =1000, max =1500} -- The time the contract takes to start after being generated.}
Contracts
Structure
This is the base structure of a contract will various possible values
["ID OF THE CONTRACT"] = { -- ID of the contract title ="NAME OF THE CONTRACT", -- Title of the contract description ="DESCRIPTION OF THE CONTRACTS", -- Description of the contract gangsRequired =1, -- The amount of joined gangs required to start. (If not enough joined gangs will get their coins refunded). policeRequired =0, -- The amount of police online for the contract to generate (The count will also be checked when it starts and if it isn't reached the joined gangs will get their coins refunded). price =0, -- The price of gang coins to join. requiredReputation = { -- Required reputation of various dealers to join the contract.-- ["dealer_name"] = requiredDealerReputation, }, requiredTasks = { -- Required completed tasks of various dealers to join the contract.-- ["dealer_name"] = { list of needed tasks } }, timeToComplete =600000, --TIME TO COMPLETE THE CONTRACT IN MS steps = { -- Steps and their data.-- init and finish steps are crucial, without both of these steps the contract will break and the script will have issues. ["init"] = { stepData here }, --Look at the step structure ["finish"] = { stepData here } --Look at the step structure }}
Steps
This displays all possible values for steps.
Notice: Finish step only takes clearEntities and clearBlips and doesn't execute any other values.
["STEP ID"] = { -- STEP IDserverCallback=function() -- THIS FUNCTION GETS CALLED WHEN THIS STEP IS INITIATED (SERVER-SIDE)end,playerCallback=function(player) -- THIS FUNCTION IS CALLED FOR ALL THE JOINED PLAYERS WHEN THE STEP IS INITIATED (SERVER-SIDE)end, clearEntities =true, -- Should entities be cleaned when step is started? Can be a true to clear all entities or an array of entity IDs to clear like { 'benson'} clearBlips =true, -- Should blips be cleaned when step is started? True - cleans all blips, False - doesn't clean blips blips = { -- BLIPS TO CREATE { blip structure } }, vehicles = { -- VEHICLES TO CREATE { vehicle structure } }, peds = { -- PEDS TO CREATE { peds structure }},
Blips
These are all possible values for blips and they should go in the steps blips field.
{ title ="Supply Truck", -- Blip title sprite =479,--Blip icon id color =28,--Blip color id scale =1.3,--Blip scale coords =vector3(1247.1368, -3150.2583, 5.6856), -- Blip coords radius = { sprite =9,--Radius id color =1,--Radius color id offsets =math.random(-170.0, 170.0),--Radius offset, radius =250--Radius size, }}
Vehicles
There are all possible values for vehicles and they should go in the steps vehicles field.
Keeping the same ID but changing the values in steps after the entity is spawned will change some of these values, you can use this to modify currently existing entities without having to re-create new ones.
{ id ="ID of the Vehicle", -- ID OF THE VEHICLE model ="Model of the Vehicle", -- MODEL OF THE VEHICLE pos =vector3(1247.1368, -3150.2583, 5.6856), -- POSITION OF THE VEHICLE heading =267.0805, -- HEADING OF THE VEHICLE freeze =false, -- FREEZE THE VEHICLEserverCallback=function(entity) -- SERVER CALLBACK FOR THE VEHICLE--Can be used to lock the vehicle for example.end, target = { TARGET DATA }}
Entities
These are all possible values on an entities and should go to the steps entities field
{ id ="boxes", -- ID OF THE ENTITY model ="prop_rub_boxpile_06", -- MODEL OF THE ENTITY pos =vector3(1247.9449, -3289.4832, -5.7197), -- POSITION OF THE ENTITY freeze =true, -- FREEZE THE ENTITY attach = { -- ATTACHMENT DATA type ="vehicle", -- TYPE OF THE ATTACHMENT (vehicle or entity, if attaching to vehicle set to vehicle if to anything else set to entity) id ="benson", -- ID OF THE VEHICLE TO ATTACH TO bone ="chassis", -- BONE TO ATTACH TO pos =vec3(0.75, -5.0, 0.5), -- POSITION OFFSET rot =vec3(0.0, 0.0, 0.0), -- ROTATION OFFSET disableCollision =true, -- DISABLE COLLISION FOR THE ATTACHED ENTITY }, target = { TARGET DATA }}
Peds
These are all possible values for peds. These should go in the steps peds field.
{ id ="thirdEnemy", -- ID OF THE PED freeze =true, -- FREEZE THE PED health =200, -- HEALTH OF THE PED armour =100, -- ARMOUR OF THE PED anim = { -- ANIMATION FOR THE PED | SET TO FALSE TO DISABLE dict ="amb@code_human_police_investigate@idle_a", -- ANIMATION DICTIONARY clip ="idle_b", -- ANIMATION CLIP }, scenario =false, -- SCENARIO FOR THE PED | SET TO FALSE TO DISABLE ignoreEverything =false, -- IGNORE EVERYTHING FOR THE PED clearTasks =true, -- CLEAR TASKS FOR THE PED weapon = { -- WEAPON FOR THE PED ammo =200, -- AMMO FOR THE WEAPON weapon ="WEAPON_MICROSMG" -- WEAPON MODEL }, tasks = { -- TASKS FOR THE PED { task ="attack_hated_targets", -- TASK TO PERFORM radius =50.0-- RADIUS FOR THE TASK } }, target = { TARGET DATA }},
Target
These are all posible values for target data for entities. This can be used with all of the entities, vehicles and peds. This should go in the selected peds target field.
["TARGET ID"] = { -- TARGET ID icon ="Target Icon", -- ICON FOR THE TARGET label ="Target Label", -- LABEL FOR THE TARGET action = { -- ACTIONS FOR THE TARGET requiredItems = { -- REQUIRED ITEMS TO PERFORM THE ACTION [itemname] = itemAmount ["item name"] =1, }, remove = { -- ITEMS TO REMOVE AFTER THE ACTION IS PERFORMED [itemname] = itemAmount items = { ["item name"] =1, } }, give = { items = { -- ITEMS TO GIVE AFTER THE ACTION IS PERFORMED [itemname] = itemAmount ["item name"] = {amount = {min =50, max =100}}, -- Structure for random amount ["item name"] = {chance =70, amount = { min =1, max =3}}, --Structure for random amount and chance ["item name"] = {chance =70, amount =1}, --Structure for fixed amount and chance ["item name"] =20, -- Structure for fixed amount }, reputation = { --Reputation to give or remove (use negative values to remove)--[dealerName] = amount ["lamar"] =5 }, coins =5--Coins to give. }, setNewStep ="Step ID", -- SET NEW STEP AFTER THE ACTION IS PERFORMEDcallback=function(player) -- CALLBACK FUNCTION CALLED BEFORE THE ACTION IS PERFORMED. THIS IS SERVER SIDE. YOU CAN RETURN FALSE IN THIS FUNCTION TO STOP THE ACTION--Return false to stop this function--Return true to go ahead with the action--Returning nothing is equal to returning false, so be sure to return true if using this.end }}
To clear out active targets when a step is initialized add clearTargets = true to the entity.
Customizing the experience
This requires knowladge of LUA and programming, but you can always ask us for help implementing your ideas.
Modyfing Existing Entities
To modify already existing entities, use the same structure and specifiy the same ID. If the entity is available the script will override the entities options with newly passed ones. Keep in mind that some options like model can't be overwritten, and a new entity will have to be created.
Example
-- Creating an entity in init step{ id ="boxes", -- ID OF THE ENTITY model ="prop_rub_boxpile_06", -- MODEL OF THE ENTITY pos =vector3(1247.9449, -3289.4832, -5.7197), -- POSITION OF THE ENTITY freeze =true, -- FREEZE THE ENTITY}--Unfreezing the entity in the next step required only the ID and freeze value set to false{ id ="boxes", -- ID OF THE ENTITY freeze =false, -- FREEZE THE ENTITY}--When the step with new options is started, the entity will be unfrozen.
Accessing Entity Handles
You might have to access the entities script-wise to call native values and them. To do that you can follow this example:
--Keep in mind this is in serverside, to execute client natives you'll have to send an event to the client side.--Also, note that all entities are created on the server side and might not be available at the time on the client, so be sure to use OneSync friendly techniques.--contractID is the ID of the contract, for example supplyrunone--entityID is the ID of the entity, for example boxesifnot Contracts.Active[contractID] thenreturnfalseendifnot Contracts.Active[contractID].data.entities[entityID] thenreturnfalseendwhileNetworkGetEntityOwner(Contracts.Active[contractID].data.entities[entityID]) ==-1do Citizen.Wait(1000)endlocal owner =NetworkGetEntityOwner(Contracts.Active[contractID].data.entities[entityID])TriggerClientEvent("clientEvent", owner, NetworkGetNetworkIdFromEntity(Contracts.Active[contractID].data.entities[entityID]))