├── LICENSE.md ├── README.md ├── header.png ├── lua ├── darkrp_modules │ └── levels │ │ ├── cl_hud.lua │ │ ├── sh_config.lua │ │ ├── sh_core.lua │ │ ├── sv_addways.lua │ │ ├── sv_data.lua │ │ └── sv_levels.lua ├── entities │ ├── vrondakis_book │ │ ├── cl_init.lua │ │ ├── init.lua │ │ └── shared.lua │ └── vrondakis_printer │ │ ├── cl_init.lua │ │ ├── init.lua │ │ └── shared.lua ├── plugins │ ├── levels │ │ ├── cl_init.lua │ │ ├── init.lua │ │ ├── sh_commands.lua │ │ └── shared.lua │ └── readme.txt ├── ulx │ └── modules │ │ └── sh │ │ └── levels.lua └── weapons │ └── pocket │ ├── cl_menu.lua │ ├── shared.lua │ └── sv_init.lua ├── materials └── vrondakis │ └── xp_bar.png └── resource └── fonts └── francoisone.ttf /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Manolis Vrondakis 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy and modify subject to the following conditions: 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 8 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 11 | SOFTWARE. 12 | 13 | Re-distribution is not permitted. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DarkRP Leveling System 2 | ====================== 3 | For DarkRP 2.7.0 and above. Adds leveling functionality and allows you to limit item purchasing based on a players level. 4 | 5 | 6 | Features 7 | ------- 8 | **7 Money Printers** - They work like normal printers, apart from the fact that they store money and XP. 9 | 10 | **3 xp books** - Big, medium and small books that give you XP. 11 | 12 | **Database Support** - This script integrates directly into DarkRP's database. This means that it works with SQLite and MySQL! No tweaky setup required! 13 | 14 | **HUD** - The HUD looks good and provides level infomation to players. The XP bar is animated, and fits right in! 15 | 16 | **Easy Installation** - Drag and drop one folder 17 | 18 | **Supports future versions of DarkRP** - This script doesn't edit any of DarkRP's core files, so you don't have to worry about reinstalling the script when you update 19 | 20 | **ULX Support and serverguard** - Allows you to set levels and add/remove XP with ULX or serverguard. 21 | 22 | **Huge Configuration** - This script is VERY easy to customize. You can change everything from one file. 23 | 24 | -------------------------------------------------------------------------------- /header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uen/Leveling-System/7e083636174777cc580100379d8ff64a25b4f55a/header.png -------------------------------------------------------------------------------- /lua/darkrp_modules/levels/cl_hud.lua: -------------------------------------------------------------------------------- 1 | // Love Manolis Vrondakis. @vrondakis 2 | 3 | surface.CreateFont( "HeadBar", { // XP Bar font 4 | font = "Tahoma", 5 | size = 13, 6 | weight = 500, 7 | blursize = 0, 8 | scanlines = 0, 9 | } ) 10 | 11 | surface.CreateFont("LevelPrompt", { // Level prompt font 12 | font = "Francois One", 13 | size = 70, 14 | weight = 500, 15 | blursize = 0, 16 | scanlines = 0, 17 | antialias = true, 18 | underline = false, 19 | italic = false, 20 | strikeout = false, 21 | symbol = false, 22 | rotary = false, 23 | shadow = false, 24 | additive = false, 25 | outline = false, 26 | }) 27 | 28 | 29 | // I hate this fucking DrawDisplay function. Eurgh. 30 | local function DrawDisplay() 31 | local shouldDraw, players = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_EntityDisplay") 32 | if shouldDraw == false then return end 33 | local shootPos = LocalPlayer():GetShootPos() 34 | local aimVec = LocalPlayer():GetAimVector() 35 | if(LevelSystemConfiguration.DisplayLevel) then 36 | for k, ply in pairs(players or player.GetAll()) do 37 | if not ply:Alive() then continue end 38 | if ply:GetRenderMode() == RENDERMODE_TRANSALPHA then continue end // player is cloaked (ULX) 39 | if ply == LocalPlayer() then continue end 40 | local hisPos = ply:GetShootPos() 41 | if GAMEMODE.Config.globalshow and ply ~= localplayer then 42 | local pos = ply:EyePos() 43 | pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes 44 | pos = pos:ToScreen() 45 | pos.y = pos.y-20 46 | draw.DrawText("Level: "..(ply:getDarkRPVar("level") or 0), "DarkRPHUD2", pos.x+1, pos.y -56, Color(0,0,0,255), 1) 47 | draw.DrawText("Level: "..(ply:getDarkRPVar("level") or 0), "DarkRPHUD2", pos.x, pos.y -55, Color(255,255,255,200), 1) 48 | elseif not GAMEMODE.Config.globalshow and hisPos:Distance(shootPos) < 250 then 49 | local pos = hisPos - shootPos 50 | local unitPos = pos:GetNormalized() 51 | 52 | local trace = util.QuickTrace(shootPos, pos, localplayer) 53 | if trace.Hit and trace.Entity ~= ply then return end 54 | local pos = ply:EyePos() 55 | pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes 56 | pos = pos:ToScreen() 57 | pos.y = pos.y-20 58 | draw.DrawText("Level: "..(ply:getDarkRPVar("level") or 0), "DarkRPHUD2", pos.x, pos.y -58, Color(0,0,0,255), 1) 59 | draw.DrawText("Level: "..(ply:getDarkRPVar("level") or 0), "DarkRPHUD2", pos.x+1, pos.y -57, Color(255,255,255,200), 1) 60 | end 61 | end 62 | end 63 | 64 | local tr = LocalPlayer():GetEyeTrace() 65 | 66 | end 67 | local OldXP = 0 68 | local xp_bar = Material("vrondakis/xp_bar.png","noclamp smooth") 69 | local function HUDPaint() 70 | if not LevelSystemConfiguration then return end 71 | local PlayerLevel = LocalPlayer():getDarkRPVar("level") 72 | local PlayerXP = LocalPlayer():getDarkRPVar("xp") 73 | 74 | local percent = ((PlayerXP or 0)/(((10+(((PlayerLevel or 1)*((PlayerLevel or 1)+1)*90))))*LevelSystemConfiguration.XPMult)) // Gets the accurate level up percentage 75 | 76 | local drawXP = Lerp(8*FrameTime(),OldXP,percent) 77 | OldXP = drawXP 78 | local percent2 = percent*100 79 | percent2 = math.Round(percent2) 80 | percent2 = math.Clamp(percent2, 0, 99) //Make sure it doesn't round past 100% 81 | 82 | if LevelSystemConfiguration.EnableBar then 83 | // Draw the XP Bar 84 | surface.SetDrawColor(0,0,0,200) 85 | surface.DrawRect(ScrW()/2-300,(LevelSystemConfiguration.XPBarYPos or 0),580,25) 86 | 87 | // Draw the XP Bar before the texture 88 | surface.SetDrawColor(LevelSystemConfiguration.LevelBarColor[1],LevelSystemConfiguration.LevelBarColor[2],LevelSystemConfiguration.LevelBarColor[3],255) 89 | surface.DrawRect(ScrW()/2-300,(LevelSystemConfiguration.XPBarYPos or 0),580*drawXP,25) 90 | 91 | //Render the texture 92 | surface.SetMaterial(xp_bar) 93 | surface.SetDrawColor(255,255,255,255) 94 | surface.DrawTexturedRect( ScrW()/2-371, 0+(LevelSystemConfiguration.XPBarYPos or 0), 742,46) 95 | end 96 | 97 | // Render the text 98 | if LevelSystemConfiguration.BarText then 99 | draw.DrawText("Level "..(LocalPlayer():getDarkRPVar("level") or 0).." - "..percent2 .."%", "HeadBar", ScrW()/2,7+(LevelSystemConfiguration.XPBarYPos or 0),(LevelSystemConfiguration.XPTextColor or Color(255,255,255,255)), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) 100 | end 101 | 102 | if LevelSystemConfiguration.LevelText then 103 | draw.SimpleText("Level: " ..(LocalPlayer():getDarkRPVar("level") or 0), "LevelPrompt", LevelSystemConfiguration.LevelTextPos[1],ScrH()-LevelSystemConfiguration.LevelTextPos[2],((Color(0,0,0,255))), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT) 104 | draw.SimpleText("Level: " ..(LocalPlayer():getDarkRPVar("level") or 0), "LevelPrompt", LevelSystemConfiguration.LevelTextPos[1]+1,ScrH()-LevelSystemConfiguration.LevelTextPos[2]-1,(LevelSystemConfiguration.LevelColor or (Color(0,0,0,255))), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT) 105 | end 106 | 107 | DrawDisplay() 108 | end 109 | hook.Add("HUDPaint", "manolis:MVLevels:HUDPaintA", HUDPaint) // IS THAT UNIQUE ENOUGH FOR YOU, FUCKING GMOD HOOKING BULLSHIT. 110 | 111 | 112 | -------------------------------------------------------------------------------- /lua/darkrp_modules/levels/sh_config.lua: -------------------------------------------------------------------------------- 1 | ///////////////////////// 2 | // Configuration file // 3 | ///////////////////////// 4 | 5 | LevelSystemConfiguration = {} -- Ignore 6 | local Printers = {} -- Ignore 7 | local Books = {} -- Ignore 8 | 9 | //Language settings 10 | LevelSystemConfiguration.Language = "EN" -- (available: FR, EN, PL, RU, zh-CN) 11 | 12 | //Hud settings 13 | LevelSystemConfiguration.EnableBar = true -- Is the XP Bar enabled? 14 | LevelSystemConfiguration.BarText = true -- Is the bar text enabled? 15 | LevelSystemConfiguration.XPTextColor = Color(255,255,255,255) -- The color of the XP percentage HUD element. 16 | LevelSystemConfiguration.LevelBarColor = {6,116,255} -- The color of the XP bar. (Sorry this one is different. It is still {R,G,B}) 17 | LevelSystemConfiguration.XPBarYPos = 0 -- Y position of the XP bar 18 | LevelSystemConfiguration.LevelText = true -- Enable the white text on left bottom? 19 | LevelSystemConfiguration.LevelColor = Color(255,255,255,255) -- The color of the "Level: 1" HUD element. White looks best. (This setting is nullified if you have the prestige system) 20 | LevelSystemConfiguration.LevelTextPos = {1.5, 180.0} -- The position of the LevelText. Y starts from bottom. Fiddle with it 21 | LevelSystemConfiguration.DisplayLevel = true -- Show player levels when you look at them 22 | LevelSystemConfiguration.GreenJobBars = true -- Are the green bars at the bottom of jobs enabled? KEEP THIS TRUE! 23 | LevelSystemConfiguration.GreenAllBars = true -- Are the green bars at the bottom of everything but jobs enabled? Recommended(true) 24 | 25 | //Kill settings 26 | LevelSystemConfiguration.KillModule = true -- Give XP + Money for kills! -- Next 2 settings control this. 27 | LevelSystemConfiguration.Friendly = true -- Only take away money / give XP if the killer is a lower level/same level than the victim. (Recommended:true) 28 | LevelSystemConfiguration.TakeAwayMoneyAmount = 100 -- How much money to take away from players when they are killed and add to the killer. You can change this to 0 if none. The XP amount is dynamic. 29 | LevelSystemConfiguration.NPCXP = true -- Give XP when an NPC is killed? 30 | LevelSystemConfiguration.NPCXPAmount = 10 -- Amount of XP to give when an NPC is killed 31 | 32 | //Timer settings 33 | LevelSystemConfiguration.TimerModule = true -- Give XP to everybody every howeverlong 34 | LevelSystemConfiguration.Timertime = 120 -- How much time (in seconds) until everybody gets given XP 35 | LevelSystemConfiguration.TimerXPAmount = 50 -- How much XP to give each time it goes off 36 | LevelSystemConfiguration.TimerXPAmountVip = 100 -- How much XP to give for vip players each time it goes off 37 | LevelSystemConfiguration.TimerXPVipGroups = {"vip", "premium"} -- The vip groups 38 | 39 | //XP settings 40 | LevelSystemConfiguration.XPMult = 1 -- How hard it is to level up. 2 would require twice as much XP, ect. 41 | LevelSystemConfiguration.MaxLevel = 99 -- The max level 42 | LevelSystemConfiguration.ContinueXP = false -- If remaining XP continues over to next levels. I recommend this to be false. Seriously. What if a level 1 gets 99999999 XP somehow? He is level 99 so quickly. 43 | LevelSystemConfiguration.BoughtXP = true -- Does the player gain xp from buying something (shipment/entity) 44 | 45 | //Printer settings 46 | LevelSystemConfiguration.PrinterSound = true -- Give the printers sounds? 47 | LevelSystemConfiguration.PrinterMaxP = 4 -- How many times a printer can print before stopping. Change this to 0 if you want infine. 48 | LevelSystemConfiguration.PrinterMax = 4 -- How many printers of a certain type a player can own at any one time 49 | LevelSystemConfiguration.PrinterOverheat = false -- Can printers overheat? 50 | LevelSystemConfiguration.PrinterTime = 120 -- How long it takes printers to print 51 | LevelSystemConfiguration.PrinterCanCollect = true -- Can players collect from printers that are 5 levels above their level? (Recommended: false) 52 | LevelSystemConfiguration.PrinterEpilepsy = true -- If printers flash different colors when they have money in them. 53 | 54 | //Book settings 55 | LevelSystemConfiguration.BookMax = 4 -- How many Books of a certain type a player can own at any one time 56 | LevelSystemConfiguration.BookOnTouch = true -- Consume the book on touch? 57 | 58 | 59 | /*Template Code for printers/* 60 | local Printer= {} -- Leave this line 61 | Printer.Name = "Your Printer Name" 62 | Printer.Type = "yourprintername" -- A UNIQUE identifier STRING, can be anything. NO SPACES! The player does not see this. 63 | Printer.Category = "printers" -- The category of the printer (See http:--wiki.darkrp.com/index.php/DarkRP:Categories) 64 | Printer.XPPerPrint = 10 -- How much XP to give a player every time they print. 65 | Printer.MoneyPerPrint = 50 -- How much money to give a player every time they print. 66 | Printer.Color = Color(255,255,255,255) -- The color of the printer. Setting it to (255,255,255,255) will make it the normal prop color. 67 | Printer.Model = "models/props_lab/reciever01b.mdl" -- The model of the printer. To find the path of a model, right click it in the spawn menu and click "Copy to Clipboard" 68 | Printer.Prestige = 0 -- The prestige you have to be to buy the printer. Only works with the prestige DLC on Gmodstore. 69 | Printer.Allowed = {} -- Same as DarkRP .allowed 70 | Printer.CustomCheck = function(ply) return CLIENT or table.HasValue({"vip"}, ply:GetNWString("usergroup")) end -- Custom check, this one will make the printer vip only 71 | Printer.CustomCheckFailMsg = "This printer is vip only" -- Message to display if the player can"t buy the entity 72 | table.insert(Printers,Printer) -- Leave this line 73 | */ 74 | 75 | // Default printers: 76 | local Printer={} 77 | Printer.Name = "Regular Printer" 78 | Printer.Type = "regularprinter" 79 | Printer.XPPerPrint = 65 80 | Printer.MoneyPerPrint = 100 81 | Printer.Color = Color(255,255,255,255) 82 | Printer.Model = "models/props_lab/reciever01b.mdl" 83 | Printer.Price = 1000 84 | Printer.Level = 1 85 | Printer.Prestige = 0 86 | table.insert(Printers,Printer) 87 | 88 | local Printer={} 89 | Printer.Name = "Golden Money Printer" 90 | Printer.Type = "goldenprinter" 91 | Printer.XPPerPrint = 300 92 | Printer.MoneyPerPrint = 300 93 | Printer.Color = Color(255,215,0) 94 | Printer.Model = "models/props_lab/reciever01b.mdl" 95 | Printer.Price = 3000 96 | Printer.Level = 10 97 | Printer.Prestige = 0 98 | table.insert(Printers,Printer) 99 | 100 | local Printer={} 101 | Printer.Name = "Ruby Money Printer" 102 | Printer.Type = "rubyprinter" 103 | Printer.XPPerPrint = 1069 104 | Printer.MoneyPerPrint = 1200 105 | Printer.Color = Color(255,0,0) 106 | Printer.Model = "models/props_lab/reciever01a.mdl" 107 | Printer.Price = 5000 108 | Printer.Level = 20 109 | Printer.Prestige = 0 110 | table.insert(Printers,Printer) 111 | 112 | local Printer={} 113 | Printer.Name = "Platinum Money Printer" 114 | Printer.Type = "platprinter" 115 | Printer.XPPerPrint = 1800 116 | Printer.MoneyPerPrint = 1500 117 | Printer.Color = Color(255,255,255) 118 | Printer.Model = "models/props_c17/consolebox03a.mdl" 119 | Printer.Price = 10000 120 | Printer.Level = 30 121 | Printer.Prestige = 0 122 | table.insert(Printers,Printer) 123 | 124 | local Printer={} 125 | Printer.Name = "Diamond Money Printer" 126 | Printer.Type = "diamondprinter" 127 | Printer.XPPerPrint = 2500 128 | Printer.MoneyPerPrint = 5000 129 | Printer.Color = Color(135,200,250) 130 | Printer.Model = "models/props_c17/consolebox01a.mdl" 131 | Printer.Price = 50000 132 | Printer.Level = 40 133 | Printer.Prestige = 0 134 | table.insert(Printers,Printer) 135 | 136 | local Printer={} 137 | Printer.Name = "Emerald Money Printer" 138 | Printer.Type = "emeraldprinter" 139 | Printer.XPPerPrint = 3550 140 | Printer.MoneyPerPrint = 10000 141 | Printer.Color = Color(0,100,0) 142 | Printer.Model = "models/props_c17/consolebox01a.mdl" 143 | Printer.Price = 100000 144 | Printer.Level = 50 145 | Printer.Prestige = 0 146 | table.insert(Printers,Printer) 147 | 148 | local Printer={} 149 | Printer.Name = "Unubtainium Money Printer" 150 | Printer.Type = "unubprinter" 151 | Printer.XPPerPrint = 3500 152 | Printer.MoneyPerPrint = 15000 153 | Printer.Color = Color(255,255,255) 154 | Printer.Model = "models/props_lab/harddrive01.mdl" 155 | Printer.Price = 120000 156 | Printer.Level = 60 157 | Printer.Prestige = 0 158 | table.insert(Printers,Printer) 159 | 160 | /*Template Code for books/* 161 | local Book= {} -- Leave this line 162 | Book.Name = "Your Book Name" 163 | Book.Type = "yourbookname" -- A UNIQUE identifier STRING, can be anything. NO SPACES! The player does not see this. 164 | Book.Category = "Books" -- The category of the Book (See http:--wiki.darkrp.com/index.php/DarkRP:Categories) 165 | Book.Color = Color(255,255,255,255) -- The color of the Book. Setting it to (255,255,255,255) will make it the normal prop color. 166 | Book.Model = "models/props_lab/binderblue.mdl" -- The model of the Book. To find the path of a model, right click it in the spawn menu and click "Copy to Clipboard" 167 | Book.Prestige = 0 -- The prestige you have to be to buy the Book. Only works with the prestige DLC on Gmodstore. 168 | Book.Allowed = {} -- Same as DarkRP .allowed 169 | Book.CustomCheck = function(ply) return CLIENT or table.HasValue({"vip"}, ply:GetNWString("usergroup")) end -- Custom check, this one will make the printer vip only 170 | Book.CustomCheckFailMsg = "This book is vip only" -- Message to display if the player can"t buy the entity 171 | table.insert(Books,Book) -- Leave this line 172 | */ 173 | 174 | // Default books: 175 | local Book={} 176 | Book.Name = "Small Book" 177 | Book.Type = "smallbook" 178 | Book.Color = Color(255,255,255) 179 | Book.Model = "models/props_lab/binderblue.mdl" 180 | Book.Price = 750 181 | Book.XP = 500 182 | Book.Level = 1 183 | Book.Prestige = 0 184 | table.insert(Books,Book) 185 | 186 | local Book={} 187 | Book.Name = "Medium Book" 188 | Book.Type = "mediumbook" 189 | Book.Color = Color(255,255,255) 190 | Book.Model = "models/props_lab/bindergreen.mdl" 191 | Book.Price = 3000 192 | Book.XP = 2000 193 | Book.Level = 1 194 | Book.Prestige = 0 195 | table.insert(Books,Book) 196 | 197 | local Book={} 198 | Book.Name = "Big Book" 199 | Book.Type = "bigbook" 200 | Book.Color = Color(255,255,255) 201 | Book.Model = "models/props_lab/binderredlabel.mdl" 202 | Book.Price = 7500 203 | Book.XP = 5000 204 | Book.Level = 1 205 | Book.Prestige = 0 206 | table.insert(Books,Book) 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | // Ignore everything under this line. 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | local en_language = { 235 | lvl_buy_entity = "You\'re not the right level to buy this!", -- Error message when someone can't buy an entity 236 | lvl_take_job = "You\'re not the right level to become this!", -- Error message when someone can't take a job 237 | lvl_kill_notify = "You got %s XP and %s for killing %s", -- Notification to the killer when he kill someone (vars: XP, money, victime) 238 | lvl_kill_notify2 = "You got %s XP for killing %s", -- Notification to the killer when he kill someone (vars: XP, victime) 239 | lvl_kill_notify3 = "You killed %s", -- Notification to the killer when he kill someone (vars: victime) 240 | lvl_kill_npc = "You got %s XP for killing an NPC.", -- Notification to the killer when he kill a npc (vars: XP) 241 | lvl_death = "You died and lost %s!", -- Notification to the victim when he lost money on death (vars: money) 242 | lvl_play_on = "You got %s XP for playing on the server.", -- Notification to everyone when they gain xp by the timer (vars: XP) 243 | lvl_recieve_xp = "You got %s XP!", -- Notification to the player when he recieve xp (vars: ammount) 244 | lvl_reach_level = "%s has reached level %s!", -- Notification to everyone when someone reach a level (vars: name, PlayerLevel) 245 | lvl_book_notify = "You got %s XP for using the book %s!", -- Notification to the player when he use a book (vars: XP, bookname) 246 | lvl_printer_use = "You got %s XP and %s from this printer.", -- Notification to the player when he use a printer (vars: XP, money) 247 | lvl_printer_level = "You need to be a higher level to use this!", -- Notification to the player when he can't use a printer 248 | } 249 | DarkRP.addLanguage("en", en_language) 250 | 251 | local fr_language = { 252 | lvl_buy_entity = "Vous n\'avez pas le bon level pour acheter ça!", 253 | lvl_take_job = "Vous n\'avez pas le bon level pour avoir ce job!", 254 | lvl_kill_notify = "Vous avez reçu %s XP et %s pour avoir tué %s", 255 | lvl_kill_notify2 = "Vous avez reçu %s XP pour avoir tué %s", 256 | lvl_kill_notify3 = "Vous avez tué %s", 257 | lvl_kill_npc = "Vous avez reçu %s XP pour avoir tué un NPC.", 258 | lvl_death = "Vous êtes mort et avez perdu %s!", 259 | lvl_play_on = "Vous avez reçu %s XP Pour avoir joué sur le serveur.", 260 | lvl_recieve_xp = "Vous avez reçu %s XP!", 261 | lvl_reach_level = "%s a atteint le niveau %s!", 262 | lvl_book_notify = "Vous avez reçu %s XP pour avoir utilisé un livre %s!", 263 | lvl_printer_use = "Vous avez reçu %s XP et %s du printer.", 264 | lvl_printer_level = "Vous devez avoir un plus haut niveau pour utiliser ce printer!", 265 | } 266 | DarkRP.addLanguage("fr", fr_language) 267 | 268 | local pl_language = { 269 | lvl_buy_entity = "Ty nie masz odpowiedniego poziomu by to kupić!", 270 | lvl_take_job = "Ty nie masz odpowiedniego poziomu by tym zostać!", 271 | lvl_kill_notify = "Ty masz %s XP i %s za zabicie %s", 272 | lvl_kill_notify2 = "Ty masz %s XP za zabicie %s", 273 | lvl_kill_notify3 = "Zabiłeś %s", 274 | lvl_kill_npc = "Ty masz %s XP za zabicie NPC.", 275 | lvl_death = "Zmarłeś i straciłeś %s!", 276 | lvl_play_on = "Ty masz %s XP za grę na serwerze.", 277 | lvl_recieve_xp = "Ty masz %s XP!", 278 | lvl_reach_level = "%s osiągnął poziom %s!", 279 | lvl_book_notify = "Ty masz %s XP za korzystanie z książki %s!", 280 | lvl_printer_use = "Ty masz %s XP i %s z tej drukarki.", 281 | lvl_printer_level = "Aby móc z tego korzystać, musisz być na wyższym poziomie!", 282 | } 283 | DarkRP.addLanguage("pl", pl_language) 284 | 285 | local ru_language = { 286 | lvl_buy_entity = "Вы не того уровня, чтобы купить это!", 287 | lvl_take_job = "Вы не того уровня для этой работы!", 288 | lvl_kill_notify = "Вы получили %s опыта и %s за убийство %s", 289 | lvl_kill_notify2 = "Вы получили %s опыта за убийство %s", 290 | lvl_kill_notify3 = "Вы убили %s", 291 | lvl_kill_npc = "Вы получили %s опыта за убийство NPC.", 292 | lvl_death = "Вы умерли и потеряли %s!", 293 | lvl_play_on = "Вы получили %s опыта за игру на этом сервере.", 294 | lvl_recieve_xp = "Вы получили %s опыта!", 295 | lvl_reach_level = "%s достиг уровня %s!", 296 | lvl_book_notify = "Вы получили %s опыта за использование книги %s!", 297 | lvl_printer_use = "Вы получили %s опыта и %s из принтера.", 298 | lvl_printer_level = "Вы должны быть более высокого уровня, чтобы использовать это!", 299 | } 300 | DarkRP.addLanguage("ru", ru_language) 301 | 302 | local cn_language = { 303 | lvl_buy_entity = "你没有足够的等级来购买这个!", 304 | lvl_take_job = "你没有足够的等级去就职这个!", 305 | lvl_kill_notify = "你获得了 %s XP 和 %s 作为击杀 %s 的奖励", 306 | lvl_kill_notify2 = "你获得了 %s XP 作为击杀 %s 的奖励", 307 | lvl_kill_notify3 = "你击杀了 %s", 308 | lvl_kill_npc = "你获得了 %s XP 作为击杀了一个NPC的奖励.", 309 | lvl_death = "你因死亡丢失了 %s!", 310 | lvl_play_on = "你获得了 %s XP 作为游玩本服的奖励.", 311 | lvl_recieve_xp = "你获得了 %s XP!", 312 | lvl_reach_level = "%s 提升到了等级 %s!", 313 | lvl_book_notify = "你获得了 %s XP 因为你阅读了书籍: %s", 314 | lvl_printer_use = "你从这个印钞机获得了 %s XP 和 %s.", 315 | lvl_printer_level = "你需要拥有更高的等级才能使用这个!", 316 | } 317 | DarkRP.addLanguage("zh-CN", cn_language) 318 | 319 | 320 | hook.Add("loadCustomDarkRPItems", "manolis:MVLevels:CustomLoad", function() 321 | 322 | for k,v in pairs(Printers) do 323 | local Errors = {} 324 | if not type(v.Name) == "string" then table.insert(Errors, "The name of a printer is INVALID!") end 325 | if not type(v.Type) == "string" then table.insert(Errors, "The type of a printer is INVALID!") end 326 | if not type(v.XPPerPrint) == "number" then table.insert(Errors, "The XP of a printer is INVALID!") end 327 | if not type(v.MoneyPerPrint) == "number" then table.insert(Errors, "The money of a printer is INVALID!") end 328 | if not type(v.Color) == "table" then table.insert(Errors, "The color of a printer is INVALID!") end 329 | if not type(v.Model) == "string" then table.insert(Errors, "The model of a printer is INVALID!") end 330 | if not type(v.Price) == "number" then table.insert(Errors, "The price of a printer is INVALID!") end 331 | if not type(v.Category) == "string" then v.Category="" end 332 | if not type(v.Level) == "number" then table.insert(Errors, "The level of a printer is INVALID!") end 333 | local ErrorCount = 0 334 | for k,v in pairs(Errors) do 335 | error(v) 336 | ErrorCount = ErrorCount + 1 337 | end 338 | 339 | 340 | 341 | if not(ErrorCount==0) then return false end 342 | 343 | local t = { 344 | ent = "vrondakis_printer", 345 | model = v.Model, 346 | category = v.Category, 347 | price = v.Price, 348 | prestige = (v.Prestige or 0), 349 | printer = true, 350 | level = v.Level, 351 | max = LevelSystemConfiguration.PrinterMax, 352 | cmd = "buyvrondakis"..v.Type.."printer", 353 | allowed = v.Allowed, 354 | vrondakisName = v.Name, 355 | vrondakisType = v.Type, 356 | vrondakisXPPerPrint = v.XPPerPrint, 357 | vrondakisMoneyPerPrint = v.MoneyPerPrint, 358 | vrondakisColor = v.Color, 359 | vrondakisModel = v.Model, 360 | customCheck = (v.CustomCheck or function() return true end), 361 | CustomCheckFailMsg = v.CustomCheckFailMsg, 362 | vrondakisPrinterOverheat = LevelSystemConfiguration.PrinterOverheat, 363 | vrondakisPrinterMaxP = LevelSystemConfiguration.PrinterMaxP, 364 | vrondakisPrinterTime = LevelSystemConfiguration.PrinterTime, 365 | vrondakisPrinterCanCollect = LevelSystemConfiguration.PrinterCanCollect, 366 | vrondakisPrinterEpilepsy = LevelSystemConfiguration.PrinterEpilepsy 367 | } 368 | 369 | if(v.DParams) then 370 | for k,v in pairs(v.DParams) do 371 | t[k] = v 372 | end 373 | end 374 | 375 | DarkRP.createEntity(v.Name,t) 376 | 377 | end 378 | 379 | 380 | 381 | 382 | 383 | for k,v in pairs(Books) do 384 | local Errors = {} 385 | if not type(v.Name) == "string" then table.insert(Errors, "The name of a book is INVALID!") end 386 | if not type(v.Type) == "string" then table.insert(Errors, "The type of a book is INVALID!") end 387 | if not type(v.Color) == "table" then table.insert(Errors, "The color of a book is INVALID!") end 388 | if not type(v.Model) == "string" then table.insert(Errors, "The model of a book is INVALID!") end 389 | if not type(v.Price) == "number" then table.insert(Errors, "The price of a book is INVALID!") end 390 | if not type(v.XP) == "number" then table.insert(Errors, "The xp ammount of a book is INVALID!") end 391 | if not type(v.Category) == "string" then v.Category="" end 392 | if not type(v.Level) == "number" then table.insert(Errors, "The level of a book is INVALID!") end 393 | local ErrorCount = 0 394 | for k,v in pairs(Errors) do 395 | error(v) 396 | ErrorCount = ErrorCount + 1 397 | end 398 | 399 | 400 | 401 | if not(ErrorCount==0) then return false end 402 | 403 | local t = { 404 | ent = "vrondakis_book", 405 | model = v.Model, 406 | category = v.Category, 407 | price = v.Price, 408 | xp = v.XP, 409 | prestige = (v.Prestige or 0), 410 | book = true, 411 | level = v.Level, 412 | max = LevelSystemConfiguration.BookMax, 413 | cmd = "buyvrondakis"..v.Type.."book", 414 | allowed = v.Allowed, 415 | vrondakisName = v.Name, 416 | vrondakisType = v.Type, 417 | vrondakisColor = v.Color, 418 | vrondakisModel = v.Model, 419 | customCheck = (v.CustomCheck or function() return true end), 420 | CustomCheckFailMsg = v.CustomCheckFailMsg, 421 | } 422 | 423 | if(v.DParams) then 424 | for k,v in pairs(v.DParams) do 425 | t[k] = v 426 | end 427 | end 428 | 429 | DarkRP.createEntity(v.Name,t) 430 | 431 | end 432 | 433 | end) 434 | 435 | 436 | DarkRP.registerDarkRPVar("xp", net.WriteDouble, net.ReadDouble) 437 | DarkRP.registerDarkRPVar("level", net.WriteDouble, net.ReadDouble) 438 | DarkRP.registerDarkRPVar("prestige", net.WriteDouble, net.ReadDouble) 439 | -------------------------------------------------------------------------------- /lua/darkrp_modules/levels/sh_core.lua: -------------------------------------------------------------------------------- 1 | // Love Manolis Vrondakis. @vrondakis 2 | if SERVER then 3 | function checkLevel(ply,entity) 4 | if(entity.level) then 5 | if not((ply:getDarkRPVar("level") or 0) >= (entity.level)) then 6 | return false, DarkRP.getPhrase("lvl_buy_entity") 7 | end 8 | end 9 | end 10 | 11 | hook.Add("canBuyPistol", "manolis:MVLevels:PistolBuy", checkLevel) 12 | hook.Add("canBuyAmmo", "manolis:MVLevels:AmmoBuy", checkLevel) 13 | hook.Add("canBuyShipment", "manolis:MVLevels:ShipmentBuy", checkLevel) 14 | hook.Add("canBuyVehicle", "manolis:MVLevels:VehiclesBuy", checkLevel) 15 | hook.Add("canBuyCustomEntity", "manolis:MVLevels:CEntityBuy", checkLevel) 16 | 17 | hook.Add("playerCanChangeTeam", "manolis:MVLevels:playerTeamChange", function(ply, jobno) 18 | // This one requires a little extra work 19 | job = RPExtraTeams[jobno] 20 | if (job.level) then 21 | if not ((ply:getDarkRPVar("level") or 0) >= (job.level)) then 22 | return false, DarkRP.getPhrase("lvl_take_job") 23 | end 24 | end 25 | end) 26 | 27 | end 28 | 29 | if CLIENT then 30 | function LevelPrompts() 31 | timer.Simple(0.15,function() 32 | 33 | for k,v in pairs(DarkRPEntities) do 34 | v.label = v.name 35 | if v.level then 36 | v.label = (v.label .. " - Level "..v.level) 37 | end 38 | end 39 | 40 | for k,v in pairs(RPExtraTeams) do 41 | v.label = v.name 42 | if v.level then 43 | v.label = (v.label .. " - Level "..v.level) 44 | end 45 | end 46 | 47 | for k,v in pairs(CustomVehicles) do 48 | v.label = v.name 49 | if v.level then 50 | v.label = (v.label .. " - Level "..v.level) 51 | end 52 | end 53 | 54 | for k,v in pairs(CustomShipments) do 55 | v.label = v.name 56 | if v.level then 57 | v.label = (v.label .. " - Level "..v.level) 58 | end 59 | end 60 | 61 | for k,v in pairs(GAMEMODE.AmmoTypes) do 62 | v.label = v.name 63 | if v.level then 64 | v.label = (v.label .. " - Level "..v.level) 65 | end 66 | end 67 | end) 68 | 69 | end 70 | 71 | hook.Add( "InitPostEntity", "manolis:MVLevels:PostEntInit", function() 72 | LevelPrompts() 73 | end) 74 | 75 | hook.Add( "OnReloaded", "manolis:MVLevels:LuaReloadA", function() 76 | LevelPrompts() 77 | end) 78 | 79 | end 80 | 81 | 82 | if CLIENT then 83 | 84 | function ButtonColors() 85 | timer.Simple(0.1, function() 86 | 87 | if(LevelSystemConfiguration.GreenAllBars) then 88 | for k,v in pairs(DarkRPEntities) do 89 | if v.level then 90 | if not((LocalPlayer():getDarkRPVar("level") or 0) >= v.level) then 91 | v.buttonColor = Color(100,0,0) 92 | else 93 | v.buttonColor = Color(0,100,0) 94 | end 95 | else 96 | v.buttonColor = Color(0,100,0) 97 | end 98 | 99 | end 100 | end 101 | 102 | if(LevelSystemConfiguration.GreenJobBars) then 103 | for k,v in pairs(RPExtraTeams) do 104 | if v.level then 105 | if not((LocalPlayer():getDarkRPVar("level") or 0) >= v.level) then 106 | v.buttonColor = Color(100,0,0) 107 | else 108 | v.buttonColor = Color(0,100,0) 109 | end 110 | else 111 | v.buttonColor = Color(0,100,0) 112 | end 113 | 114 | end 115 | end 116 | 117 | if(LevelSystemConfiguration.GreenAllBars) then 118 | for k,v in pairs(CustomVehicles) do 119 | if v.level then 120 | if not((LocalPlayer():getDarkRPVar("level") or 0) >= v.level) then 121 | v.buttonColor = Color(100,0,0) 122 | else 123 | v.buttonColor = Color(0,100,0) 124 | end 125 | else 126 | v.buttonColor = Color(0,100,0) 127 | end 128 | end 129 | 130 | for k,v in pairs(CustomShipments) do 131 | if v.level then 132 | if not((LocalPlayer():getDarkRPVar("level") or 0) >= v.level) then 133 | v.buttonColor = Color(100,0,0) 134 | else 135 | v.buttonColor = Color(0,100,0) 136 | end 137 | else 138 | v.buttonColor = Color(0,100,0) 139 | end 140 | end 141 | 142 | for k,v in pairs(GAMEMODE.AmmoTypes) do 143 | if v.level then 144 | if not((LocalPlayer():getDarkRPVar("level") or 0) >= v.level) then 145 | v.buttonColor = Color(100,0,0) 146 | else 147 | v.buttonColor = Color(0,100,0) 148 | end 149 | else 150 | v.buttonColor = Color(0,100,0) 151 | end 152 | end 153 | end 154 | end) 155 | end 156 | hook.Add("F4MenuTabs", "manolis:MVLevels:FFourMenuTabs", ButtonColors) 157 | hook.Add("PlayerLevelChanged", "manolis:MVLevels:PlayerLevelChangedA", ButtonColors) 158 | 159 | end 160 | 161 | function PlayerInitialSpawn(ply) 162 | if SERVER then 163 | DarkRP.retrievePlayerLevelData(ply) 164 | end 165 | end 166 | 167 | hook.Add("PlayerInitialSpawn", "manolis:MVLevels:PlayerSpawnB", function(ply) timer.Simple( 1, function () PlayerInitialSpawn(ply) end) end) 168 | -------------------------------------------------------------------------------- /lua/darkrp_modules/levels/sv_addways.lua: -------------------------------------------------------------------------------- 1 | local function PlayerDeath(victim, weapon, killer) 2 | if (LevelSystemConfiguration.KillModule) then 3 | if (victim != killer) then -- Not a suicide 4 | if (killer:IsPlayer()) then 5 | local victime = victim:Nick() 6 | local money = DarkRP.formatMoney(LevelSystemConfiguration.TakeAwayMoneyAmount) 7 | local XP = killer:addXP( 10 * (victim:getDarkRPVar("level") or 1), true) 8 | 9 | if (LevelSystemConfiguration.Friendly) then 10 | if ((killer:getDarkRPVar("level") or 1) <= (victim:getDarkRPVar("level") or 1)) then 11 | killer:addMoney(LevelSystemConfiguration.TakeAwayMoneyAmount) 12 | DarkRP.notify(killer, 0,4, DarkRP.getPhrase("lvl_kill_notify", XP, money, victime)) 13 | if guthlogsystem then 14 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..killer.."* got &"..XP.."& XP and &"..money.."& for killing ?"..victime.."?" ) 15 | end 16 | 17 | if (victim:canAfford(LevelSystemConfiguration.TakeAwayMoneyAmount)) then 18 | victim:addMoney(-LevelSystemConfiguration.TakeAwayMoneyAmount) 19 | DarkRP.notify(victim, 0,4, DarkRP.getPhrase("lvl_death", money)) 20 | end 21 | else 22 | DarkRP.notify(killer,0,4, DarkRP.getPhrase("lvl_kill_notify2", XP, victime)) 23 | if guthlogsystem then 24 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..killer:Name().."* got &"..XP.."& XP for killing ?"..victime.."?" ) 25 | end 26 | end 27 | else 28 | killer:addMoney(LevelSystemConfiguration.TakeAwayMoneyAmount) 29 | DarkRP.notify(killer, 0,4, DarkRP.getPhrase("lvl_kill_notify3", victime)) 30 | if guthlogsystem then 31 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..killer:Name().."* got &0& XP ?"..victime.."? (Friendly mode no XP gain)") 32 | end 33 | end 34 | end 35 | end 36 | end 37 | end 38 | 39 | hook.Add( "PlayerDeath", "manolis:MVLevels:PlayerDeathBC", PlayerDeath ) 40 | 41 | 42 | local function NPCDeath(npc, killer,weapon) 43 | if (LevelSystemConfiguration.NPCXP) then 44 | if (npc != killer) then -- Not a suicide? Somehow. 45 | if (killer:IsPlayer()) then 46 | local XP = killer:addXP(npc:GetVar("GiveXP") or LevelSystemConfiguration.NPCXPAmount, true) 47 | if (XP) then 48 | DarkRP.notify(killer, 0,4, DarkRP.getPhrase("lvl_kill_npc", XP)) 49 | if guthlogsystem then 50 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..killer:Name().."* got &"..XP.."& XP for killing an NPC" ) 51 | end 52 | end 53 | end 54 | end 55 | end 56 | end 57 | 58 | hook.Add( "OnNPCKilled", "manolis:MVLevels:OnNPCKilledBC", NPCDeath ) 59 | 60 | 61 | if (LevelSystemConfiguration.BoughtXP) then 62 | local function BoughtXP(ply, ent, price) 63 | local XP = 0.1 * ent.price 64 | ply:addXP(XP, true) 65 | if guthlogsystem then 66 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..ply:Name().."* got &"..XP.."& XP for buying ?"..ent.name.."?" ) 67 | end 68 | end 69 | 70 | hook.Add("playerBoughtPistol", "manolis:MVLevels:PistolBought", BoughtXP) 71 | hook.Add("playerBoughtAmmo", "manolis:MVLevels:AmmoBought", BoughtXP) 72 | hook.Add("playerBoughtShipment", "manolis:MVLevels:ShipmentBought", BoughtXP) 73 | hook.Add("playerBoughtCustomEntity", "manolis:MVLevels:CEntityBought", BoughtXP) 74 | end 75 | 76 | 77 | local time = LevelSystemConfiguration.Timertime 78 | timer.Create( "PlayXP", time,0,function() 79 | if (LevelSystemConfiguration.TimerModule) then 80 | for k,v in pairs(player.GetAll()) do 81 | if IsValid(GetConVar("aafk_enabled")) and GetConVar("aafk_enabled"):GetBool() == true then 82 | if v:GetNWBool( "aafk_away" ) == false then 83 | if table.HasValue(LevelSystemConfiguration.TimerXPVipGroups, v:GetNWString("usergroup")) then 84 | local XP = v:addXP(LevelSystemConfiguration.TimerXPAmountVip, true) 85 | if (XP) then 86 | DarkRP.notify(v,0,4, DarkRP.getPhrase("lvl_play_on", XP)) 87 | end 88 | else 89 | local XP = v:addXP(LevelSystemConfiguration.TimerXPAmount, true) 90 | if (XP) then 91 | DarkRP.notify(v,0,4, DarkRP.getPhrase("lvl_play_on", XP)) 92 | end 93 | end 94 | end 95 | else 96 | if table.HasValue(LevelSystemConfiguration.TimerXPVipGroups, v:GetNWString("usergroup")) then 97 | local XP = v:addXP(LevelSystemConfiguration.TimerXPAmountVip, true) 98 | if (XP) then 99 | DarkRP.notify(v,0,4, DarkRP.getPhrase("lvl_play_on", XP)) 100 | end 101 | else 102 | local XP = v:addXP(LevelSystemConfiguration.TimerXPAmount, true) 103 | if (XP) then 104 | DarkRP.notify(v,0,4, DarkRP.getPhrase("lvl_play_on", XP)) 105 | end 106 | end 107 | end 108 | end 109 | if guthlogsystem then 110 | guthlogsystem.addLog( "DarkRP Leveling System", "*Everyone* got &"..LevelSystemConfiguration.TimerXPAmount.."& or !"..LevelSystemConfiguration.TimerXPAmountVip.."! XP depending of their rank" ) 111 | end 112 | end 113 | end) -------------------------------------------------------------------------------- /lua/darkrp_modules/levels/sv_data.lua: -------------------------------------------------------------------------------- 1 | // Love Manolis Vrondakis. @vrondakis 2 | 3 | if (guthlogsystem) then 4 | guthlogsystem.addCategory( "DarkRP Leveling System", Color(255, 0, 255) ) 5 | end 6 | 7 | function DarkRPInit() 8 | MySQLite.query([[CREATE TABLE IF NOT EXISTS darkrp_levels( 9 | uid VARCHAR(32) NOT NULL, 10 | level int NOT NULL, 11 | xp int NOT NULL, 12 | UNIQUE(uid) 13 | ); 14 | ]]) 15 | end 16 | hook.Add("DarkRPDBInitialized", "manolis:MVLevels:DarkRPDBInitializedBB", DarkRPInit) 17 | 18 | function DarkRP.retrievePlayerLevelXP(ply, callback) 19 | MySQLite.query("SELECT level,xp FROM darkrp_levels WHERE uid = ".. MySQLite.SQLStr(ply:UniqueID())..";", function(r)callback(r)end) 20 | end 21 | 22 | function DarkRP.createPlayerLevelData(ply) 23 | MySQLite.query([[REPLACE INTO darkrp_levels VALUES(]]..MySQLite.SQLStr(ply:UniqueID()) .. [[,"1","0")]]) 24 | end 25 | 26 | 27 | function DarkRP.retrievePlayerLevelData(ply) 28 | DarkRP.retrievePlayerLevelXP(ply,function(data) 29 | if not IsValid(ply) then return end 30 | local info = data and data[1] or {} 31 | info.xp = (info.xp or 0) 32 | info.level = (info.level or 1) 33 | ply:setDarkRPVar("xp", tonumber(info.xp)) 34 | ply:setDarkRPVar("level", tonumber(info.level)) 35 | if not data then DarkRP.createPlayerLevelData(ply) end 36 | end) 37 | end 38 | 39 | 40 | 41 | function DarkRP.storeXPData(ply, level, xp) 42 | xp = math.max(xp,0) 43 | MySQLite.query("UPDATE darkrp_levels SET level = " ..MySQLite.SQLStr(level) ..", xp = "..MySQLite.SQLStr(xp).." WHERE uid = "..MySQLite.SQLStr(ply:UniqueID())) 44 | end 45 | 46 | local function resetAllXP(ply, cmd, args) 47 | if ply:EntIndex() ~= 0 and not ply:IsSuperAdmin() then return end 48 | MySQLite.query("UPDATE darkrp_levels SET level = 1 ;") 49 | MySQLite.query("UPDATE darkrp_levels SET xp = 0 ;") 50 | for _, v in ipairs(player.GetAll()) do 51 | v:setDarkRPVar("level", 1) 52 | v:setDarkRPVar("xp", 0) 53 | end 54 | if ply:IsPlayer() then 55 | DarkRP.notifyAll(0, 4, "Levels have been reseted by an administrator") 56 | else 57 | DarkRP.notifyAll(0, 4, "Levels have been reseted by the console") 58 | end 59 | end 60 | concommand.Add("rp_resetallxp", resetAllXP) 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /lua/darkrp_modules/levels/sv_levels.lua: -------------------------------------------------------------------------------- 1 | resource.AddSingleFile("materials/vrondakis/xp_bar.png") 2 | resource.AddSingleFile("resource/fonts/francoisone.ttf") 3 | local meta = FindMetaTable("Player") 4 | 5 | function meta:setLevel(level) 6 | if not (level or self:IsPlayer()) then return end 7 | return self:setDarkRPVar("level", level) 8 | end 9 | 10 | function meta:setXP(xp) 11 | if not (xp or self:IsPlayer()) then return end 12 | return self:setDarkRPVar("xp", xp) 13 | end 14 | 15 | function meta:addXP(amount, notify, carryOver) 16 | local PlayerLevel = (self:getDarkRPVar("level")) 17 | local PlayerXP = (self:getDarkRPVar("xp")) 18 | amount = tonumber(amount) 19 | 20 | if((not amount) or (not IsValid(self)) or (not PlayerLevel) or (not PlayerXP) or (PlayerLevel>=LevelSystemConfiguration.MaxLevel)) then return 0 end 21 | if(not carryOver) then 22 | if(self.VXScaleXP) then 23 | amount=(amount*tonumber(self.VXScaleXP)) 24 | end 25 | end 26 | 27 | if not(notify) then 28 | DarkRP.notify(self,0,4, DarkRP.getPhrase("lvl_recieve_xp", amount)) 29 | end 30 | 31 | local TotalXP = PlayerXP + amount 32 | 33 | if(TotalXP>=self:getMaxXP()) then // Level up! 34 | PlayerLevel = PlayerLevel + 1 35 | local name = self:Name() 36 | DarkRP.notifyAll(0,3, DarkRP.getPhrase("lvl_reach_level", name, PlayerLevel)) 37 | if guthlogsystem then 38 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..name.."* reached level &"..PlayerLevel.."&" ) 39 | end 40 | hook.Call( "PlayerLevelChanged", nil, self, PlayerLevel-1, PlayerLevel ) // call the PlayerLevelChanged hook and pass player, old level and new level. 41 | 42 | local RemainingXP = (TotalXP-self:getMaxXP()) 43 | if(LevelSystemConfiguration.ContinueXP) then 44 | if(RemainingXP>0) then 45 | self:setXP(0) 46 | self:setLevel(PlayerLevel) 47 | return self:addXP(RemainingXP,true,true) 48 | end 49 | end 50 | 51 | self:setLevel(PlayerLevel) 52 | self:setXP(0) 53 | 54 | DarkRP.storeXPData(self,PlayerLevel,0) 55 | else 56 | DarkRP.storeXPData(self,PlayerLevel,(TotalXP or 0)) 57 | self:setXP(math.max(0,TotalXP)) 58 | 59 | end 60 | 61 | if not carryOver then 62 | hook.Run( "VrondakisLeveling.XPAdded", self, amount ) 63 | end 64 | 65 | return (amount or 0) 66 | 67 | end 68 | 69 | meta.AddXP = meta.addXP 70 | 71 | function meta:getLevel() 72 | return self:getDarkRPVar("level") 73 | end 74 | 75 | function meta:getXP() 76 | return self:getDarkRPVar("xp") 77 | end 78 | 79 | function meta:getMaxXP() 80 | return (((10+(((self:getDarkRPVar("level") or 1)*((self:getDarkRPVar("level") or 1)+1)*90))))*LevelSystemConfiguration.XPMult) 81 | end 82 | 83 | function meta:addLevels(levels) 84 | if(self:getDarkRPVar("level") == LevelSystemConfiguration.MaxLevel) then 85 | return false 86 | end 87 | if((self:getDarkRPVar("level") +levels)>LevelSystemConfiguration.MaxLevel) then 88 | // Determine how many levels we can add. 89 | local LevelsCan = (((self:getDarkRPVar("level")+levels))-LevelSystemConfiguration.MaxLevel) 90 | if(LevelsCan==0) then 91 | return 0 92 | else 93 | DarkRP.storeXPData(self, LevelSystemConfiguration.MaxLevel,0) 94 | self:setDarkRPVar("xp",0) 95 | self:setDarkRPVar("level", LevelSystemConfiguration.MaxLevel) 96 | return LevelsCan 97 | end 98 | 99 | else 100 | DarkRP.storeXPData(self,(self:getDarkRPVar("level") +levels),0) 101 | self:setDarkRPVar("xp",0) 102 | self:setDarkRPVar("level",(self:getDarkRPVar("level") +levels)) 103 | return levels 104 | end 105 | 106 | 107 | end 108 | 109 | function meta:hasLevel(level) 110 | return ((self:getDarkRPVar("level")) >= level) 111 | end 112 | 113 | concommand.Add("level", function(ply) 114 | DarkRP.notify(ply,0,10,"Leveling System by @vrondakis for Darkrp 2.7") 115 | end) 116 | -------------------------------------------------------------------------------- /lua/entities/vrondakis_book/cl_init.lua: -------------------------------------------------------------------------------- 1 | include("shared.lua") 2 | 3 | 4 | function ENT:Draw() 5 | self:DrawModel() 6 | 7 | end -------------------------------------------------------------------------------- /lua/entities/vrondakis_book/init.lua: -------------------------------------------------------------------------------- 1 | AddCSLuaFile( "cl_init.lua" ) 2 | AddCSLuaFile( "shared.lua" ) 3 | include("shared.lua") 4 | 5 | function ENT:Initialize() 6 | self:SetModel(self.DarkRPItem.model) 7 | self:SetColor(self.DarkRPItem.vrondakisColor) 8 | 9 | self:PhysicsInit( SOLID_VPHYSICS ) 10 | self:SetMoveType( MOVETYPE_VPHYSICS ) 11 | self:SetSolid( SOLID_VPHYSICS ) 12 | local phys = self:GetPhysicsObject() 13 | if (phys:IsValid()) then 14 | phys:Wake() 15 | end 16 | end 17 | 18 | function ENT:Use( activator, caller ) 19 | local XP = self.DarkRPItem.xp 20 | local bookname = self.DarkRPItem.vrondakisName 21 | activator:addXP( XP, true) 22 | DarkRP.notify(activator, 0,4, DarkRP.getPhrase("lvl_book_notify", XP, bookname)) 23 | if guthlogsystem then 24 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..activator:Name().."* got &"..XP.."& XP for using ?"..bookname.."?" ) 25 | end 26 | self:Remove() 27 | end 28 | 29 | function ENT:Touch(entity) 30 | if LevelSystemConfiguration.BookOnTouch then 31 | if (!entity:IsPlayer()) then return end 32 | local XP = self.DarkRPItem.xp 33 | local bookname = self.DarkRPItem.vrondakisName 34 | entity:addXP( XP, true) 35 | DarkRP.notify(entity, 0,4, DarkRP.getPhrase("lvl_book_notify", XP, bookname)) 36 | if guthlogsystem then 37 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..entity:Name().."* got &"..XP.."& XP for using ?"..bookname.."?" ) 38 | end 39 | self:Remove() 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lua/entities/vrondakis_book/shared.lua: -------------------------------------------------------------------------------- 1 | ENT.Type = "anim" 2 | ENT.Base = "base_gmodentity" 3 | ENT.PrintName = "XP Book" 4 | ENT.Author = "vrondakis & chesiren" 5 | ENT.Spawnable = false 6 | ENT.AdminSpawnable = false -------------------------------------------------------------------------------- /lua/entities/vrondakis_printer/cl_init.lua: -------------------------------------------------------------------------------- 1 | include("shared.lua") 2 | 3 | 4 | surface.CreateFont("TargetID", { 5 | font = "Trebuchet MS", 6 | size = 22, 7 | weight = 900, 8 | antialias = true, 9 | }) 10 | function ENT:Initialize() 11 | self.PrinterName = self:GetNWString("PrinterName") // Why is self.DarkRPItem not clientside? 12 | self.PrinterType = self:GetNWString("PrinterType") 13 | end 14 | 15 | 16 | function ENT:Draw() 17 | self:DrawModel() 18 | 19 | local Pos = self:GetPos() 20 | local Ang = self:GetAngles() 21 | 22 | local owner = self:Getowning_ent() 23 | owner = (IsValid(owner) and owner:Nick()) or DarkRP.getPhrase("unknown") 24 | local amount = "Unknown" 25 | if(self:GetNWInt("MaxConfig") == 0) then 26 | amount = DarkRP.formatMoney(self:GetNWInt("MoneyAmount")) 27 | else 28 | amount = (DarkRP.formatMoney(self:GetNWInt("MoneyAmount")).." / "..DarkRP.formatMoney(self:GetNWInt("MaxConfig")*self:GetNWInt("MoneyPerPrint"))) 29 | end 30 | 31 | surface.SetFont("HUDNumber5") 32 | local text = self:GetNWString("PrinterName", "Unknown") 33 | local TextWidth = surface.GetTextSize(text) 34 | local TextWidth2 = surface.GetTextSize(owner) 35 | local TextWidth3 = surface.GetTextSize(amount) 36 | 37 | Ang:RotateAroundAxis(Ang:Up(), 90) 38 | 39 | cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11) 40 | draw.WordBox(2, -TextWidth*0.5, -30, text, "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255)) 41 | draw.WordBox(2, -TextWidth2*0.5, 18, owner, "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255)) 42 | draw.WordBox(2, -TextWidth3*0.5, 60, amount, "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255)) 43 | 44 | 45 | cam.End3D2D() 46 | end 47 | 48 | 49 | function ENT:Think() 50 | end 51 | -------------------------------------------------------------------------------- /lua/entities/vrondakis_printer/init.lua: -------------------------------------------------------------------------------- 1 | // Modified from core DarkRP. 2 | AddCSLuaFile("cl_init.lua") 3 | AddCSLuaFile("shared.lua") 4 | include("shared.lua") 5 | 6 | ENT.SeizeReward = 950 7 | ENT.StoredMoney = 0 8 | ENT.StoredXP = 0 9 | 10 | local PrintMore 11 | function ENT:Initialize() 12 | self:SetModel(self.DarkRPItem.model) 13 | self:SetColor(self.DarkRPItem.vrondakisColor) 14 | 15 | 16 | self:PhysicsInit(SOLID_VPHYSICS) 17 | self:SetMoveType(MOVETYPE_VPHYSICS) 18 | self:SetSolid(SOLID_VPHYSICS) 19 | local phys = self:GetPhysicsObject() 20 | phys:Wake() 21 | 22 | self.sparking = false 23 | self.damage = 100 24 | self.IsMoneyPrinter = true 25 | timer.Simple(self.DarkRPItem.vrondakisPrinterTime,function() PrintMore(self) end) 26 | 27 | if(LevelSystemConfiguration.PrinterSound) then 28 | self.sound = CreateSound(self, Sound("ambient/levels/labs/equipment_printer_loop1.wav")) 29 | self.sound:SetSoundLevel(52) 30 | self.sound:PlayEx(1, 100) 31 | end 32 | 33 | self:SetNWString("PrinterName", (self.DarkRPItem.name or "Unknown")) 34 | self:SetNWInt("MoneyPerPrint", self.DarkRPItem.vrondakisMoneyPerPrint or 0) 35 | self:SetNWInt("MoneyAmount", 0) 36 | self:SetNWInt("MaxConfig",self.DarkRPItem.vrondakisPrinterMaxP or 1) 37 | 38 | self:SetUseType(SIMPLE_USE) 39 | 40 | 41 | 42 | end 43 | 44 | function ENT:OnTakeDamage(dmg) 45 | if self.burningup then return end 46 | 47 | self.damage = (self.damage or 100) - dmg:GetDamage() 48 | if self.damage <= 0 then 49 | local rnd = math.random(1, 10) 50 | if rnd < 3 then 51 | self:BurstIntoFlames() 52 | else 53 | self:Destruct() 54 | self:Remove() 55 | end 56 | end 57 | end 58 | 59 | function ENT:Destruct() 60 | local vPoint = self:GetPos() 61 | local effectdata = EffectData() 62 | effectdata:SetStart(vPoint) 63 | effectdata:SetOrigin(vPoint) 64 | effectdata:SetScale(1) 65 | util.Effect("Explosion", effectdata) 66 | if(IsValid(self:Getowning_ent())) then 67 | DarkRP.notify(self:Getowning_ent(), 1, 4, DarkRP.getPhrase("money_printer_exploded")) 68 | end 69 | end 70 | 71 | function ENT:BurstIntoFlames() 72 | DarkRP.notify(self:Getowning_ent(), 0, 4, DarkRP.getPhrase("money_printer_overheating")) 73 | self.burningup = true 74 | local burntime = math.random(8, 18) 75 | self:Ignite(burntime, 0) 76 | timer.Simple(burntime, function() self:Fireball() end) 77 | end 78 | 79 | function ENT:Fireball() 80 | if not self:IsOnFire() then self.burningup = false return end 81 | local dist = math.random(20, 280) -- Explosion radius 82 | self:Destruct() 83 | for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do 84 | if not v:IsPlayer() and not v:IsWeapon() and v:GetClass() ~= "predicted_viewmodel" and not v.IsMoneyPrinter then 85 | v:Ignite(math.random(5, 22), 0) 86 | elseif v:IsPlayer() then 87 | local distance = v:GetPos():Distance(self:GetPos()) 88 | v:TakeDamage(distance / dist * 100, self, self) 89 | end 90 | end 91 | self:Remove() 92 | end 93 | 94 | PrintMore = function(ent) 95 | if not IsValid(ent) then return end 96 | 97 | ent.sparking = true 98 | timer.Simple(1, function() 99 | if not IsValid(ent) then return end 100 | ent:CreateMoneybag() 101 | end) 102 | end 103 | 104 | function ENT:CreateMoneybag() 105 | if not IsValid(self) or self:IsOnFire() then return end 106 | 107 | local MoneyPos = self:GetPos() 108 | if(self.DarkRPItem.vrondakisPrinterOverheat) then 109 | local overheatchance 110 | if GAMEMODE.Config.printeroverheatchance <= 3 then 111 | overheatchance = 22 112 | else 113 | overheatchance = GAMEMODE.Config.printeroverheatchance or 22 114 | end 115 | if math.random(1, overheatchance) == 3 then self:BurstIntoFlames() end 116 | end 117 | if(self.DarkRPItem.vrondakisPrinterMaxP == 0) or ((self.StoredMoney+self.DarkRPItem.vrondakisMoneyPerPrint) <= (self.DarkRPItem.vrondakisMoneyPerPrint*self.DarkRPItem.vrondakisPrinterMaxP)) then 118 | 119 | local amount = self.DarkRPItem.vrondakisMoneyPerPrint 120 | local xpamount = self.DarkRPItem.vrondakisXPPerPrint 121 | 122 | self.StoredMoney = self.StoredMoney + amount 123 | self.StoredXP = self.StoredXP + xpamount 124 | self:SetNWInt("MoneyAmount", self.StoredMoney) 125 | end 126 | 127 | self.sparking = false 128 | timer.Simple(self.DarkRPItem.vrondakisPrinterTime,function() PrintMore(self) end) 129 | end 130 | 131 | function ENT:Use(activator,caller) 132 | local xpAdded = 0 133 | if(IsValid(activator)) then 134 | if(activator:IsPlayer()) then 135 | if(self.StoredMoney>0) then 136 | if (not(self.DarkRPItem.vrondakisPrinterCanCollect)) then 137 | if not(self.StoredMoney==0) then 138 | activator:addMoney(self.StoredMoney) 139 | end 140 | 141 | if not (self.StoredXP==0) then 142 | activator:addXP(self.StoredXP,true) 143 | end 144 | self:SetNWInt("MoneyAmount", 0) 145 | DarkRP.notify(activator,0,4, DarkRP.getPhrase("lvl_printer_use", self.StoredXP, DarkRP.formatMoney(self.StoredMoney))) 146 | if guthlogsystem then 147 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..activator:Name().."* got &"..self.StoredXP.."& XP and !"..DarkRP.formatMoney(self.StoredMoney).."! for using ?"..self:Getowning_ent():Name().."? printer" ) 148 | end 149 | self.StoredMoney = 0 150 | self.StoredXP = 0 151 | 152 | else 153 | if(activator:getDarkRPVar("level")<(self.DarkRPItem.level-5)) then return DarkRP.notify(activator,0,4, DarkRP.getPhrase("lvl_printer_level")) end 154 | 155 | if not(self.StoredMoney==0) then 156 | activator:addMoney(self.StoredMoney) 157 | end 158 | 159 | if not (self.StoredXP==0) then 160 | activator:addXP(self.StoredXP,true) 161 | end 162 | self:SetNWInt("MoneyAmount", 0) 163 | DarkRP.notify(activator,0,4, DarkRP.getPhrase("lvl_printer_use", self.StoredXP, DarkRP.formatMoney(self.StoredMoney))) 164 | if guthlogsystem then 165 | guthlogsystem.addLog( "DarkRP Leveling System", "*"..activator:Name().."* got &"..self.StoredXP.."& XP and !"..DarkRP.formatMoney(self.StoredMoney).."! for using ?"..self:Getowning_ent():Name().."? printer" ) 166 | end 167 | self.StoredMoney = 0 168 | self.StoredXP = 0 169 | end 170 | end 171 | 172 | end 173 | end 174 | end 175 | function ENT:Think() 176 | 177 | if self:WaterLevel() > 0 then 178 | self:Destruct() 179 | self:Remove() 180 | return 181 | end 182 | if(self.DarkRPItem.vrondakisPrinterEpilepsy) then 183 | if(self.StoredMoney>0) then 184 | //Pick a random color, go to it, then change the color 185 | local Rr = math.random(0,255) 186 | local Rb = math.random(0,255) 187 | local Rc = math.random(0,255) 188 | 189 | self:SetColor(Color(Rr,Rb,Rc)) 190 | end 191 | end 192 | 193 | if not self.sparking then return end 194 | 195 | local effectdata = EffectData() 196 | effectdata:SetOrigin(self:GetPos()) 197 | effectdata:SetMagnitude(1) 198 | effectdata:SetScale(1) 199 | effectdata:SetRadius(2) 200 | util.Effect("Sparks", effectdata) 201 | 202 | 203 | 204 | end 205 | 206 | function ENT:OnRemove() 207 | if self.sound then 208 | self.sound:Stop() 209 | end 210 | end 211 | -------------------------------------------------------------------------------- /lua/entities/vrondakis_printer/shared.lua: -------------------------------------------------------------------------------- 1 | ENT.Type = "anim" 2 | ENT.Base = "base_gmodentity" 3 | ENT.PrintName = "Money Printer" 4 | ENT.Author = "vrondakis" 5 | ENT.Spawnable = false 6 | ENT.AdminSpawnable = false 7 | 8 | function ENT:SetupDataTables() 9 | self:NetworkVar("Int", 0, "price") 10 | self:NetworkVar("Entity", 0, "owning_ent") 11 | end -------------------------------------------------------------------------------- /lua/plugins/levels/cl_init.lua: -------------------------------------------------------------------------------- 1 | local plugin = plugin 2 | 3 | plugin:IncludeFile("shared.lua", SERVERGUARD.STATE.CLIENT) 4 | plugin:IncludeFile("sh_commands.lua", SERVERGUARD.STATE.CLIENT) -------------------------------------------------------------------------------- /lua/plugins/levels/init.lua: -------------------------------------------------------------------------------- 1 | local plugin = plugin 2 | 3 | plugin:IncludeFile("shared.lua", SERVERGUARD.STATE.SHARED) 4 | plugin:IncludeFile("sh_commands.lua", SERVERGUARD.STATE.SHARED) -------------------------------------------------------------------------------- /lua/plugins/levels/sh_commands.lua: -------------------------------------------------------------------------------- 1 | local plugin = plugin 2 | 3 | local command = {} 4 | command.help = "Give XP to a player." 5 | command.command = "addxp" 6 | command.arguments = {"player", "amount"} 7 | command.bDisallowConsole = false 8 | command.bSingleTarget = true 9 | command.immunity = SERVERGUARD.IMMUNITY.LESSEQUAL 10 | command.aliases = {"xp"} 11 | command.permissions = {"Set XP"} 12 | function command:Execute(player, silent, arguments) 13 | local target = util.FindPlayer(arguments[1], player) 14 | local amount = tonumber(arguments[2]) or -1 15 | 16 | if amount == -1 then return end 17 | 18 | if (IsValid(target)) then 19 | if target.DarkRPUnInitialized then 20 | serverguard.Notify(player, SERVERGUARD.NOTIFY.RED, "Player is not yet initialized.") 21 | return 22 | end 23 | 24 | target:addXP(amount) 25 | 26 | if not silent then 27 | serverguard.Notify(nil, SERVERGUARD.NOTIFY.GREEN, serverguard.player:GetName(player), SERVERGUARD.NOTIFY.WHITE, " has given ", SERVERGUARD.NOTIFY.RED, target:Name(), SERVERGUARD.NOTIFY.WHITE, " " .. tostring(amount) .. " XP.") 28 | end 29 | end 30 | end 31 | plugin:AddCommand(command) 32 | 33 | command = {} 34 | command.help = "Set a player's current level." 35 | command.command = "setlevel" 36 | command.arguments = {"player", "amount"} 37 | command.bDisallowConsole = false 38 | command.bSingleTarget = true 39 | command.immunity = SERVERGUARD.IMMUNITY.LESSEQUAL 40 | command.aliases = {"level"} 41 | command.permissions = {"Set XP"} 42 | function command:Execute(player, silent, arguments) 43 | local target = util.FindPlayer(arguments[1], player) 44 | local amount = tonumber(arguments[2]) or -1 45 | 46 | if amount == -1 then return end 47 | 48 | if (IsValid(target)) then 49 | if target.DarkRPUnInitialized then 50 | serverguard.Notify(player, SERVERGUARD.NOTIFY.RED, "Player is not yet initialized.") 51 | return 52 | end 53 | 54 | DarkRP.storeXPData(target, amount, 0) 55 | target:setDarkRPVar("level", amount) 56 | target:setDarkRPVar("xp", 0) 57 | 58 | if not silent then 59 | serverguard.Notify(nil, SERVERGUARD.NOTIFY.GREEN, serverguard.player:GetName(player), SERVERGUARD.NOTIFY.WHITE, " set ", SERVERGUARD.NOTIFY.RED, target:Name(), SERVERGUARD.NOTIFY.WHITE, " level to " .. tostring(amount)) 60 | end 61 | end 62 | end 63 | plugin:AddCommand(command) 64 | 65 | command = {} 66 | command.help = "Give player a number of levels." 67 | command.command = "addlevels" 68 | command.arguments = {"player", "amount"} 69 | command.bDisallowConsole = false 70 | command.bSingleTarget = true 71 | command.immunity = SERVERGUARD.IMMUNITY.LESSEQUAL 72 | command.aliases = {"levels", "givelevels"} 73 | command.permissions = {"Set XP"} 74 | function command:Execute(player, silent, arguments) 75 | local target = util.FindPlayer(arguments[1], player) 76 | local amount = tonumber(arguments[2]) or -1 77 | 78 | if amount == -1 then return end 79 | 80 | if (IsValid(target)) then 81 | if target.DarkRPUnInitialized then 82 | serverguard.Notify(player, SERVERGUARD.NOTIFY.RED, "Player is not yet initialized.") 83 | return 84 | end 85 | 86 | local level = target:getDarkRPVar("level") or 0 87 | DarkRP.storeXPData(target, level + amount, 0) 88 | target:setDarkRPVar("level", level + amount) 89 | target:setDarkRPVar("xp", 0) 90 | 91 | if not silent then 92 | serverguard.Notify(nil, SERVERGUARD.NOTIFY.GREEN, serverguard.player:GetName(player), SERVERGUARD.NOTIFY.WHITE, " gave ", SERVERGUARD.NOTIFY.RED, target:Name(), SERVERGUARD.NOTIFY.WHITE, tostring(amount) .. " levels.") 93 | end 94 | end 95 | end 96 | plugin:AddCommand(command) -------------------------------------------------------------------------------- /lua/plugins/levels/shared.lua: -------------------------------------------------------------------------------- 1 | local plugin = plugin 2 | 3 | plugin.name = "Level Control" 4 | plugin.author = "Dr. Internet | HenkSpenk" 5 | plugin.version = "1.0" 6 | plugin.description = "Allows administrators to control DarkRP Levels from ServerGuard." 7 | plugin.permissions = {"Set XP"} 8 | plugin.messages = {} -------------------------------------------------------------------------------- /lua/plugins/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | setlevel {playername} - Set a player's current level 3 | addlevels {playername} - Give player a number of levels 4 | addxp {playername} - Give XP to a player. 5 | 6 | source : https://forums.gmodserverguard.com/threads/set-level-plugin-for-darkrp.617/ -------------------------------------------------------------------------------- /lua/ulx/modules/sh/levels.lua: -------------------------------------------------------------------------------- 1 | function ulx.addXP(calling_ply, target_ply, amount) 2 | if not amount then ULib.tsayError("Amount not specified!") return end 3 | if target_ply.DarkRPUnInitialized then return end 4 | target_ply:addXP(amount, true) 5 | DarkRP.notify(target_ply, 0,4,calling_ply:Nick() .. " gave you "..amount.."XP") 6 | ulx.fancyLogAdmin(calling_ply, "#A has gave #T an xp amount of #s", target_ply, amount) 7 | end 8 | local addXPx = ulx.command("Levels", "ulx addxp", ulx.addXP, "!addxp") 9 | addXPx:addParam{type=ULib.cmds.PlayerArg} 10 | addXPx:addParam{type=ULib.cmds.NumArg, hint="xp"} 11 | addXPx:defaultAccess(ULib.ACCESS_ADMIN) 12 | addXPx:help("Add XP to a player.") 13 | 14 | function ulx.setLevel(calling_ply, target_ply, level) 15 | if not level then ULib.tsayError("Level not specified!") return end 16 | if target_ply.DarkRPUnInitialized then return end 17 | DarkRP.storeXPData(target_ply,level,0) 18 | target_ply:setDarkRPVar("level",level) 19 | target_ply:setDarkRPVar("xp",0) 20 | DarkRP.notify(target_ply, 0,4,calling_ply:Nick() .. " set your level to "..level) 21 | ulx.fancyLogAdmin(calling_ply, "#A has set #T level to #s", target_ply, level) 22 | end 23 | local setLevelx = ulx.command("Levels", "ulx setlevel", ulx.setLevel, "!setlevel") 24 | setLevelx:addParam{type=ULib.cmds.PlayerArg} 25 | setLevelx:addParam{type=ULib.cmds.NumArg, hint="level"} 26 | setLevelx:defaultAccess(ULib.ACCESS_ADMIN) 27 | setLevelx:help("Set a players level.") -------------------------------------------------------------------------------- /lua/weapons/pocket/cl_menu.lua: -------------------------------------------------------------------------------- 1 | local meta = FindMetaTable("Player") 2 | local pocket = {} 3 | local frame 4 | local reload 5 | 6 | /*--------------------------------------------------------------------------- 7 | Stubs 8 | ---------------------------------------------------------------------------*/ 9 | DarkRP.stub{ 10 | name = "openPocketMenu", 11 | description = "Open the DarkRP pocket menu.", 12 | parameters = { 13 | }, 14 | returns = { 15 | }, 16 | metatable = DarkRP 17 | } 18 | 19 | /*--------------------------------------------------------------------------- 20 | Interface functions 21 | ---------------------------------------------------------------------------*/ 22 | function meta:getPocketItems() 23 | if self ~= LocalPlayer() then return nil end 24 | 25 | return pocket 26 | end 27 | 28 | function DarkRP.openPocketMenu() 29 | if frame and frame:IsValid() and frame:IsVisible() then return end 30 | if LocalPlayer():GetActiveWeapon():GetClass() ~= "pocket" then return end 31 | if not pocket then pocket = {} return end 32 | if #pocket <= 0 then return end 33 | frame = vgui.Create("DFrame") 34 | 35 | frame:SetTitle(DarkRP.getPhrase("drop_item")) 36 | frame:SetVisible(true) 37 | frame:MakePopup() 38 | 39 | reload() 40 | frame:SetSkin(GAMEMODE.Config.DarkRPSkin) 41 | end 42 | 43 | 44 | /*--------------------------------------------------------------------------- 45 | UI 46 | ---------------------------------------------------------------------------*/ 47 | function reload() 48 | if not ValidPanel(frame) or not frame:IsVisible() then return end 49 | if not pocket or next(pocket) == nil then frame:Close() return end 50 | 51 | local itemCount = table.Count(pocket) 52 | 53 | frame:SetSize(itemCount * 64, 90) 54 | frame:Center() 55 | 56 | local i = 0 57 | 58 | local items = {} 59 | for k,v in pairs(pocket) do 60 | 61 | local icon = vgui.Create("SpawnIcon", frame) 62 | icon:SetPos(i * 64, 25) 63 | icon:SetModel(v.model) 64 | icon:SetSize(64, 64) 65 | icon:SetToolTip() 66 | icon.DoClick = function(self) 67 | icon:SetToolTip() 68 | 69 | net.Start("DarkRP_spawnPocket") 70 | net.WriteFloat(k) 71 | net.SendToServer() 72 | pocket[k] = nil 73 | 74 | itemCount = itemCount - 1 75 | 76 | if itemCount == 0 then 77 | frame:Close() 78 | return 79 | end 80 | 81 | fn.Map(self.Remove, items) 82 | items = {} 83 | 84 | LocalPlayer():GetActiveWeapon():SetWeaponHoldType("pistol") 85 | timer.Simple(0.2, function() if LocalPlayer():GetActiveWeapon():IsValid() then LocalPlayer():GetActiveWeapon():SetWeaponHoldType("normal") end end) 86 | end 87 | 88 | table.insert(items, icon) 89 | i = i + 1 90 | end 91 | end 92 | 93 | local function retrievePocket() 94 | pocket = net.ReadTable() 95 | reload() 96 | end 97 | net.Receive("DarkRP_Pocket", retrievePocket) 98 | -------------------------------------------------------------------------------- /lua/weapons/pocket/shared.lua: -------------------------------------------------------------------------------- 1 | if SERVER then 2 | AddCSLuaFile("shared.lua") 3 | AddCSLuaFile("cl_menu.lua") 4 | include("sv_init.lua") 5 | end 6 | 7 | if CLIENT then 8 | include("cl_menu.lua") 9 | end 10 | 11 | SWEP.PrintName = "Pocket" 12 | SWEP.Slot = 1 13 | SWEP.SlotPos = 1 14 | SWEP.DrawAmmo = false 15 | SWEP.DrawCrosshair = true 16 | 17 | SWEP.Base = "weapon_cs_base2" 18 | 19 | SWEP.Author = "DarkRP Developers + vrondakis" 20 | SWEP.Instructions = "Left click to pick up, right click to drop, reload for menu" 21 | SWEP.Contact = "" 22 | SWEP.Purpose = "" 23 | SWEP.IconLetter = "" 24 | 25 | SWEP.ViewModelFOV = 62 26 | SWEP.ViewModelFlip = false 27 | SWEP.AnimPrefix = "rpg" 28 | SWEP.WorldModel = "" 29 | 30 | SWEP.Spawnable = true 31 | SWEP.AdminOnly = true 32 | SWEP.Category = "DarkRP (Utility)" 33 | SWEP.Primary.ClipSize = -1 34 | SWEP.Primary.DefaultClip = 0 35 | SWEP.Primary.Automatic = false 36 | SWEP.Primary.Ammo = "" 37 | 38 | SWEP.Secondary.ClipSize = -1 39 | SWEP.Secondary.DefaultClip = 0 40 | SWEP.Secondary.Automatic = false 41 | SWEP.Secondary.Ammo = "" 42 | 43 | function SWEP:Initialize() 44 | self:SetWeaponHoldType("normal") 45 | end 46 | 47 | function SWEP:Deploy() 48 | return true 49 | end 50 | 51 | function SWEP:DrawWorldModel() end 52 | 53 | function SWEP:PreDrawViewModel(vm) 54 | return true 55 | end 56 | 57 | function SWEP:Holster() 58 | if not SERVER then return true end 59 | 60 | self.Owner:DrawViewModel(true) 61 | self.Owner:DrawWorldModel(true) 62 | 63 | return true 64 | end 65 | 66 | function SWEP:PrimaryAttack() 67 | self.Weapon:SetNextPrimaryFire(CurTime() + 0.2) 68 | 69 | if not SERVER then return end 70 | 71 | local ent = self.Owner:GetEyeTrace().Entity 72 | local canPickup, message = hook.Call("canPocket", nil, self.Owner, ent) 73 | 74 | if not canPickup then 75 | if message then DarkRP.notify(self.Owner, 1, 4, message) end 76 | return 77 | end 78 | 79 | self.Owner:addPocketItem(ent) 80 | end 81 | 82 | function SWEP:SecondaryAttack() 83 | if not SERVER then return end 84 | 85 | local item = #self.Owner:getPocketItems() 86 | if item <= 0 then 87 | DarkRP.notify(self.Owner, 1, 4, DarkRP.getPhrase("pocket_no_items")) 88 | return 89 | end 90 | 91 | self.Owner:dropPocketItem(item) 92 | end 93 | 94 | function SWEP:Reload() 95 | if not CLIENT then return end 96 | 97 | DarkRP.openPocketMenu() 98 | end 99 | 100 | local meta = FindMetaTable("Player") 101 | DarkRP.stub{ 102 | name = "getPocketItems", 103 | description = "Get a player's pocket items.", 104 | parameters = { 105 | }, 106 | returns = { 107 | { 108 | name = "items", 109 | description = "A table containing crucial information about the items in the pocket.", 110 | type = "table" 111 | } 112 | }, 113 | metatable = meta, 114 | realm = "Shared" 115 | } 116 | -------------------------------------------------------------------------------- /lua/weapons/pocket/sv_init.lua: -------------------------------------------------------------------------------- 1 | local meta = FindMetaTable("Player") 2 | if not(DarkRP) then return false end 3 | 4 | /*--------------------------------------------------------------------------- 5 | Functions 6 | ---------------------------------------------------------------------------*/ 7 | -- workaround: GetNetworkVars doesn't give entities because the /duplicator/ doesn"t want to save entities 8 | local function getDTVars(ent) 9 | if not ent.GetNetworkVars then return nil end 10 | local name, value = debug.getupvalue(ent.GetNetworkVars, 1) 11 | if name ~= "datatable" then 12 | ErrorNoHalt("Warning: Datatable cannot be stored properly in pocket. Tell a developer!") 13 | end 14 | 15 | local res = {} 16 | 17 | for k,v in pairs(value) do 18 | res[k] = v.GetFunc(ent, v.index) 19 | end 20 | 21 | return res 22 | end 23 | 24 | local function serialize(ent) 25 | local serialized = duplicator.CopyEntTable(ent) 26 | serialized.DT = getDTVars(ent) 27 | serialized.DarkRPItem = ent.DarkRPItem or {} 28 | serialized.StoredMoney = ent.StoredMoney or 0 29 | serialized.StoredXP = ent.StoredXP or 0 30 | return serialized 31 | end 32 | 33 | local function deserialize(ply, item) 34 | local ent = ents.Create(item.Class) 35 | duplicator.DoGeneric(ent, item) 36 | ent.DarkRPItem = item.DarkRPItem 37 | ent.StoredMoney = item.StoredMoney 38 | ent.StoredXP = item.StoredXP 39 | ent:Spawn() 40 | ent:Activate() 41 | 42 | 43 | duplicator.DoGenericPhysics(ent, ply, item) 44 | table.Merge(ent:GetTable(), item) 45 | 46 | local pos, mins = ent:GetPos(), ent:WorldSpaceAABB() 47 | local offset = pos.z - mins.z 48 | 49 | local trace = {} 50 | trace.start = ply:EyePos() 51 | trace.endpos = trace.start + ply:GetAimVector() * 85 52 | trace.filter = ply 53 | 54 | local tr = util.TraceLine(trace) 55 | ent:SetPos(tr.HitPos + Vector(0, 0, offset)) 56 | 57 | local phys = ent:GetPhysicsObject() 58 | if phys:IsValid() then phys:Wake() end 59 | 60 | return ent 61 | end 62 | 63 | local function dropAllPocketItems(ply) 64 | for k,v in pairs(ply.darkRPPocket or {}) do 65 | ply:dropPocketItem(k) 66 | end 67 | end 68 | 69 | util.AddNetworkString("DarkRP_Pocket") 70 | local function sendPocketItems(ply) 71 | net.Start("DarkRP_Pocket") 72 | net.WriteTable(ply:getPocketItems()) 73 | net.Send(ply) 74 | end 75 | 76 | /*--------------------------------------------------------------------------- 77 | Interface functions 78 | ---------------------------------------------------------------------------*/ 79 | function meta:addPocketItem(ent) 80 | if not IsValid(ent) then error("Entity not valid", 2) end 81 | 82 | local serialized = serialize(ent) 83 | 84 | hook.Call("onPocketItemAdded", nil, self, ent, serialized) 85 | 86 | ent:Remove() 87 | 88 | self.darkRPPocket = self.darkRPPocket or {} 89 | 90 | local id = table.insert(self.darkRPPocket, serialized) 91 | sendPocketItems(self) 92 | return id 93 | end 94 | 95 | function meta:removePocketItem(item) 96 | if not self.darkRPPocket or not self.darkRPPocket[item] then error("Player does not contain " .. item .. " in their pocket.", 2) end 97 | 98 | hook.Call("onPocketItemRemoved", nil, self, item) 99 | 100 | self.darkRPPocket[item] = nil 101 | sendPocketItems(self) 102 | end 103 | 104 | function meta:dropPocketItem(item) 105 | if not self.darkRPPocket or not self.darkRPPocket[item] then error("Player does not contain " .. item .. " in their pocket.", 2) end 106 | 107 | local id = self.darkRPPocket[item] 108 | local ent = deserialize(self, id) 109 | 110 | self:removePocketItem(item) 111 | return ent 112 | end 113 | 114 | -- serverside implementation 115 | function meta:getPocketItems() 116 | self.darkRPPocket = self.darkRPPocket or {} 117 | 118 | local res = {} 119 | for k,v in pairs(self.darkRPPocket) do 120 | res[k] = { 121 | model = v.Model, 122 | class = v.Class 123 | } 124 | end 125 | 126 | return res 127 | end 128 | 129 | /*--------------------------------------------------------------------------- 130 | Commands 131 | ---------------------------------------------------------------------------*/ 132 | util.AddNetworkString("DarkRP_spawnPocket") 133 | net.Receive("DarkRP_spawnPocket", function(len, ply) 134 | local item = net.ReadFloat() 135 | if not ply.darkRPPocket[item] then return end 136 | ply:dropPocketItem(item) 137 | end) 138 | 139 | /*--------------------------------------------------------------------------- 140 | Hooks 141 | ---------------------------------------------------------------------------*/ 142 | 143 | local function onAdded(ply, ent, serialized) 144 | if not ent:IsValid() or not ent.DarkRPItem or not ent.Getowning_ent or not IsValid(ent:Getowning_ent()) then return end 145 | 146 | local ply = ent:Getowning_ent() 147 | local cmdname = string.gsub(ent.DarkRPItem.ent, " ", "_") 148 | 149 | ply:addCustomEntity(ent.DarkRPItem) 150 | end 151 | hook.Add("onPocketItemAdded", "defaultImplementation", onAdded) 152 | 153 | local function canPocket(ply, item) 154 | if not IsValid(item) then return false end 155 | local class = item:GetClass() 156 | 157 | if item.Removed then return false, DarkRP.getPhrase("cannot_pocket_x") end 158 | if not item:CPPICanPickup(ply) then return false, DarkRP.getPhrase("cannot_pocket_x") end 159 | if item.jailWall then return false, DarkRP.getPhrase("cannot_pocket_x") end 160 | if GAMEMODE.Config.PocketBlacklist[class] then return false, DarkRP.getPhrase("cannot_pocket_x") end 161 | if string.find(class, "func_") then return false, DarkRP.getPhrase("cannot_pocket_x") end 162 | 163 | local trace = ply:GetEyeTrace() 164 | if ply:EyePos():Distance(trace.HitPos) > 150 then return false end 165 | 166 | local phys = trace.Entity:GetPhysicsObject() 167 | if not phys:IsValid() then return false end 168 | 169 | local mass = trace.Entity.RPOriginalMass and trace.Entity.RPOriginalMass or phys:GetMass() 170 | if mass > 100 then return false, DarkRP.getPhrase("object_too_heavy") end 171 | 172 | local job = ply:Team() 173 | local max = RPExtraTeams[job].maxpocket or GAMEMODE.Config.pocketitems 174 | if table.Count(ply.darkRPPocket or {}) >= max then return false, DarkRP.getPhrase("pocket_full") end 175 | 176 | return true 177 | end 178 | hook.Add("canPocket", "defaultRestrictions", canPocket) 179 | 180 | 181 | -- Drop pocket items on death 182 | hook.Add("PlayerDeath", "DropPocketItems", function(ply) 183 | if not GAMEMODE.Config.droppocketdeath or not ply.darkRPPocket then return end 184 | dropAllPocketItems(ply) 185 | end) 186 | 187 | hook.Add("playerArrested", "DropPocketItems", function(ply) 188 | if not GAMEMODE.Config.droppocketarrest then return end 189 | dropAllPocketItems(ply) 190 | end) 191 | -------------------------------------------------------------------------------- /materials/vrondakis/xp_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uen/Leveling-System/7e083636174777cc580100379d8ff64a25b4f55a/materials/vrondakis/xp_bar.png -------------------------------------------------------------------------------- /resource/fonts/francoisone.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uen/Leveling-System/7e083636174777cc580100379d8ff64a25b4f55a/resource/fonts/francoisone.ttf --------------------------------------------------------------------------------