Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.02 KB | None | 0 0
  1.  
  2. --[[
  3. Added a function to config to copy existing jobrank tables for other jobs:
  4. JBR_CopyRankTable(JobToCopy, Job)
  5. JobToCopy - This is the jobs ranktable it will copy and use
  6. Job - The job that should use the ranktable
  7.  
  8. Example: JBR_CopyRankTable(TEAM_CHIEF, TEAM_POLICE)
  9. This would give TEAM_POLICE the same ranks as TEAM_CHIEF
  10. However this only COPY the table, the progression is still unique for each job
  11. NOTE: THIS FUNCTION HAS TO BE CALLED AT THE END OF THE CONFIG
  12.  
  13. Added command to convert all data from SQLite to MySQL (This overwrites MySQL data, use player command if you wish to convert a specific player)
  14. Restart server once this command has been used as it doesn't update current players
  15. "jobranks_convertsql_all"
  16.  
  17. Config changes:
  18. ]]
  19. JobRanksConfig = JobRanksConfig or {}
  20.  
  21. //Use MySQL or not, edit database in sv_mysql.lua
  22. JobRanksConfig.MYSQLOO = false
  23.  
  24. //Who can access admin commands,menus etc
  25. JobRanksConfig.AdminAccessCustomCheck = function(Player)
  26. if Player:IsAdmin() or Player:IsSuperAdmin() then
  27. return true
  28. else
  29. return false
  30. end
  31. end
  32. //How often should it update and save?
  33. JobRanksConfig.UpdateTimer = 30
  34. //Players Required to be able to earns playtime through timer
  35. JobRanksConfig.PlayersRequired = 0
  36. //Should it give SALARY*Bonus instead of SALARY+Bonus?
  37. //NOTE: This calculates BaseSalary + (BaseSalary/100*Bonus)
  38. //So if you set BonusSalary to 15 it will be 15% of the original salary
  39. JobRanksConfig.BonusSalaryPercent = false
  40. //Disables progression if player is AFK
  41. JobRanksConfig.DisableAFKProgress = true
  42. //NOTE: These uses DarkRPs chatcommand system, which means it will always use / before the command so by default it would be -> /rpromote NICK REASON
  43. //Chatcommand to promote
  44. JobRanksConfig.PromotionChatCommands = {"rpromote"}
  45. //Chatcommand to demote
  46. JobRanksConfig.DemotionChatCommands = {"rdemote"}
  47. //Should ranks reset when you die?
  48. JobRanksConfig.ResetRanksOnDeath = false
  49.  
  50. //HUD Jobranks
  51. JobRanksConfig.HUD = true
  52. //Defined 0-100, 0 is as much left as it can and 100 is as much right as it can
  53. JobRanksConfig.UIW = 100
  54. //Defined 0-100, 0 is as much up as it can and 100 is as much down as it can
  55. JobRanksConfig.UIH = 0
  56. --[[
  57. bar = a bar for progress
  58. time = text for time left
  59. number = numbers only
  60. ]]
  61. JobRanksConfig.HUDType = "number"
  62.  
  63. --[[
  64. 1 = Displays: Job
  65. 2 = Displays: Jobrank
  66. 3 = Displays: Job (JobRank)
  67. ]]
  68. JobRanksConfig.ShowJobType = 3
  69.  
  70. JobRanksConfig.UIBoxColor = Color(100,100,100,200)
  71. JobRanksConfig.UIOutlineColor = Color(200, 200, 200, 200)
  72. JobRanksConfig.UITextColor = Color(255,255,255,200)
  73. JobRanksConfig.BarBackground = Color(0,0,0,255)
  74. JobRanksConfig.Bar = Color(0,200,0,255)
  75.  
  76. JobRanks = JobRanks or {}
  77. JobRanksConfig.JobJoinRestrictments = JobRanksConfig.JobJoinRestrictments or {}
  78. JobRanksConfig.JobPermissionList = JobRanksConfig.JobPermissionList or {}
  79.  
  80. local function JBR_InitRanks()
  81. timer.Simple(3, function()
  82. --[[
  83. JBR_SetupRestrictedJob(Job, RequiredJobs)
  84. Job - The job to be restricted
  85. RequiredJobs - Table of the ranks you must reach in that specific job {[Job] = RequiredRank, [Job2] = RequiredRank} etc
  86. ]]
  87. JBR_SetupRestrictedJob(TEAM_CHIEF, {[TEAM_POLICE] = 8})
  88.  
  89. --[[
  90. JBR_SetupJobPermissionList(Job, AllowedJobs)
  91. Job - Job that is allowed to promote/demote
  92. AllowedJobs - The jobs the job is allowed to promote/demote {[Job] = true, [Job2] = true} etc
  93. ]]
  94. JBR_SetupJobPermissionList(TEAM_POLICE, {[TEAM_POLICE] = true})
  95.  
  96. --[[
  97. JBR_SetupRankTable(Job, MaxRank, BonusSalary, PrefixSeparator, Warrant, Wanted, DisableProgression)
  98. Job - Variable for job for example TEAM_POLICE
  99. MaxRank - Maximum rank achieveable
  100. BonusSalary - Bonus salary for each rank, so Amount*Rank, if bonus is set to 15 and you are rank 3 you would recieve 45$ extra
  101. PrefixSeparator - What should be between Prefix and Name, for example . would be Pvt.ToBadForYou or _ would be Pvt_ToBadForYou
  102. Warrant - Rank required to warrant, set to nil to disable
  103. Wanted - Rank required to Wanted, set to nil to disable
  104. DisableProgression - true or false, true will not allow the player to progress through playtime only through manual promotions
  105. ]]
  106. JBR_SetupRankTable(TEAM_POLICE, 8, 15, ".", 5, 5, false)-- THIS MUST ALWAYS BE FIRST OR IT WILL SETUP FOR THE JOBRANK THAT WAS DEFINED BEFORE THIS
  107.  
  108. --[[
  109. JBR_SetupRank(RankID, TimeRequired, Name, Prefix, Permissions, ExtraStats, Loadout, Icon)
  110. RankID - RankID should start from 1
  111. TimeRequired - First rank MUST always have 0, other ranks must be above the previous one. It counts the difference between OLD and NEW rank
  112. Name - Rank name
  113. Prefix - Prefix before players name
  114.  
  115. Permissions
  116. ----------------------------------------------------
  117. Promote = true/false -> Can this rank promote?
  118. MaxPromotion = Number -> Max rank this rank can promote to
  119. Demote = true/false -> Can this rank demote?
  120. MaxDemotion = Number -> Max rank this rank can demote to
  121.  
  122. Leaving MaxPromotion empty will allow to set to highest rank
  123. Leaving MaxDemotion empty will allow to set to lowest rank
  124.  
  125. NOTE: Only add ranks that you want to grant permissions to, if the rank isn't in this config it can't promote or demote
  126. ----------------------------------------------------
  127.  
  128. ExtraStats - Extra stats (speaks for itself)
  129. Loadout - Extraloadout for this SPECIFIC rank
  130. Icon - Icon path for this ranks icon
  131. ]]
  132. //THE ICONS ARE JUST TEMPLATES, download icons online and insert their path here (Also upload it on workshop or to your FastDL and add it to force download)
  133. JBR_SetupRank(1, 0, "Recruit", "Rct", {Promote = false, Demote = false}, {Health = 5, Armor = 5}, {}, Material("jobranks/police/rank1.png"))
  134. JBR_SetupRank(2, 1500, "Deputy", "Dpt", {Promote = false, Demote = false}, {Health = 10, Armor = 10}, {}, Material("jobranks/police/rank2.png"))
  135. JBR_SetupRank(3, 3000, "Detective", "Det", {Promote = false, Demote = false}, {Health = 15, Armor = 15}, {}, Material("jobranks/police/rank3.png"))
  136. JBR_SetupRank(4, 6000, "Sergeant", "Sgt", {Promote = false, Demote = false}, {Health = 20, Armor = 20}, {}, Material("jobranks/police/rank4.png"))
  137. JBR_SetupRank(5, 12000, "Lieutenant", "Lt", {Promote = false, Demote = true, MaxDemotion = 4}, {Health = 25, Armor = 25}, {"weapon_pumpshotgun2"}, Material("jobranks/police/rank5.png"))
  138. JBR_SetupRank(6, 20000, "Captain", "Cpt", {Promote = true, Demote = false, MaxPromotion = 5}, {Health = 30, Armor = 30}, {}, Material("jobranks/police/rank6.png"))
  139. JBR_SetupRank(7, 30000, "Major", "Maj", {Promote = true, Demote = true, MaxPromotion = 5, MaxDemotion = 3}, {Health = 35, Armor = 35}, {"weapon_mp52"}, Material("jobranks/police/rank7.png"))
  140. JBR_SetupRank(8, 45000, "Inspector", "Insp", {Promote = true, Demote = true}, {Health = 40, Armor = 40}, {}, Material("jobranks/police/rank8.png"))
  141.  
  142. --[[
  143. RankID - Rank to setup for, set to false if for all ranks
  144. Function - Custom lua function
  145.  
  146. NOTE: ONLY SETUP CUSTOM LUA FUNCTION IF YOU KNOW WHAT YOU ARE DOING
  147. ]]
  148. JBR_SetupRankSpawnFunc(false, function(Player) print(Player, "all ranks") end) -- This custom lua function will run for ALL ranks upon SPAWN
  149. JBR_SetupRankSpawnFunc(1, function(Player) print(Player, "rank 1") end) -- This custom lua function will run for ONLY RANK 1 upon SPAWN
  150.  
  151. --[[
  152. JBR_SetupRankModel(RankID, ModelTbl)
  153. RankID - Rank to setup for
  154. ModelTbl - Model information, {{Model = "MODELPATH", Bodygroups{{BodygroupID, Amount}}, Skin = SKINID}}
  155. ]]
  156. JBR_SetupRankModel(6, {{Model = "models/player/police.mdl", Bodygroups = {{0,0},{2,1}}, Skin = 1}})--Sets model, two custom bodygroups and skin to 1
  157. --Skipped rank 2, it will now set default model on rank 2
  158. JBR_SetupRankModel(3, {{Model = "models/player/police.mdl", Bodygroups = {{0,0},{2,1}}, Skin = 1},{Model = "models/player/police_fem.mdl", Bodygroups = nil, Skin = 3}}) -- EXAMPLE OF MULTIPLY MODELS FOR ONE RANK
  159. JBR_SetupRankModel(4, {{Model = "models/player/police_fem.mdl", Bodygroups = nil, Skin = 3}})--Sets model, no bodygroups, sets skin to 3
  160. JBR_SetupRankModel(5, {{Model = nil, Bodygroups = nil, Skin = 2}})--Sets default model, no bodygroups, sets skin to 2
  161.  
  162. --[[
  163. JBR_AddLoadout(RankID, Weapons)
  164. RankID - RankID
  165. Weapons - List of weapons
  166. This adds the loadout to this rank AND all ranks ABOVE this rank
  167. ]]
  168. JBR_AddLoadout(5, {"weapon_pumpshotgun2"})
  169. JBR_AddLoadout(7, {"weapon_mp52"})
  170.  
  171. --[[
  172. JBR_AddEntity(RankID, Entities)
  173. RankID - RankID required to buy the entities
  174. Entities - List of entities
  175. This will allow the input rank and all ABOVE this rank to purchase these entities
  176. ]]
  177. JBR_AddEntity(5, {"money_printer"})
  178.  
  179. --[[
  180. JBR_AddShipment(RankID, Shipments)
  181. RankID - RankID required to buy the shipments
  182. Shipments - List of shipments
  183. This will allow the input rank and all ABOVE this rank to purchase these shipments
  184. ]]
  185. JBR_AddShipment(5, {"weapon_pumpshotgun2"})
  186.  
  187. JBR_SetupRankTable(GARDIENDELAPAIX, 4, 30, ".", 1, 1, false) -- THIS MUST ALWAYS BE FIRST OR IT WILL SETUP FOR THE JOBRANK THAT WAS DEFINED BEFORE THIS
  188. JBR_SetupRank(1, 0, "Chief Recruit", "Rct", {Promote = false, Demote = false}, {Health = 5, Armor = 5}, {}, nil)
  189. JBR_SetupRank(2, 5000, "Deputy Chief", "Dpt", {Promote = false, Demote = false}, {Health = 25, Armor = 25}, {}, nil)
  190. JBR_SetupRank(3, 10000, "Assistant Chief", "Asst", {Promote = false, Demote = false}, {Health = 50, Armor = 50}, {}, nil)
  191. JBR_SetupRank(4, 20000, "Chief of Police", "Chief", {Promote = true, Demote = true}, {Health = 100, Armor = 100}, {}, nil)
  192. JBR_SetupRankModel(1, {{Model = "models/darkley/sapeur_p03.mdl", Bodygroups = {{0,1}, {1,2}}, Skin = 1}})
  193.  
  194. JBR_SetupRankTable(TEAM_MEDIC, 9, 15, ".", nil, nil, false) -- THIS MUST ALWAYS BE FIRST OR IT WILL SETUP FOR THE JOBRANK THAT WAS DEFINED BEFORE THIS
  195. JBR_SetupRank(1, 0, "Medic Trainee", nil, {Promote = false, Demote = false}, nil, {}, nil)
  196. JBR_SetupRank(2, 1500, "Medic", nil, {Promote = false, Demote = false}, nil, {}, nil)
  197. JBR_SetupRank(3, 3000, "Medical Scientist", nil, {Promote = false, Demote = false}, nil, {}, nil)
  198. JBR_SetupRank(4, 6000, "Junior Doctor", nil, {Promote = false, Demote = false}, nil, {}, nil)
  199. JBR_SetupRank(5, 12000, "Doctor", nil, {Promote = false, Demote = false}, nil, {}, nil)
  200. JBR_SetupRank(6, 20000, "Plastic Surgeon", nil, {Promote = false, Demote = false}, nil, {}, nil)
  201. JBR_SetupRank(7, 30000, "Brain Surgeon", nil, {Promote = false, Demote = false}, nil, {}, nil)
  202. JBR_SetupRank(8, 45000, "Chief Physician", nil, {Promote = false, Demote = false}, nil, {}, nil)
  203. JBR_SetupRank(9, 60000, "Hospital Manager", nil, {Promote = false, Demote = false}, nil, {}, nil)
  204.  
  205. JBR_SetupRankTable(TEAM_MAYOR, 7, 45, ".", 1, 1, false) -- THIS MUST ALWAYS BE FIRST OR IT WILL SETUP FOR THE JOBRANK THAT WAS DEFINED BEFORE THIS
  206. JBR_SetupRank(1, 0, "Candidate", nil, {Promote = false, Demote = false}, nil, {}, nil)
  207. JBR_SetupRank(2, 5000, "Politician", nil, {Promote = false, Demote = false}, nil, {}, nil)
  208. JBR_SetupRank(3, 10000, "Vice Mayor", nil, {Promote = false, Demote = false}, nil, {}, nil)
  209. JBR_SetupRank(4, 15000, "Mayor", nil, {Promote = false, Demote = false}, nil, {}, nil)
  210. JBR_SetupRank(5, 20000, "Vice President", nil, {Promote = false, Demote = false}, nil, {}, nil)
  211. JBR_SetupRank(6, 25000, "President", nil, {Promote = false, Demote = false}, nil, {}, nil)
  212. JBR_SetupRank(7, 30000, "Supreme Leader", nil, {Promote = false, Demote = false}, nil, {}, nil)
  213.  
  214. --[[
  215. NOTE: THIS FUNCTION HAS TO BE CALLED AT THE END OF THE CONFIG
  216.  
  217. JBR_CopyRankTable(JobToCopy, Job)
  218. JobToCopy - This is the jobs ranktable it will copy and use
  219. Job - The job that should use the ranktable
  220.  
  221. Example: JBR_CopyRankTable(TEAM_CHIEF, TEAM_POLICE)
  222. This would give TEAM_POLICE the same ranks as TEAM_CHIEF
  223. However this only COPY the table, the progression is still unique for each job
  224. ]]
  225. //Just an example, copies TEAM_POLICE ranktable and sets TEAM_POLICE ranktable to this.
  226. JBR_CopyRankTable(TEAM_POLICE, TEAM_POLICE)
  227. end)
  228. end
  229.  
  230. hook.Add("DarkRPFinishedLoading", "JBR_InitRanks", function()
  231. if DCONFIG then
  232. hook.Add("DConfigDataLoaded", "JBR_InitRanks", JBR_InitRanks)
  233. elseif ezJobs then
  234. hook.Add("ezJobsLoaded", "JBR_InitRanks", JBR_InitRanks)
  235. else
  236. hook.Add("loadCustomDarkRPItems", "JBR_InitRanks", JBR_InitRanks)
  237. end
  238. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement