Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.32 KB | None | 0 0
  1. PJDelivery = PJDelivery or {}
  2. PJDelivery.Languages = {}
  3. PJDelivery.Config = {}
  4. PJDelivery.Config.Derma = {}
  5.  
  6. PJDelivery.Config.Language = "en" -- Available languages: fr, en, es, pl, ru, de, dk (default: en)
  7.  
  8. PJDelivery.Config.ForAllEnts = true --[[ Is the delivery system needs to be applied on all entities ? true -> yes; false -> no; (default: true)
  9.     If false then you need to add: delivery = true, in your darkrp config entities.
  10.     For exemple:
  11.     DarkRP.createEntity("The best entity ever", {
  12.         ...
  13.         delivery = true, -- THIS LINE needs to be add to be delivered (PJDelivery.Config.WhiteList on true) or not (PJDelivery.Config.WhiteList on false)
  14.         ...
  15.     })
  16. ]]
  17. PJDelivery.Config.WhiteList = true -- If not ForAllEnts, add "delivery = true" will be for whitelisted items, or blacklist them. true for whitelist, false for blacklist (default: true)
  18.  
  19. PJDelivery.Config.AdminRanks = { -- Which ranks can access to the dropbox tool ?
  20.     "superadmin",
  21. }
  22.  
  23. // Models
  24. PJDelivery.Config.DropBoxModel = "models/props_street/mail_dropbox.mdl" -- Model for the drop box, if you want to use a custom one (default: "models/props_street/mail_dropbox.mdl")
  25. PJDelivery.Config.PackageModel = "models/props_junk/cardboard_box001a.mdl" -- Model for the package box (default: "models/props_junk/cardboard_box001a.mdl")
  26. PJDelivery.Config.TruckRetriverModel = "models/odessa.mdl" -- Model for the delivery truck retriever (default: "models/odessa.mdl")
  27. PJDelivery.Config.StorageCenterModel = "models/alyx.mdl" -- Model of the storage center, need to be a pnj one (default: "models/alyx.mdl")
  28. PJDelivery.Config.MarketModel = "models/alyx.mdl" -- Default model of the market PNJ (default: "models/alyx.mdl")
  29. PJDelivery.Config.MarketModels = { -- All available market models
  30.     -- DEFAULTS:
  31.     "models/alyx.mdl",
  32.     "models/barney.mdl",
  33.     "models/breen.mdl",
  34.     "models/p2_chell.mdl",
  35.     "models/eli.mdl",
  36.     "models/gman_high.mdl",
  37.     "models/kleiner.mdl",
  38.     "models/monk.mdl",
  39.     "models/mossman.mdl",
  40.     "models/mossman_arctic.mdl",
  41.     "models/odessa.mdl",
  42.     "models/magnusson.mdl",
  43.     "models/police.mdl",
  44.     "models/police_fem.mdl",
  45.     "models/combine_soldier.mdl",
  46.     "models/combine_super_soldier.mdl",
  47.     "models/combine_soldier_prisonguard.mdl",
  48.     "models/soldier_stripped.mdl",
  49.     "models/corpse1.mdl",
  50.     "models/charple.mdl",
  51.     "models/skeleton.mdl",
  52.     "models/zombie_classic.mdl",
  53.     "models/zombie_fast.mdl",
  54.     "models/zombie_soldier.mdl",
  55.     "models/Group01/female_01.mdl",
  56.     "models/Group01/female_02.mdl",
  57.     "models/Group01/female_03.mdl",
  58.     "models/Group01/female_04.mdl",
  59.     "models/Group01/female_05.mdl",
  60.     "models/Group01/female_06.mdl",
  61.     "models/Group03/female_01.mdl",
  62.     "models/Group03/female_02.mdl",
  63.     "models/Group03/female_03.mdl",
  64.     "models/Group03/female_04.mdl",
  65.     "models/Group03/female_05.mdl",
  66.     "models/Group03/female_06.mdl",
  67.     "models/Group03m/female_01.mdl",
  68.     "models/Group03m/female_02.mdl",
  69.     "models/Group03m/female_03.mdl",
  70.     "models/Group03m/female_04.mdl",
  71.     "models/Group03m/female_05.mdl",
  72.     "models/Group03m/female_06.mdl",
  73.     "models/Group01/male_01.mdl",
  74.     "models/Group01/male_02.mdl",
  75.     "models/Group01/male_03.mdl",
  76.     "models/Group01/male_04.mdl",
  77.     "models/Group01/male_05.mdl",
  78.     "models/Group01/male_06.mdl",
  79.     "models/Group01/male_07.mdl",
  80.     "models/Group01/male_08.mdl",
  81.     "models/Group01/male_09.mdl",
  82.     "models/Group02/male_02.mdl",
  83.     "models/Group02/male_04.mdl",
  84.     "models/Group02/male_06.mdl",
  85.     "models/Group02/male_08.mdl",
  86.     "models/Group03/male_01.mdl",
  87.     "models/Group03/male_02.mdl",
  88.     "models/Group03/male_03.mdl",
  89.     "models/Group03/male_04.mdl",
  90.     "models/Group03/male_05.mdl",
  91.     "models/Group03/male_06.mdl",
  92.     "models/Group03/male_07.mdl",
  93.     "models/Group03/male_08.mdl",
  94.     "models/Group03/male_09.mdl",
  95.     "models/Group03m/male_01.mdl",
  96.     "models/Group03m/male_02.mdl",
  97.     "models/Group03m/male_03.mdl",
  98.     "models/Group03m/male_04.mdl",
  99.     "models/Group03m/male_05.mdl",
  100.     "models/Group03m/male_06.mdl",
  101.     "models/Group03m/male_07.mdl",
  102.     "models/Group03m/male_08.mdl",
  103.     "models/Group03m/male_09.mdl",
  104.     "models/hostage/hostage_01.mdl",
  105.     "models/hostage/hostage_02.mdl",
  106.     "models/hostage/hostage_03.mdl",
  107.     "models/hostage/hostage_04.mdl",
  108.     "models/arctic.mdl",
  109.     "models/gasmask.mdl",
  110.     "models/guerilla.mdl",
  111.     "models/leet.mdl",
  112.     "models/phoenix.mdl",
  113.     "models/riot.mdl",
  114.     "models/swat.mdl",
  115.     "models/urban.mdl",
  116.     "models/dod_american.mdl",
  117.     "models/dod_german.mdl",
  118.  
  119.     -- CUSTOMS
  120.     -- "mdl_path/mdl_name.mdl",
  121. }
  122. PJDelivery.Config.CanBeSameName = false -- Can be two drop box with the same name ? (default: false)
  123. PJDelivery.Config.HelpText = 3 /*
  124.     Postion of the HUD:
  125.         1: top left
  126.         2: top right
  127.         3: middle
  128.         4: bottom left
  129.         5: bottom right
  130. */
  131. PJDelivery.Config.HelpTextsShow = { // Show help text, true to show, false to hide
  132.     ["DepositCarTrunk"] = true,
  133.     ["OpenCarTrunk"] = true,
  134.     ["PickupPackage"] = true,
  135.     ["DropboxPut"] = true,
  136.     ["DropboxGet"] = true,
  137. }
  138.  
  139. // Delivery & packages
  140. PJDelivery.Config.PayByBank = true -- Can the player pay by his bank account if he doesn't have enough money ? (default: true)
  141. PJDelivery.Config.PackagePickUpKey = {key = KEY_R, text = "Reload"} -- Key and text to pickup a package, this is also used for car storage
  142. PJDelivery.Config.TimeToDeliver = 0.15 -- Time for the post man for one meter, for exemple: if set to 1 then 13 meters take 13 seconds to be reached (default: 0.15)
  143. PJDelivery.Config.MeterPrice = 0.1 -- How much cost one meter for the delivery distance (default: 0.1)
  144. PJDelivery.Config.DeliveryPrice = false -- How much cost the delivery for a set price, false to let the price be variable (set by the MeterPrice) (default: false)
  145. PJDelivery.Config.PostmanFixed = false -- Do the postman will get a set reward ? false for the variable reward, true for set reward (default: false)
  146. PJDelivery.Config.AtHome = false -- Force the player to choose his home dropbox ? true for yes, false for no (default: false)
  147. PJDelivery.Config.MaxPackages = 5 -- Maximum active packages that a player could have (default: 5)
  148. PJDelivery.Config.SpawnPackage = "!package" -- Chat comment to spawn a new package, set it to false to disable it (default: "!package")
  149. PJDelivery.Config.PackageRemoveTime = 5 -- How many seconds for a package to be removed once it's empty ? (default: 300)
  150.  
  151. // Market
  152. PJDelivery.Config.Market = true -- Enable or disable the market system (default: true)
  153. PJDelivery.Config.MarketOpen = KEY_F5 -- Key to open the market, if yout want a command you can set "!my_marke_command" (default: KEY_F5)
  154. PJDelivery.Config.MarketPNJ = true -- Use market PNJ ? Can be placed with a tool (default: true)
  155. PJDelivery.Config.MarketPNJCategory = true -- Need to specify a category for a market PNJ ? Configurable with the tool (default: true)
  156. PJDelivery.Config.MarketAutoOpen = true -- Automaticaly open the market when the player try to by an ent ? (default: true)
  157. PJDelivery.Config.MarketMaxItems = 50 -- How many items * quantity can be delivered in one package ? (default: 50)
  158. PJDelivery.Config.MarketName = "PJ's Market" -- Market name shown on the market frame
  159. PJDelivery.Config.MarketTypes = { -- Items types (not the category name !) for the market, edit only the true or false
  160.     ["Entities"] = true,
  161.     ["Shipments"] = true,
  162.     ["Weapons"] = true,
  163.     ["Ammo"] = true,
  164.     ["Food"] = true, // If hungermod is enabled
  165.     ["Vehicles"] = false,
  166. }
  167. PJDelivery.Config.MarketAllCategories = true // Include all categories by default ? If not, you can edit below (default: true)
  168. PJDelivery.Config.MarketDefaultCategories = {
  169.     ["entities"] = { // Edit only the tables, not the ["Entities"], ["Shipments"], etc...
  170.         ["Other"] = true,
  171.     },
  172.     ["shipments"] = {
  173.         ["Snipers"] = true,
  174.         ["Rifles"] = false,
  175.         ["Shotguns"] = true,
  176.         ["Other"] = true,
  177.     },
  178.     ["weapons"] = {
  179.         ["Pistols"] = true
  180.     },
  181.     ["ammo"] = {
  182.         ["Other"] = true,
  183.     },
  184.     ["vehicles"] = {
  185.        
  186.     },
  187. }
  188.  
  189. // Items
  190. PJDelivery.Config.AutoItemsWeight = true -- Automaticly assigned weight for items (default: true)
  191. PJDelivery.Config.ItemWeight = { -- If PJDelivery.Config.AutoItemsWeight is to false, then this table will be used
  192.     ["darkrp_tip_jar"] = 5,-- ["ITEM ENT CLASS"] = weight,
  193. }
  194. PJDelivery.Config.DefaultItemWeight = 1 -- Default item weight (default: 1)
  195.  
  196. // Postman
  197. PJDelivery.Config.Job = "Postman" -- Post man job's name, false if you don't want it (default: "Postman") -- NOTE: you need to create the job ! -- Not supporting lua refresh !
  198. PJDelivery.Config.JobAutoCreate = true -- Auto create the postman job ? Editable lower in the file -- "true" for yes, "false" for no (default: true)
  199. PJDelivery.Config.BecomePostmanByStorageCenter = false -- Do a derma open when a player press use on the storage center pnj ? (default: true)
  200. PJDelivery.Config.AcceptTime = 60 -- How many time a postman have to accept the delivery order ? (default: 60) -- In seconds
  201. PJDelivery.Config.MaxLateTime = 3 * 60 -- How many minutes before cancel the delivery (after the delivery time end) (default: 3 * 60) -- TIPS: add *60 to make in minutes
  202. PJDelivery.Config.PenalityCost = 1 -- How much cost the penality for one second late (default: 1) -- In seconds -- Exemple: 1 minute late is: (the reward price) - 60$
  203. PJDelivery.Config.AcceptShowTime = 5 -- How many time the request frame stay after accepted the delivery order ? (default: 5) -- In seconds
  204. PJDelivery.Config.MaxJobs = 5 -- How many delivery orders can have a postman at the same time (default: 5)
  205. PJDelivery.Config.WantedNoDelivery = true -- Is the player wanted if he doesn't delivered the order, and don't have enough money to pay the order's value ? (default: true)
  206. PJDelivery.Config.DeliveryVehicles = { -- ["Veh_class"] = {Veh_Skin_1, Veh_Skin_2, etc...}, || Veh_class can be found by right clicking in your vehicles list and copy to clipboard, Veh_skin is by default 0
  207.     ["courier_trucktdm"] = {1}
  208. }
  209.  
  210. // Auto postman job
  211. PJDelivery.Config.AutoJobs = {min = 20, max = 60} -- An auto job appear when the postman doesn't had a job for x seconds (default: min = 20, max = 20) -- In seconds -- false to disable -- min, max is for a random between these two values
  212. PJDelivery.Config.AutoItems = { -- Wich items can be auto delivered ? It's needed because we don't want a player to steal a $1.000.000 item, false to make all
  213.     ["Entities"] = {
  214.         ["atm_reader"] = true,-- ["ITEM ENT CLASS"] = true, -- The item class can be found at the ent line of the darkrp ent: 'ent = "darkrp_tip_jar",'
  215.     },
  216.     ["Shipments"] = {
  217.         ["cw_makarov"] = false,
  218.     },
  219.     ["Weapons"] = {
  220.  
  221.     },
  222.     ["Ammo"] = {
  223.  
  224.     },
  225.     ["Food"] = {
  226.  
  227.     },
  228.     ["Vehicles"] = { -- The darkrp vehicle, mostly unused by people
  229.  
  230.     },
  231. }
  232.  
  233. // Car Trunk
  234. PJDelivery.Config.CarStorageDefault = 10 -- How many packages in one car by default (default: 10)
  235. PJDelivery.Config.CarStorage = { -- This is used to define amount of package for specific car, you can get the car class by right clicking on the car in the spawn menu
  236.     ["courier_trucktdm"] = 10, -- ["CAR CLASS"] = AMOUNT OF PACKAGE,
  237. } -- courier_trucktdm is the default car class for the delivery truck
  238. PJDelivery.Config.AlwaysShowEntsName = false -- Do the postman can see the entities name during the delivery on the different frames ? (default: false)
  239. PJDelivery.Config.CarTrunkRestriction = false -- Restrict car trunk to postmans ? (default: false)
  240.  
  241. PJDelivery.Config.Derma.FrameTop = Color(38, 38, 38)
  242. PJDelivery.Config.Derma.FrameBack = Color(23, 23, 23, 200)
  243.  
  244. PJDelivery.Config.Derma.Button = Color(48, 48, 48)
  245. PJDelivery.Config.Derma.ButtonHover = Color(23, 23, 23)
  246.  
  247. PJDelivery.Config.Derma.RedButton = Color(231, 76, 60)
  248. PJDelivery.Config.Derma.RedButtonBack = Color(192, 57, 43)
  249.  
  250.  
  251. if PJDelivery.Config.JobAutoCreate then // Postman job config
  252. hook.Add("DarkRPFinishedLoading", "PJDelivery:AutoCreateJob", function()
  253.  
  254. TEAM_POSTMAN = DarkRP.createJob(PJDelivery.Config.Job, { // Start config here
  255.     color = Color(89, 89, 89, 255),
  256.     model = {"models/Barney.mdl"},
  257.     description = [[Delivery some packages to other players and get rewards !]],
  258.     weapons = {},
  259.     command = "postman",
  260.     max = 0,
  261.     salary = GM.Config.normalsalary,
  262.     admin = 0,
  263.     vote = false,
  264.     hasLicense = false, // End here, don't forget to make sure you have some commas at the end of each lines
  265. })
  266.  
  267. end)
  268. end
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292. -- DON'T TOUCH BELOW THIS !!!
  293. -- DON'T TOUCH BELOW THIS !!!
  294. -- DON'T TOUCH BELOW THIS !!!
  295. -- DON'T TOUCH BELOW THIS !!!
  296. -- DON'T TOUCH BELOW THIS !!!
  297.  
  298. if SERVER then resource.AddWorkshop("1873947237") end
  299.  
  300. IncludeCS("pjdelivery/languages/en.lua")
  301. IncludeCS("pjdelivery/languages/"..PJDelivery.Config.Language..".lua")
  302. function PJDelivery.GetPhrase(name)
  303.     return  PJDelivery.Languages[PJDelivery.Config.Language] != nil and PJDelivery.Languages[PJDelivery.Config.Language][name] or PJDelivery.Languages["en"][name]
  304. end
  305.  
  306. function PJDelivery.FormatDistance(pos1, pos2)
  307.     return math.Round(pos1:Distance(pos2) / 10)
  308. end
  309.  
  310. function PJDelivery.GetDeliveryCenter()
  311.     local r = ents.FindByClass("pj_pnj_storage_center")
  312.  
  313.     return (!r or table.IsEmpty(r)) and false or r
  314. end
  315.  
  316. function PJDelivery.RandomVariable(length)
  317.     //math.randomseed(FrameTime())
  318.     local r = ""
  319.     for i = 1, length do
  320.         r = r .. string.char(math.random(97, 122))
  321.     end
  322.     return r
  323. end
  324.  
  325. function PJDelivery.GetPostMan()
  326.     local r = {}
  327.     for k,v in pairs(player.GetAll()) do
  328.         if PJDelivery.Config.Job != team.GetName(v:Team()) then continue end
  329.         table.insert(r, v)
  330.     end
  331.     return r
  332. end
  333.  
  334.  
  335. local meta = FindMetaTable("Player")
  336. function meta:GetCloserCenter()
  337.     local centers = PJDelivery.GetDeliveryCenter()
  338.  
  339.     if !centers then return false end
  340.    
  341.     local min = -1
  342.     local ent = nil
  343.     for k,v in pairs(centers) do
  344.         local dist = PJDelivery.FormatDistance(v:GetPos(), self:GetPos())
  345.         if dist < min or min == -1 then ent = v min = dist end
  346.     end
  347.  
  348.     return ent, min
  349. end
  350.  
  351. hook.Add("loadCustomDarkRPItems", "PJDelivery:ListAutoItems", function()
  352.     if !PJDelivery.Config.AutoJobs then return end
  353.  
  354.     PJDelivery.AutoItemsList = {}
  355.  
  356.     for k,v in pairs(DarkRPEntities) do
  357.         if PJDelivery.Config.AutoItems.Entities[v.ent] or !PJDelivery.Config.AutoItems then local ins = table.Copy(v) ins.Type = "entity" PJDelivery.AutoItemsList[k] = ins end
  358.     end
  359.  
  360.     for k,v in pairs(CustomShipments) do
  361.         if PJDelivery.Config.AutoItems.Shipments[v.entity] or !PJDelivery.Config.AutoItems then local ins = table.Copy(v) if ins.separate then ins.Type = "pistol" else ins.Type = "shipment" end PJDelivery.AutoItemsList[k] = ins end
  362.     end
  363.    
  364.     for k,v in pairs(GAMEMODE.AmmoTypes) do
  365.         if PJDelivery.Config.AutoItems.Ammo[v.ent] or !PJDelivery.Config.AutoItems then local ins = table.Copy(v) ins.Type = "ammo" PJDelivery.AutoItemsList[k] = ins end
  366.     end
  367.    
  368.     if !DarkRP.disabledDefaults["modules"]["hungermod"] then
  369.         for k,v in pairs(FoodItems) do
  370.             if PJDelivery.Config.AutoItems.Food[v.ent] or !PJDelivery.Config.AutoItems then local ins = table.Copy(v) ins.Type = "Food" PJDelivery.AutoItemsList[k] = ins end
  371.         end
  372.     end
  373.  
  374.     for k,v in pairs(CustomVehicles) do
  375.         if PJDelivery.Config.AutoItems.Vehicles[v.ent] or !PJDelivery.Config.AutoItems then local ins = table.Copy(v) ins.Type = "vehicle" PJDelivery.AutoItemsList[k] = ins end
  376.     end
  377. end)
  378.  
  379. PJDelivery.Version = "1.1.5" -- Just for support
  380.  
  381. if BATM then
  382. function PJDelivery.BATM_Accounts()
  383.     return CBLib.LoadModule("batm/bm_accounts.lua", false)
  384. end
  385. end
  386.  
  387. if SERVER then
  388.     AddCSLuaFile("pjdelivery/cl_utils.lua")
  389.     AddCSLuaFile("pjdelivery/cl_init.lua")
  390.     AddCSLuaFile("pjdelivery/cl_hud.lua")
  391.     AddCSLuaFile("pjdelivery/cl_panels.lua")
  392.     include("pjdelivery/sv_init.lua")
  393.     include("pjdelivery/sv_delivery.lua")
  394.     include("pjdelivery/sv_hooks.lua")
  395.     include("pjdelivery/sv_nets.lua")
  396. elseif CLIENT then
  397.     include("pjdelivery/cl_utils.lua")
  398.     include("pjdelivery/cl_init.lua")
  399.     include("pjdelivery/cl_hud.lua")
  400.     include("pjdelivery/cl_panels.lua")
  401. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement