diff --git a/.gitignore b/.gitignore index db52e9bd..88f5619d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,338 @@ -bin/* - -obj/* - -Migrations/* - -Properties/* -*.csproj +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +# User-specific files +*.rsuser +*.suo *.user +*.userosscache +*.sln.docstates -!.gitkeep -yolo/* -/mycmds.cs -/Server/Commands/mycmds.cs +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Migrations Folder +Migrations/ +/Properties/launchSettings.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 99bee2cc..fb381229 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: - build before_script: - - "../database_password.sh" + - "../gm_database_password.sh" - "dotnet restore" build: @@ -10,4 +10,4 @@ build: only: - develop script: - - "dotnet build" + - "dotnet build -c ServerBuild" diff --git a/Client/DoorManager/doormanager.js b/Client/DoorManager/doormanager.js new file mode 100644 index 00000000..b411b8ca --- /dev/null +++ b/Client/DoorManager/doormanager.js @@ -0,0 +1,5 @@ +mp.events.add('changeDoorState', (doorHash, x, y, z, locked, p5, p6, p7) => { + locked === 1 ? locked = true : locked = false; + + mp.game.object.doorControl(doorHash, x, y, z, locked, p5, p6, p7); +}); \ No newline at end of file diff --git a/Client/FactionManagement/main.js b/Client/FactionManagement/main.js index a3168947..26e99e72 100644 --- a/Client/FactionManagement/main.js +++ b/Client/FactionManagement/main.js @@ -11,24 +11,6 @@ mp.events.add('manageFactionRanks', (ranks) => { if (manageFactionRanksBrowser !== null) return; manageFactionRanksBrowser = mp.browsers.new('package://FactionManagement/Ranks/index.html'); - //var testRanks = { - // FactionId: 3, - // Ranks: [ - // { - // Id: 5, - // Name: "Officer" - // }, - // { - // Id: 6, - // Name: "Sergeant" - // } - // ] - //}; - - //var json = JSON.stringify(testRanks); - - //mp.events.callRemote('OnFactionRanksEdit', json); - mp.gui.chat.activate(false); rankData = JSON.parse(ranks); }); diff --git a/Client/Gui/deathscreen.js b/Client/Gui/deathscreen.js index 82dc413a..639403b9 100644 --- a/Client/Gui/deathscreen.js +++ b/Client/Gui/deathscreen.js @@ -49,7 +49,7 @@ mp.events.add("respawnDeathPlayer", () => { }); mp.events.add("updateDutyMedics", (count) => { - if (count == true) + if (count === true) { dutyMedics++; } @@ -70,11 +70,11 @@ mp.events.add("render", () => { if (dutyMedics > 0) { medicString = "Derzeit sind ~g~" + dutyMedics + " Medics ~s~im Dienst ~c~und versuchen dich wiederzubeleben..."; } else { - medicString = "Derzeit sind ~r~keine Medics ~s~im Dienst." + medicString = "Derzeit sind ~r~keine Medics ~s~im Dienst."; } deathSeconds = respawnTime - Math.floor(currentDate.getTime() / 1000); - var alpha = fade + (Math.floor((currentDate.getTime() / 1000) - (deathDate.getTime() / 1000))); + var alpha = fade + Math.floor(currentDate.getTime() / 1000 - deathDate.getTime() / 1000); if (deathSeconds >= 0) { mp.game.graphics.drawSprite("Mptattoos", "clearout", 0.625, 0.52, 0.1, 0.1, 0, 255, 255, 255, 236); mp.game.graphics.drawText("Respawn in: ~y~" + deathSeconds, [0.5, 0.5], @@ -83,14 +83,14 @@ mp.events.add("render", () => { color: [255, 255, 255, 255], scale: [0.8, 0.8], outline: true - }) + }); mp.game.graphics.drawText(medicString, [0.5, 0.975], { font: 4, color: [255, 255, 255, 255], scale: [0.4, 0.4], outline: true - }) + }); mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha); } else { diff --git a/Client/Gui/infobox.js b/Client/Gui/infobox.js index 6b0a5bae..f8262bd2 100644 --- a/Client/Gui/infobox.js +++ b/Client/Gui/infobox.js @@ -9,6 +9,7 @@ var dateString; var timeString; var draw = false; +var editMode = false; let posX = 0.92; let posY = 0.45; @@ -43,6 +44,26 @@ mp.events.add("draw", (pName, pId) => { }); +mp.events.add("toggleEditMode", (toggle) => { + editMode = toggle; +}); + +mp.events.add("toggleUi", (show) => { + if (show === false) { + draw = false; + mp.game.ui.displayRadar(false); + mp.game.ui.displayHud(false); + mp.gui.chat.show(false); + globalData.HideGui = true; + } else { + draw = true; + mp.game.ui.displayRadar(true); + mp.game.ui.displayHud(true); + mp.gui.chat.show(true); + globalData.HideGui = false; + } +}); + //function currencyFormatDE(num) { // return ('$' + num.toFixed(2).replace('.', ',').replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.')); //} @@ -173,4 +194,13 @@ mp.events.add("render", () => { outline: true }) } + if (editMode === true) { + mp.game.graphics.drawText("~r~EDIT-MODE AKTIV", [0.5, 0], + { + font: 4, + color: [255, 255, 255, 255], + scale: [0.7, 0.7], + outline: true + }) + } }); \ No newline at end of file diff --git a/Client/Gui/nametags.js b/Client/Gui/nametags.js new file mode 100644 index 00000000..c958a611 --- /dev/null +++ b/Client/Gui/nametags.js @@ -0,0 +1,57 @@ +const maxDistance = 25 * 25; +const width = 0.03; +const height = 0.0065; +const border = 0.001; +const color = [255, 255, 255, 255]; + +mp.nametags.enabled = false; + +mp.events.add('render', (nametags) => { + const graphics = mp.game.graphics; + const screenRes = graphics.getScreenResolution(0, 0); + + nametags.forEach(nametag => { + let [player, x, y, distance] = nametag; + + if (distance <= maxDistance) { + let scale = distance / maxDistance; + if (scale < 0.6) scale = 0.6; + + var health = player.getHealth(); + health = health < 100 ? 0 : (health - 100) / 100; + + var armour = player.getArmour() / 100; + + y -= scale * (0.005 * (screenRes.y / 1080)); + + mp.game.graphics.drawText(player.name + " (" + player.remoteId + ")", [x, y], + { + font: 4, + color: [255, 255, 255, 255], + scale: [0.4, 0.4], + outline: true + }); + + if (mp.game.player.isFreeAimingAtEntity(player.handle)) { + let y2 = y + 0.042; + + if (armour > 0) { + graphics.drawRect(x, y2, width + border * 2, 0.0085, 0, 0, 0, 200); + graphics.drawRect(x, y2, width, height, 150, 150, 150, 255); + graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200); + + x2 = x + width / 2 + border / 2; + + graphics.drawRect(x, y2 + height, width + border * 2, height + border * 2, 0, 0, 0, 200); + graphics.drawRect(x, y2 + height, width, height, 41, 66, 78, 255); + graphics.drawRect(x - width / 2 * (1 - armour), y2 + height, width * armour, height, 48, 108, 135, 200); + } + else { + graphics.drawRect(x, y2, width + border * 2, height + border * 2, 0, 0, 0, 200); + graphics.drawRect(x, y2, width, height, 150, 150, 150, 255); + graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200); + } + } + } + }); +}); \ No newline at end of file diff --git a/Client/Player/dutycloth.js b/Client/Player/dutycloth.js new file mode 100644 index 00000000..677a2ac3 --- /dev/null +++ b/Client/Player/dutycloth.js @@ -0,0 +1,108 @@ +/** + * @overview Life of German Reallife - Player DutyClothes dutyclothes.js + * @author VegaZ + * @copyright (c) 2008 - 2018 Life of German + */ + +const NativeUI = require("nativeui"); +const Menu = NativeUI.Menu; +const UIMenuItem = NativeUI.UIMenuItem; +const UIMenuListItem = NativeUI.UIMenuListItem; +const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem; +const BadgeStyle = NativeUI.BadgeStyle; +const Point = NativeUI.Point; +const ItemsCollection = NativeUI.ItemsCollection; +const Color = NativeUI.Color; + +var hats; +var tops; +var legs; +var shoes; + +var hat = -1; +var top; +var leg; +var shoe; + +let screenRes = mp.game.graphics.getScreenResolution(0, 0); + +var dutyMenu; +let saveItem = new UIMenuItem("Speichern", "Speichert deine Dienstkleidung"); +saveItem.BackColor = new Color(13, 71, 161); +saveItem.HighlightedBackColor = new Color(25, 118, 210); + +let cancelItem = new UIMenuItem("Abbrechen", ""); +cancelItem.BackColor = new Color(213, 0, 0); +cancelItem.HighlightedBackColor = new Color(229, 57, 53); + + +//Cloth Menu + +mp.events.add('showDutyClothMenu', (hatsArr, topsArr, legsArr, shoesArr) => { + + mp.gui.chat.activate(false); + hats = hatsArr; + tops = topsArr; + legs = legsArr; + shoes = shoesArr; + + dutyMenu = new Menu("Dienstkleidung", "Stelle deine Dienstkleidung zusammen", new Point(0, screenRes.y/2)); + + dutyMenu.AddItem(new UIMenuListItem("Hut", "", new ItemsCollection(hats))); + dutyMenu.AddItem(new UIMenuListItem("Top", "", new ItemsCollection(tops))); + dutyMenu.AddItem(new UIMenuListItem("Hose", "", new ItemsCollection(legs))); + dutyMenu.AddItem(new UIMenuListItem("Schuhe", "", new ItemsCollection(shoes))); + dutyMenu.AddItem(saveItem); + dutyMenu.AddItem(cancelItem); + dutyMenu.Visible = true; + + dutyMenu.ListChange.on((item, index) => { + switch (item.Text) { + case "Hut": + if (item.SelectedItem.DisplayText === "Keinen") { + hat = -1; + mp.events.callRemote("updateDutyProp", 0, -1); + } else { + hat = parseInt(item.SelectedItem.DisplayText); + mp.events.callRemote("updateDutyProp", 0, hat); + } + break; + case "Top": + top = parseInt(item.SelectedItem.DisplayText); + mp.events.callRemote("updateDutyCloth", 11, top); + break; + case "Hose": + leg = parseInt(item.SelectedItem.DisplayText); + mp.events.callRemote("updateDutyCloth", 4, leg); + break; + case "Schuhe": + shoe = parseInt(item.SelectedItem.DisplayText); + mp.events.callRemote("updateDutyCloth", 6, shoe); + break; + } + }); + + dutyMenu.ItemSelect.on((item) => { + if (item.Text === "Speichern") { + var slotType = [1, 0, 0, 0]; + var slotId = [0, 11, 4, 6]; + var clothId = [hat, top, leg, shoe]; + mp.events.callRemote("saveCharacterCloth", JSON.stringify(slotType), JSON.stringify(slotId), JSON.stringify(clothId)); + dutyMenu.Visible = false; + mp.gui.chat.activate(true); + } else if (item.Text === "Abbrechen") { + dutyMenu.Visible = false; + mp.gui.chat.activate(true); + mp.events.callRemote("defaultCharacterCloth"); + } + }); + + + dutyMenu.MenuClose.on(() => { + dutyMenu.Visible = false; + mp.gui.chat.activate(true); + mp.events.callRemote("defaultCharacterCloth"); + }); +}); + + diff --git a/Client/Player/keys.js b/Client/Player/keys.js index 7a18021b..0f845504 100644 --- a/Client/Player/keys.js +++ b/Client/Player/keys.js @@ -7,7 +7,11 @@ //https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes var chat = false; +<<<<<<< HEAD var showInventory = false; +======= +var showGui = true; +>>>>>>> develop //ENTER mp.keys.bind(0x0D, false, function () { @@ -16,7 +20,32 @@ mp.keys.bind(0x0D, false, function () { } }); -//I + +//F7 //Unshowalles +mp.keys.bind(0x76, false, function () { + if (showGui === true) { + showGui = false; + mp.events.call("toggleUi", false); + } else { + showGui = true; + mp.events.call("toggleUi", true); + } +}); + +//NUM2 //Save Blips in Edit Mode +mp.keys.bind(0x62, false, function () { + mp.events.callRemote("keyPress:NUM2"); +}); + +//E +mp.keys.bind(0x45, false, function () { + if (!chat) { + mp.events.callRemote("keyPress:E"); + } +}); + + +//I //Spielerliste mp.keys.bind(0x49, false, function () { if (!chat) { mp.events.callRemote("keyPress:I"); @@ -24,6 +53,7 @@ mp.keys.bind(0x49, false, function () { } }); +<<<<<<< HEAD //J mp.keys.bind(0x4A, false, function () { if (showInventory === false) { @@ -36,6 +66,23 @@ mp.keys.bind(0x4A, false, function () { }); //N +======= +//K //Dienstkleidung +mp.keys.bind(0x4B, false, function () { + if (!chat) { + mp.events.callRemote("keyPress:K"); + } +}); + +//L //Türen auf / zuschließen +mp.keys.bind(0x4C, false, function () { + if (!chat) { + mp.events.callRemote("keyPress:L"); + } +}); + +//N //Motor Starten +>>>>>>> develop mp.keys.bind(0x4E, false, function () { if (!chat) { mp.events.callRemote("keyPress:N"); @@ -49,9 +96,10 @@ mp.keys.bind(0x54, false, function () { } }); -//X +//X //Anschnallen mp.keys.bind(0x58, false, function () { if (!chat) { mp.events.callRemote("keyPress:X"); } }); + diff --git a/Client/Save/save.html b/Client/Save/blip/save.html similarity index 100% rename from Client/Save/save.html rename to Client/Save/blip/save.html diff --git a/Client/Save/save.js b/Client/Save/blip/save.js similarity index 84% rename from Client/Save/save.js rename to Client/Save/blip/save.js index 0d57b9e3..061f62fa 100644 --- a/Client/Save/save.js +++ b/Client/Save/blip/save.js @@ -15,7 +15,7 @@ function saveData() { let blipRotation = document.getElementById("blipRotation").value; let blipDimension = document.getElementById("blipDimension").value; - mp.trigger("saveData", blipSprite, blipName, blipScale, blipColor, blipAlpha, blipDrawDistance, blipShortRange, blipRotation, blipDimension); + mp.trigger("saveBlipData", blipSprite, blipName, blipScale, blipColor, blipAlpha, blipDrawDistance, blipShortRange, blipRotation, blipDimension); } function cancelData() { diff --git a/Client/Save/style.css b/Client/Save/blip/style.css similarity index 100% rename from Client/Save/style.css rename to Client/Save/blip/style.css diff --git a/Client/Save/main.js b/Client/Save/main.js index b40e649f..e6513ee0 100644 --- a/Client/Save/main.js +++ b/Client/Save/main.js @@ -7,12 +7,12 @@ var saveBrowser; mp.events.add('saveBlip', () => { - saveBrowser = mp.browsers.new('package://Save/save.html'); + saveBrowser = mp.browsers.new('package://Save/blip/save.html'); mp.gui.chat.activate(false); mp.gui.cursor.show(true, true); }); -mp.events.add('saveData', (blipSprite, blipName, blipScale, blipColor, blipAlpha, blipDrawDistance, blipShortRange, blipRotation, blipDimension) => { +mp.events.add('saveBlipData', (blipSprite, blipName, blipScale, blipColor, blipAlpha, blipDrawDistance, blipShortRange, blipRotation, blipDimension) => { if (saveBrowser) { saveBrowser.destroy(); } diff --git a/Client/Speedometer/cef/css/style.css b/Client/Speedometer/cef/css/style.css new file mode 100644 index 00000000..094f9d12 --- /dev/null +++ b/Client/Speedometer/cef/css/style.css @@ -0,0 +1,1628 @@ +/* W3.CSS 4.04 Apr 2017 by Jan Egil and Borge Refsnes */ +html { + box-sizing: border-box +} + +* { + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +*, *:before, *:after { + box-sizing: inherit +} +html { + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100% +} + + +body { + margin: 0; + opacity: 0; + transition: opacity 1s; +} + +body.fade { + opacity: 1; +} + +article, aside, details, figcaption, figure, footer, header, main, menu, nav, section, summary { + display: block +} + +audio, canvas, progress, video { + display: inline-block +} + +progress { + vertical-align: baseline +} + +audio:not([controls]) { + display: none; + height: 0 +} + +[hidden], template { + display: none +} + +a { + background-color: transparent; + -webkit-text-decoration-skip: objects +} + + a:active, a:hover { + outline-width: 0 + } + +abbr[title] { + border-bottom: none; + text-decoration: underline; + text-decoration: underline dotted +} + +dfn { + font-style: italic +} + +mark { + background: #ff0; + color: #000 +} + +small { + font-size: 80% +} + +sub, sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline +} + +sub { + bottom: -0.25em +} + +sup { + top: -0.5em +} + +figure { + margin: 1em 40px +} + +img { + border-style: none +} + +svg:not(:root) { + overflow: hidden +} + +code, kbd, pre, samp { + font-family: monospace,monospace; + font-size: 1em +} + +hr { + box-sizing: content-box; + height: 0; + overflow: visible +} + +button, input, select, textarea { + font: inherit; + margin: 0 +} + +optgroup { + font-weight: bold +} + +button, input { + overflow: visible +} + +button, select { + text-transform: none +} + +button, html [type=button], [type=reset], [type=submit] { + -webkit-appearance: button +} + + button::-moz-focus-inner, [type=button]::-moz-focus-inner, [type=reset]::-moz-focus-inner, [type=submit]::-moz-focus-inner { + border-style: none; + padding: 0 + } + + button:-moz-focusring, [type=button]:-moz-focusring, [type=reset]:-moz-focusring, [type=submit]:-moz-focusring { + outline: 1px dotted ButtonText + } + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: .35em .625em .75em +} + +legend { + color: inherit; + display: table; + max-width: 100%; + padding: 0; + white-space: normal +} + +textarea { + overflow: auto +} + +[type=checkbox], [type=radio] { + padding: 0 +} + +[type=number]::-webkit-inner-spin-button, [type=number]::-webkit-outer-spin-button { + height: auto +} + +[type=search] { + -webkit-appearance: textfield; + outline-offset: -2px +} + + [type=search]::-webkit-search-cancel-button, [type=search]::-webkit-search-decoration { + -webkit-appearance: none + } + +::-webkit-input-placeholder { + color: inherit; + opacity: 0.54 +} + +::-webkit-file-upload-button { + -webkit-appearance: button; + font: inherit +} +/* End extract */ +html, body { + font-family: Verdana,sans-serif; + font-size: 15px; + line-height: 1.5 +} + +html { + overflow-x: hidden +} + +h1 { + font-size: 36px +} + +h2 { + font-size: 30px +} + +h3 { + font-size: 24px +} + +h4 { + font-size: 20px +} + +h5 { + font-size: 18px +} + +h6 { + font-size: 16px +} + +.w3-serif { + font-family: serif +} + +h1, h2, h3, h4, h5, h6 { + font-family: "Segoe UI",Arial,sans-serif; + font-weight: 400; + margin: 10px 0 +} + +.w3-wide { + letter-spacing: 4px +} + +hr { + border: 0; + border-top: 1px solid #eee; + margin: 20px 0 +} + +.w3-image { + max-width: 100%; + height: auto +} + +img { + margin-bottom: -5px +} + +a { + color: inherit +} + +.w3-table, .w3-table-all { + border-collapse: collapse; + border-spacing: 0; + width: 100%; + display: table +} + +.w3-table-all { + border: 1px solid #ccc +} + + .w3-bordered tr, .w3-table-all tr { + border-bottom: 1px solid #ddd + } + +.w3-striped tbody tr:nth-child(even) { + background-color: #f1f1f1 +} + +.w3-table-all tr:nth-child(odd) { + background-color: #fff +} + +.w3-table-all tr:nth-child(even) { + background-color: #f1f1f1 +} + +.w3-hoverable tbody tr:hover, .w3-ul.w3-hoverable li:hover { + background-color: #ccc +} + +.w3-centered tr th, .w3-centered tr td { + text-align: center +} + +.w3-table td, .w3-table th, .w3-table-all td, .w3-table-all th { + padding: 8px 8px; + display: table-cell; + text-align: left; + vertical-align: top +} + + .w3-table th:first-child, .w3-table td:first-child, .w3-table-all th:first-child, .w3-table-all td:first-child { + padding-left: 16px + } + +.w3-btn, .w3-button { + border: none; + display: inline-block; + outline: 0; + padding: 8px 16px; + vertical-align: middle; + overflow: hidden; + text-decoration: none; + color: inherit; + background-color: inherit; + text-align: center; + cursor: pointer; + white-space: nowrap +} + + .w3-btn:hover { + box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19) + } + +.w3-btn, .w3-button { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none +} + + .w3-disabled, .w3-btn:disabled, .w3-button:disabled { + cursor: not-allowed; + opacity: 0.3 + } + + .w3-disabled *, :disabled * { + pointer-events: none + } + + .w3-btn.w3-disabled:hover, .w3-btn:disabled:hover { + box-shadow: none + } + +.w3-badge, .w3-tag { + background-color: #000; + color: #fff; + display: inline-block; + padding-left: 8px; + padding-right: 8px; + text-align: center +} + +.w3-badge { + border-radius: 50% +} + +.w3-ul { + list-style-type: none; + padding: 0; + margin: 0 +} + + .w3-ul li { + padding: 8px 16px; + border-bottom: 1px solid #ddd + } + + .w3-ul li:last-child { + border-bottom: none + } + +.w3-tooltip, .w3-display-container { + position: relative +} + + .w3-tooltip .w3-text { + display: none + } + + .w3-tooltip:hover .w3-text { + display: inline-block + } + +.w3-ripple:active { + opacity: 0.5 +} + +.w3-ripple { + transition: opacity 0s +} + +.w3-input { + padding: 8px; + display: block; + border: none; + border-bottom: 1px solid #ccc; + width: 100% +} + +.w3-select { + padding: 9px 0; + width: 100%; + border: none; + border-bottom: 1px solid #ccc +} + +.w3-dropdown-click, .w3-dropdown-hover { + position: relative; + display: inline-block; + cursor: pointer +} + + .w3-dropdown-hover:hover .w3-dropdown-content { + display: block; + z-index: 1 + } + + .w3-dropdown-hover:first-child, .w3-dropdown-click:hover { + background-color: #ccc; + color: #000 + } + + .w3-dropdown-hover:hover > .w3-button:first-child, .w3-dropdown-click:hover > .w3-button:first-child { + background-color: #ccc; + color: #000 + } + +.w3-dropdown-content { + cursor: auto; + color: #000; + background-color: #fff; + display: none; + position: absolute; + min-width: 160px; + margin: 0; + padding: 0 +} + +.w3-check, .w3-radio { + width: 24px; + height: 24px; + position: relative; + top: 6px +} + +.w3-sidebar { + height: 100%; + width: 200px; + background-color: #fff; + position: fixed !important; + z-index: 1; + overflow: auto +} + +.w3-bar-block .w3-dropdown-hover, .w3-bar-block .w3-dropdown-click { + width: 100% +} + + .w3-bar-block .w3-dropdown-hover .w3-dropdown-content, .w3-bar-block .w3-dropdown-click .w3-dropdown-content { + min-width: 100% + } + + .w3-bar-block .w3-dropdown-hover .w3-button, .w3-bar-block .w3-dropdown-click .w3-button { + width: 100%; + text-align: left; + padding: 8px 16px + } + +.w3-main, #main { + transition: margin-left .4s +} + +.w3-modal { + z-index: 3; + display: none; + padding-top: 100px; + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgb(0,0,0); + background-color: rgba(0,0,0,0.4) +} + +.w3-modal-content { + margin: auto; + background-color: #fff; + position: relative; + padding: 0; + outline: 0; + width: 600px +} + +.w3-bar { + width: 100%; + overflow: hidden +} + +.w3-center .w3-bar { + display: inline-block; + width: auto +} + +.w3-bar .w3-bar-item { + padding: 8px 16px; + float: left; + width: auto; + border: none; + outline: none; + display: block +} + +.w3-bar .w3-dropdown-hover, .w3-bar .w3-dropdown-click { + position: static; + float: left +} + +.w3-bar .w3-button { + white-space: normal +} + +.w3-bar-block .w3-bar-item { + width: 100%; + display: block; + padding: 8px 16px; + text-align: left; + border: none; + outline: none; + white-space: normal; + float: none +} + +.w3-bar-block.w3-center .w3-bar-item { + text-align: center +} + +.w3-block { + display: block; + width: 100% +} + +.w3-responsive { + overflow-x: auto +} + +.w3-container:after, .w3-container:before, .w3-panel:after, .w3-panel:before, .w3-row:after, .w3-row:before, .w3-row-padding:after, .w3-row-padding:before, +.w3-cell-row:before, .w3-cell-row:after, .w3-clear:after, .w3-clear:before, .w3-bar:before, .w3-bar:after { + content: ""; + display: table; + clear: both +} + +.w3-col, .w3-half, .w3-third, .w3-twothird, .w3-threequarter, .w3-quarter { + float: left; + width: 100% +} + + .w3-col.s1 { + width: 8.33333% + } + + .w3-col.s2 { + width: 16.66666% + } + + .w3-col.s3 { + width: 24.99999% + } + + .w3-col.s4 { + width: 33.33333% + } + + .w3-col.s5 { + width: 41.66666% + } + + .w3-col.s6 { + width: 49.99999% + } + + .w3-col.s7 { + width: 58.33333% + } + + .w3-col.s8 { + width: 66.66666% + } + + .w3-col.s9 { + width: 74.99999% + } + + .w3-col.s10 { + width: 83.33333% + } + + .w3-col.s11 { + width: 91.66666% + } + + .w3-col.s12 { + width: 99.99999% + } + +@media (min-width:601px) { + .w3-col.m1 { + width: 8.33333% + } + + .w3-col.m2 { + width: 16.66666% + } + + .w3-col.m3, .w3-quarter { + width: 24.99999% + } + + .w3-col.m4, .w3-third { + width: 33.33333% + } + + .w3-col.m5 { + width: 41.66666% + } + + .w3-col.m6, .w3-half { + width: 49.99999% + } + + .w3-col.m7 { + width: 58.33333% + } + + .w3-col.m8, .w3-twothird { + width: 66.66666% + } + + .w3-col.m9, .w3-threequarter { + width: 74.99999% + } + + .w3-col.m10 { + width: 83.33333% + } + + .w3-col.m11 { + width: 91.66666% + } + + .w3-col.m12 { + width: 99.99999% + } +} + +@media (min-width:993px) { + .w3-col.l1 { + width: 8.33333% + } + + .w3-col.l2 { + width: 16.66666% + } + + .w3-col.l3 { + width: 24.99999% + } + + .w3-col.l4 { + width: 33.33333% + } + + .w3-col.l5 { + width: 41.66666% + } + + .w3-col.l6 { + width: 49.99999% + } + + .w3-col.l7 { + width: 58.33333% + } + + .w3-col.l8 { + width: 66.66666% + } + + .w3-col.l9 { + width: 74.99999% + } + + .w3-col.l10 { + width: 83.33333% + } + + .w3-col.l11 { + width: 91.66666% + } + + .w3-col.l12 { + width: 99.99999% + } +} + +.w3-content { + max-width: 980px; + margin: auto +} + +.w3-rest { + overflow: hidden +} + +.w3-cell-row { + display: table; + width: 100% +} + +.w3-cell { + display: table-cell +} + +.w3-cell-top { + vertical-align: top +} + +.w3-cell-middle { + vertical-align: middle +} + +.w3-cell-bottom { + vertical-align: bottom +} + +.w3-hide { + display: none !important +} + +.w3-show-block, .w3-show { + display: block !important +} + +.w3-show-inline-block { + display: inline-block !important +} + +@media (max-width:600px) { + .w3-modal-content { + margin: 0 10px; + width: auto !important + } + + .w3-modal { + padding-top: 30px + } + + .w3-dropdown-hover.w3-mobile .w3-dropdown-content, .w3-dropdown-click.w3-mobile .w3-dropdown-content { + position: relative + } + + .w3-hide-small { + display: none !important + } + + .w3-mobile { + display: block; + width: 100% !important + } + + .w3-bar-item.w3-mobile, .w3-dropdown-hover.w3-mobile, .w3-dropdown-click.w3-mobile { + text-align: center + } + + .w3-dropdown-hover.w3-mobile, .w3-dropdown-hover.w3-mobile .w3-btn, .w3-dropdown-hover.w3-mobile .w3-button, .w3-dropdown-click.w3-mobile, .w3-dropdown-click.w3-mobile .w3-btn, .w3-dropdown-click.w3-mobile .w3-button { + width: 100% + } +} + +@media (max-width:768px) { + .w3-modal-content { + width: 500px + } + + .w3-modal { + padding-top: 50px + } +} + +@media (min-width:993px) { + .w3-modal-content { + width: 900px + } + + .w3-hide-large { + display: none !important + } + + .w3-sidebar.w3-collapse { + display: block !important + } +} + +@media (max-width:992px) and (min-width:601px) { + .w3-hide-medium { + display: none !important + } +} + +@media (max-width:992px) { + .w3-sidebar.w3-collapse { + display: none + } + + .w3-main { + margin-left: 0 !important; + margin-right: 0 !important + } +} + +.w3-top, .w3-bottom { + position: fixed; + width: 100%; + z-index: 1 +} + +.w3-top { + top: 0 +} + +.w3-bottom { + bottom: 0 +} + +.w3-overlay { + position: fixed; + display: none; + width: 100%; + height: 100%; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0,0,0,0.5); + z-index: 2 +} + +.w3-display-topleft { + position: absolute; + left: 0; + top: 0 +} + +.w3-display-topright { + position: absolute; + right: 0; + top: 0 +} + +.w3-display-bottomleft { + position: absolute; + left: -20; + bottom: 0 +} + +.w3-display-bottomright { + position: absolute; + right: -20; + bottom: 0 +} + +.w3-display-middle { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%,-50%); + -ms-transform: translate(-50%,-50%) +} + +.w3-display-left { + position: absolute; + top: 50%; + left: 0%; + transform: translate(0%,-50%); + -ms-transform: translate(-0%,-50%) +} + +.w3-display-right { + position: absolute; + top: 50%; + right: 0%; + transform: translate(0%,-50%); + -ms-transform: translate(0%,-50%) +} + +.w3-display-topmiddle { + position: absolute; + left: 50%; + top: 0; + transform: translate(-50%,0%); + -ms-transform: translate(-50%,0%) +} + +.w3-display-bottommiddle { + position: absolute; + left: 50%; + bottom: 0; + transform: translate(-50%,0%); + -ms-transform: translate(-50%,0%) +} + +.w3-display-container:hover .w3-display-hover { + display: block +} + +.w3-display-container:hover span.w3-display-hover { + display: inline-block +} + +.w3-display-hover { + display: none +} + +.w3-display-position { + position: absolute +} + +.w3-circle { + border-radius: 50% +} + +.w3-round-small { + border-radius: 2px +} + +.w3-round, .w3-round-medium { + border-radius: 4px +} + +.w3-round-large { + border-radius: 8px +} + +.w3-round-xlarge { + border-radius: 16px +} + +.w3-round-xxlarge { + border-radius: 32px +} + +.w3-row-padding, .w3-row-padding > .w3-half, .w3-row-padding > .w3-third, .w3-row-padding > .w3-twothird, .w3-row-padding > .w3-threequarter, .w3-row-padding > .w3-quarter, .w3-row-padding > .w3-col { + padding: 0 8px +} + +.w3-container, .w3-panel { + padding: 0.01em 16px +} + +.w3-panel { + margin-top: 16px; + margin-bottom: 16px +} + +.w3-code, .w3-codespan { + font-family: Consolas,"courier new"; + font-size: 16px +} + +.w3-code { + width: auto; + background-color: #fff; + padding: 8px 12px; + border-left: 4px solid #4CAF50; + word-wrap: break-word +} + +.w3-codespan { + color: crimson; + background-color: #f1f1f1; + padding-left: 4px; + padding-right: 4px; + font-size: 110% +} + +.w3-card, .w3-card-2 { + box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12) +} + +.w3-card-4, .w3-hover-shadow:hover { + box-shadow: 0 4px 10px 0 rgba(0,0,0,0.2),0 4px 20px 0 rgba(0,0,0,0.19) +} + +.w3-spin { + animation: w3-spin 2s infinite linear +} + +@keyframes w3-spin { + 0% { + transform: rotate(0deg) + } + + 100% { + transform: rotate(359deg) + } +} + +.w3-animate-fading { + animation: fading 10s infinite +} + +@keyframes fading { + 0% { + opacity: 0 + } + + 50% { + opacity: 1 + } + + 100% { + opacity: 0 + } +} + +.w3-animate-opacity { + animation: opac 0.8s +} + +@keyframes opac { + from { + opacity: 0 + } + + to { + opacity: 1 + } +} + +.w3-animate-top { + position: relative; + animation: animatetop 0.4s +} + +@keyframes animatetop { + from { + top: -300px; + opacity: 0 + } + + to { + top: 0; + opacity: 1 + } +} + +.w3-animate-left { + position: relative; + animation: animateleft 0.4s +} + +@keyframes animateleft { + from { + left: -300px; + opacity: 0 + } + + to { + left: 0; + opacity: 1 + } +} + +.w3-animate-right { + position: relative; + animation: animateright 0.4s +} + +@keyframes animateright { + from { + right: -300px; + opacity: 0 + } + + to { + right: 0; + opacity: 1 + } +} + +.w3-animate-bottom { + position: relative; + animation: animatebottom 0.4s +} + +@keyframes animatebottom { + from { + bottom: -300px; + opacity: 0 + } + + to { + bottom: 0; + opacity: 1 + } +} + +.w3-animate-zoom { + animation: animatezoom 0.6s +} + +@keyframes animatezoom { + from { + transform: scale(0) + } + + to { + transform: scale(1) + } +} + +.w3-animate-input { + transition: width 0.4s ease-in-out +} + + .w3-animate-input:focus { + width: 100% !important + } + +.w3-opacity, .w3-hover-opacity:hover { + opacity: 0.60 +} + +.w3-opacity-off, .w3-hover-opacity-off:hover { + opacity: 1 +} + +.w3-opacity-max { + opacity: 0.25 +} + +.w3-opacity-min { + opacity: 0.75 +} + +.w3-greyscale-max, .w3-grayscale-max, .w3-hover-greyscale:hover, .w3-hover-grayscale:hover { + filter: grayscale(100%) +} + +.w3-greyscale, .w3-grayscale { + filter: grayscale(75%) +} + +.w3-greyscale-min, .w3-grayscale-min { + filter: grayscale(50%) +} + +.w3-sepia { + filter: sepia(75%) +} + +.w3-sepia-max, .w3-hover-sepia:hover { + filter: sepia(100%) +} + +.w3-sepia-min { + filter: sepia(50%) +} + +.w3-tiny { + font-size: 10px !important +} + +.w3-small { + font-size: 12px !important +} + +.w3-medium { + font-size: 15px !important +} + +.w3-large { + font-size: 18px !important +} + +.w3-xlarge { + font-size: 24px !important +} + +.w3-xxlarge { + font-size: 36px !important +} + +.w3-xxxlarge { + font-size: 48px !important +} + +.w3-jumbo { + font-size: 64px !important +} + +.w3-left-align { + text-align: left !important +} + +.w3-right-align { + text-align: right !important +} + +.w3-justify { + text-align: justify !important +} + +.w3-center { + text-align: center !important +} + +.w3-border-0 { + border: 0 !important +} + +.w3-border { + border: 1px solid #ccc !important +} + +.w3-border-top { + border-top: 1px solid #ccc !important +} + +.w3-border-bottom { + border-bottom: 1px solid #ccc !important +} + +.w3-border-left { + border-left: 1px solid #ccc !important +} + +.w3-border-right { + border-right: 1px solid #ccc !important +} + +.w3-topbar { + border-top: 6px solid #ccc !important +} + +.w3-bottombar { + border-bottom: 6px solid #ccc !important +} + +.w3-leftbar { + border-left: 6px solid #ccc !important +} + +.w3-rightbar { + border-right: 6px solid #ccc !important +} + +.w3-section, .w3-code { + margin-top: 16px !important; + margin-bottom: 16px !important +} + +.w3-margin { + margin: 16px !important +} + +.w3-margin-top { + margin-top: 16px !important +} + +.w3-margin-bottom { + margin-bottom: 16px !important +} + +.w3-margin-left { + margin-left: 16px !important +} + +.w3-margin-right { + margin-right: 16px !important +} + +.w3-padding-small { + padding: 4px 8px !important +} + +.w3-padding { + padding: 8px 16px !important +} + +.w3-padding-large { + padding: 12px 24px !important +} + +.w3-padding-16 { + padding-top: 16px !important; + padding-bottom: 16px !important +} + +.w3-padding-24 { + padding-top: 24px !important; + padding-bottom: 24px !important +} + +.w3-padding-32 { + padding-top: 32px !important; + padding-bottom: 32px !important +} + +.w3-padding-48 { + padding-top: 48px !important; + padding-bottom: 48px !important +} + +.w3-padding-64 { + padding-top: 64px !important; + padding-bottom: 64px !important +} + +.w3-left { + float: left !important +} + +.w3-right { + float: right !important +} + +.w3-button:hover { + color: #000 !important; + background-color: #ccc !important +} + +.w3-transparent, .w3-hover-none:hover { + background-color: transparent !important +} + +.w3-hover-none:hover { + box-shadow: none !important +} +/* Colors */ +.w3-amber, .w3-hover-amber:hover { + color: #000 !important; + background-color: #ffc107 !important +} + +.w3-aqua, .w3-hover-aqua:hover { + color: #000 !important; + background-color: #00ffff !important +} + +.w3-blue, .w3-hover-blue:hover { + color: #fff !important; + background-color: #2196F3 !important +} + +.w3-light-blue, .w3-hover-light-blue:hover { + color: #000 !important; + background-color: #87CEEB !important +} + +.w3-brown, .w3-hover-brown:hover { + color: #fff !important; + background-color: #795548 !important +} + +.w3-cyan, .w3-hover-cyan:hover { + color: #000 !important; + background-color: #00bcd4 !important +} + +.w3-blue-grey, .w3-hover-blue-grey:hover, .w3-blue-gray, .w3-hover-blue-gray:hover { + color: #fff !important; + background-color: #607d8b !important +} + +.w3-green, .w3-hover-green:hover { + color: #fff !important; + background-color: #4CAF50 !important +} + +.w3-light-green, .w3-hover-light-green:hover { + color: #000 !important; + background-color: #8bc34a !important +} + +.w3-indigo, .w3-hover-indigo:hover { + color: #fff !important; + background-color: #3f51b5 !important +} + +.w3-khaki, .w3-hover-khaki:hover { + color: #000 !important; + background-color: #f0e68c !important +} + +.w3-lime, .w3-hover-lime:hover { + color: #000 !important; + background-color: #cddc39 !important +} + +.w3-orange, .w3-hover-orange:hover { + color: #000 !important; + background-color: #ff9800 !important +} + +.w3-deep-orange, .w3-hover-deep-orange:hover { + color: #fff !important; + background-color: #ff5722 !important +} + +.w3-pink, .w3-hover-pink:hover { + color: #fff !important; + background-color: #e91e63 !important +} + +.w3-purple, .w3-hover-purple:hover { + color: #fff !important; + background-color: #9c27b0 !important +} + +.w3-deep-purple, .w3-hover-deep-purple:hover { + color: #fff !important; + background-color: #673ab7 !important +} + +.w3-red, .w3-hover-red:hover { + color: #fff !important; + background-color: #f44336 !important +} + +.w3-sand, .w3-hover-sand:hover { + color: #000 !important; + background-color: #fdf5e6 !important +} + +.w3-teal, .w3-hover-teal:hover { + color: #fff !important; + background-color: #009688 !important +} + +.w3-yellow, .w3-hover-yellow:hover { + color: #000 !important; + background-color: #ffeb3b !important +} + +.w3-white, .w3-hover-white:hover { + color: #000 !important; + background-color: #fff !important +} + +.w3-black, .w3-hover-black:hover { + color: #fff !important; + background-color: #000 !important +} + +.w3-grey, .w3-hover-grey:hover, .w3-gray, .w3-hover-gray:hover { + color: #000 !important; + background-color: #bbb !important +} + +.w3-light-grey, .w3-hover-light-grey:hover, .w3-light-gray, .w3-hover-light-gray:hover { + color: #000 !important; + background-color: #f1f1f1 !important +} + +.w3-dark-grey, .w3-hover-dark-grey:hover, .w3-dark-gray, .w3-hover-dark-gray:hover { + color: #fff !important; + background-color: #616161 !important +} + +.w3-pale-red, .w3-hover-pale-red:hover { + color: #000 !important; + background-color: #ffdddd !important +} + +.w3-pale-green, .w3-hover-pale-green:hover { + color: #000 !important; + background-color: #ddffdd !important +} + +.w3-pale-yellow, .w3-hover-pale-yellow:hover { + color: #000 !important; + background-color: #ffffcc !important +} + +.w3-pale-blue, .w3-hover-pale-blue:hover { + color: #000 !important; + background-color: #ddffff !important +} + +.w3-text-red, .w3-hover-text-red:hover { + color: #f44336 !important +} + +.w3-text-green, .w3-hover-text-green:hover { + color: #4CAF50 !important +} + +.w3-text-blue, .w3-hover-text-blue:hover { + color: #2196F3 !important +} + +.w3-text-yellow, .w3-hover-text-yellow:hover { + color: #ffeb3b !important +} + +.w3-text-white, .w3-hover-text-white:hover { + color: #fff !important +} + +.w3-text-black, .w3-hover-text-black:hover { + color: #000 !important +} + +.w3-text-grey, .w3-hover-text-grey:hover, .w3-text-gray, .w3-hover-text-gray:hover { + color: #757575 !important +} + +.w3-text-amber { + color: #ffc107 !important +} + +.w3-text-aqua { + color: #00ffff !important +} + +.w3-text-light-blue { + color: #87CEEB !important +} + +.w3-text-brown { + color: #795548 !important +} + +.w3-text-cyan { + color: #00bcd4 !important +} + +.w3-text-blue-grey, .w3-text-blue-gray { + color: #607d8b !important +} + +.w3-text-light-green { + color: #8bc34a !important +} + +.w3-text-indigo { + color: #3f51b5 !important +} + +.w3-text-khaki { + color: #b4aa50 !important +} + +.w3-text-lime { + color: #cddc39 !important +} + +.w3-text-orange { + color: #ff9800 !important +} + +.w3-text-deep-orange { + color: #ff5722 !important +} + +.w3-text-pink { + color: #e91e63 !important +} + +.w3-text-purple { + color: #9c27b0 !important +} + +.w3-text-deep-purple { + color: #673ab7 !important +} + +.w3-text-sand { + color: #fdf5e6 !important +} + +.w3-text-teal { + color: #009688 !important +} + +.w3-text-light-grey, .w3-hover-text-light-grey:hover, .w3-text-light-gray, .w3-hover-text-light-gray:hover { + color: #f1f1f1 !important +} + +.w3-text-dark-grey, .w3-hover-text-dark-grey:hover, .w3-text-dark-gray, .w3-hover-text-dark-gray:hover { + color: #3a3a3a !important +} + +.w3-border-red, .w3-hover-border-red:hover { + border-color: #f44336 !important +} + +.w3-border-green, .w3-hover-border-green:hover { + border-color: #4CAF50 !important +} + +.w3-border-blue, .w3-hover-border-blue:hover { + border-color: #2196F3 !important +} + +.w3-border-yellow, .w3-hover-border-yellow:hover { + border-color: #ffeb3b !important +} + +.w3-border-white, .w3-hover-border-white:hover { + border-color: #fff !important +} + +.w3-border-black, .w3-hover-border-black:hover { + border-color: #000 !important +} + +.w3-border-grey, .w3-hover-border-grey:hover, .w3-border-gray, .w3-hover-border-gray:hover { + border-color: #bbb !important +} diff --git a/Client/Speedometer/cef/js/gauge.js b/Client/Speedometer/cef/js/gauge.js new file mode 100644 index 00000000..8d726406 --- /dev/null +++ b/Client/Speedometer/cef/js/gauge.js @@ -0,0 +1,3 @@ +!function(e){"use strict";function t(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t1&&(d=1),1!==d&&(c=r(d),isFinite(c)&&!isNaN(c)&&(d=c)),t&&t(d),s0){for(a=e.toFixed(i).toString().split("."),n=r-a[0].length;o1?(r=~i.indexOf("."),~i.indexOf("-")?"-"+[t.majorTicksInt+t.majorTicksDec+2+(r?1:0)-i.length].join("0")+i.replace("-",""):[t.majorTicksInt+t.majorTicksDec+1+(r?1:0)-i.length].join("0")+i):i}function f(e){return e*Math.PI/180}function m(e,t){return{x:-e*Math.sin(t),y:e*Math.cos(t)}}function v(e,t,i,r){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,a=e.createLinearGradient(o?0:n,o?n:0,o?0:r,o?r:0);return a.addColorStop(0,t),a.addColorStop(1,i),a}function b(e,t){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2])return e.restore(),!0;e.save();var i=t.borderShadowWidth;return i&&(e.shadowBlur=i,e.shadowColor=t.colorBorderShadow),!0}function g(e,t){t.needleShadow&&(e.shadowOffsetX=2,e.shadowOffsetY=2,e.shadowBlur=10,e.shadowColor=t.colorNeedleShadowDown)}function p(e,t,i){return e["font"+t+"Style"]+" "+e["font"+t+"Weight"]+" "+e["font"+t+"Size"]*i+"px "+e["font"+t]}function w(e){e.shadowOffsetX=null,e.shadowOffsetY=null,e.shadowBlur=null,e.shadowColor="",e.strokeStyle=null,e.lineWidth=0,e.save()}function k(e,t,i,r){t.valueTextShadow&&(e.shadowOffsetX=i,e.shadowOffsetY=i,e.shadowBlur=r,e.shadowColor=t.colorValueTextShadow)}function y(e,t,i,r,o,n){if(t.valueBox){w(e);var a=t.valueDec?1+t.valueDec:0,l="9".repeat(Math.max.apply(null,[String(parseInt(i)).length+a].concat(t.majorTicks.map(function(e){return String(parseInt(e,10)).length+a})))),s=t.valueText||h(i,t),d=n/200,u=n/100,f=.4*u,m=1.2*u;e.font=p(t,"Value",d),k(e,t,f,m);var v=e.measureText(t.valueText?s:"-"+h(Number(l),t)).width;w(e);var b=parseFloat(t.fontValueSize)*d+f+m,g=u*parseFloat(t.valueBoxStroke),y=2*n-2*g,x=v+10*u,T=1.1*b+f+m,S=u*t.valueBoxBorderRadius,W=(parseFloat(t.valueBoxWidth)||0)/100*y;W>x&&(x=W),x>y&&(x=y);var O=r-x/2,V=o-T/2,P=o-5.75*u;if(e.beginPath(),S?c(e,O,V,x,T,S):e.rect(O,V,x,T),g){var M=e.createRadialGradient(r,P,10*u,r,P,20*u);M.addColorStop(0,t.colorValueBoxRect),M.addColorStop(1,t.colorValueBoxRectEnd),e.strokeStyle=M,e.lineWidth=g,e.stroke()}t.colorValueBoxShadow&&(e.shadowBlur=1.2*u,e.shadowColor=t.colorValueBoxShadow),t.colorValueBoxBackground&&(e.fillStyle=t.colorValueBoxBackground,e.fill()),e.closePath(),e.restore(),k(e,t,f,m),e.fillStyle=t.colorValueText,e.textAlign="center",e.textBaseline="alphabetic",e.fillText(s,O+x/2,o+T/2-b/3),e.restore()}}function x(e){var t=e.value,i=e.minValue,r=e.maxValue,o=.01*(r-i);return{normal:tr?r:t,indented:tr?r+o:t}}function T(e,t,i,r,o){i.beginPath(),i.arc(0,0,ke(e),0,2*Se,!0),i.lineWidth=t,i.strokeStyle=o?Te.linearGradient(i,r,o,e):r,i.stroke(),i.closePath()}function S(e,t){var i=be.pixelRatio;return e.maxRadius||(e.maxRadius=e.max-t.borderShadowWidth-t.borderOuterWidth*i-t.borderMiddleWidth*i-t.borderInnerWidth*i+(t.borderOuterWidth?.5:0)+(t.borderMiddleWidth?.5:0)+(t.borderInnerWidth?.5:0)),e.maxRadius}function W(e,t){var i=be.pixelRatio,r=t.borderShadowWidth*i,o=e.max-r-t.borderOuterWidth*i/2,n=o-t.borderOuterWidth*i/2-t.borderMiddleWidth*i/2+.5,a=n-t.borderMiddleWidth*i/2-t.borderInnerWidth*i/2+.5,l=S(e,t),s=void 0,d=!1;e.save(),t.borderOuterWidth&&(d=Te.drawShadow(e,t,d),T(o,t.borderOuterWidth*i,e,t.colorBorderOuter,t.colorBorderOuterEnd)),t.borderMiddleWidth&&(d=Te.drawShadow(e,t,d),T(n,t.borderMiddleWidth*i,e,t.colorBorderMiddle,t.colorBorderMiddleEnd)),t.borderInnerWidth&&(d=Te.drawShadow(e,t,d),T(a,t.borderInnerWidth*i,e,t.colorBorderInner,t.colorBorderInnerEnd)),Te.drawShadow(e,t,d),e.beginPath(),e.arc(0,0,ke(l),0,2*Se,!0),t.colorPlateEnd?(s=e.createRadialGradient(0,0,l/2,0,0,l),s.addColorStop(0,t.colorPlate),s.addColorStop(1,t.colorPlateEnd)):s=t.colorPlate,e.fillStyle=s,e.fill(),e.closePath(),e.restore()}function O(e,t){var i=e.max*(parseFloat(t.highlightsWidth)||0)/100;if(i){var r=ke(P(e,t)-i/2),o=0,n=t.highlights.length,a=(t.maxValue-t.minValue)/t.ticksAngle;for(e.save();on?o:n,n>o,o>n?i:r):a,t>0?Te.roundRect(e,i,r,o,n,t):e.rect(i,r,o,n),e.fill(),e.closePath()}function z(e,t,i,r,o,n,a,l,s){e.beginPath(),e.lineWidth=t,e.strokeStyle=s?Te.linearGradient(e,l,s,a,!0,o):l,i>0?Te.roundRect(e,r,o,n,a,i):e.rect(r,o,n,a),e.stroke(),e.closePath()}function L(e,t,i,r,o,n){var a=be.pixelRatio;e.save();var l=t.borderRadius*a,s=o-t.borderShadowWidth-t.borderOuterWidth*a,d=s-t.borderOuterWidth*a-t.borderMiddleWidth*a,c=d-t.borderMiddleWidth*a-t.borderInnerWidth*a,h=c-t.borderInnerWidth*a,u=n-t.borderShadowWidth-t.borderOuterWidth*a,f=u-t.borderOuterWidth*a-t.borderMiddleWidth*a,m=f-t.borderMiddleWidth*a-t.borderInnerWidth*a,v=m-t.borderInnerWidth*a,b=i-(d-s)/2,g=b-(c-d)/2,p=g-(h-c)/2,w=r-(f-u)/2,k=w-(m-f)/2,y=k-(v-m)/2,x=0,T=!1;return t.borderOuterWidth&&(T=Te.drawShadow(e,t,T),z(e,t.borderOuterWidth*a,l,i+t.borderOuterWidth*a/2-x,r+t.borderOuterWidth*a/2-x,s,u,t.colorBorderOuter,t.colorBorderOuterEnd),x+=.5*a),t.borderMiddleWidth&&(T=Te.drawShadow(e,t,T),z(e,t.borderMiddleWidth*a,l-=1+2*x,b+t.borderMiddleWidth*a/2-x,w+t.borderMiddleWidth*a/2-x,d+2*x,f+2*x,t.colorBorderMiddle,t.colorBorderMiddleEnd),x+=.5*a),t.borderInnerWidth&&(T=Te.drawShadow(e,t,T),z(e,t.borderInnerWidth*a,l-=1+2*x,g+t.borderInnerWidth*a/2-x,k+t.borderInnerWidth*a/2-x,c+2*x,m+2*x,t.colorBorderInner,t.colorBorderInnerEnd),x+=.5*a),Te.drawShadow(e,t,T),D(e,l,p,y,h+2*x,v+2*x,t.colorPlate,t.colorPlateEnd),e.restore(),[p,y,h,v]}function G(e,t,i,r,o,n){var a=be.pixelRatio,l=n>=o,s=l?.85*o:n,d=l?n:o;i=l?we(i+(o-s)/2):i;var c=!!t.title,h=!!t.units,u=!!t.valueBox,f=void 0,m=void 0,v=void 0;l?(m=we(.05*d),f=we(.075*d),v=we(.11*d),c&&(d-=f,r+=f),h&&(d-=m),u&&(d-=v)):(m=f=we(.15*s),c&&(s-=f,r+=f),h&&(s-=m));var b=2*t.barStrokeWidth,g=t.barBeginCircle?we(s*t.barBeginCircle/200-b/2):0,p=we(s*t.barWidth/100-b),w=we(d*t.barLength/100-b),k=we((d-w)/2),y=we(i+(l?s/2:k+g)),x=we(r+(l?d-k-g+b/2:s/2)),T=!l||t.hasLeft&&t.hasRight?0:(t.hasRight?-1:1)*t.ticksWidth/100*s,S=l||t.hasLeft&&t.hasRight?0:(t.hasRight?-1:1)*t.ticksWidth/100*s;return e.barDimensions={isVertical:l,width:s,length:d,barWidth:p,barLength:w,strokeWidth:b,barMargin:k,radius:g,pixelRatio:a,barOffset:null,titleMargin:c?f:0,unitsMargin:h?m:0,get ticksLength(){return this.barLength-this.barOffset-this.strokeWidth},X:i+T,Y:r+S,x0:y+T,y0:x+S,baseX:i,baseY:r,ticksPadding:t.ticksPadding/100},e.barDimensions}function F(e,t,i,r,o,n,a){var l=G(e,t,r,o,n,a),s=l.isVertical,d=l.width,c=l.barWidth,h=l.barLength,u=l.strokeWidth,f=l.barMargin,m=l.radius,v=l.x0,b=l.y0,g=l.X,p=l.Y,w=h;if(e.save(),e.beginPath(),t.barBeginCircle){var k=Te.radians(s?270:0),y=Math.asin(c/2/m),x=Math.cos(y),T=Math.sin(y),S=v+(s?m*T:m*x-u/2),W=s?b-m*x:b+m*T,O=ke(s?W-b:S-v);e.barDimensions.barOffset=we(O+m);var V=s?we(v-m*T):S,P=s?W:we(b-m*T);"progress"===i&&(h=e.barDimensions.barOffset+(h-e.barDimensions.barOffset)*(Te.normalizedValue(t).normal-t.minValue)/(t.maxValue-t.minValue));var M=we(S+h-e.barDimensions.barOffset+u/2),B=we(W-h+e.barDimensions.barOffset-u/2);e.arc(v,b,m,k+y,k-y),s?(e.moveTo(S,P),e.lineTo(S,B),e.lineTo(V,B),e.lineTo(V,P)):(e.moveTo(S,P),e.lineTo(M,P),e.lineTo(M,W),e.lineTo(S,W))}else{var A=we(s?g+(d-c)/2:g+f),j=we(s?p+h+f:p+(d-c)/2);"progress"===i&&(h*=(t.value-t.minValue)/(t.maxValue-t.minValue)),s?e.rect(A,j,c,-h):e.rect(A,j,h,c)}"progress"!==i&&t.barStrokeWidth&&(e.lineWidth=u,e.strokeStyle=t.colorBarStroke,e.stroke()),"progress"!==i&&t.colorBar?(e.fillStyle=t.colorBarEnd?Te.linearGradient(e,t.colorBar,t.colorBarEnd,h,s,s?p:g):t.colorBar,e.fill()):"progress"===i&&t.colorBarProgress&&(e.fillStyle=t.colorBarProgressEnd?Te.linearGradient(e,t.colorBarProgress,t.colorBarProgressEnd,w,s,s?p:g):t.colorBarProgress,e.fill()),e.closePath(),t.barBeginCircle&&(e.barDimensions.radius+=u),e.barDimensions.barWidth+=u,e.barDimensions.barLength+=u}function X(e,t,i,r,o,n){F(e,t,"",i,r,o,n)}function Y(e,t){return t.needleSide!==e||t.tickSide!==e||t.numberSide!==e}function U(e,t,i,r,o,n){t.barProgress&&F(e,t,"progress",i,r,o,n)}function q(e,t){var i=e.barDimensions,r=i.isVertical,o=i.width,n=i.length,a=i.barWidth,l=i.barOffset,s=i.barMargin,d=i.X,c=i.Y,h=i.ticksLength,u=i.ticksPadding,f=o*(parseFloat(t.highlightsWidth)||0)/100;if(t.highlights&&f){var m="right"!==t.tickSide,v="left"!==t.tickSide,b=0,g=t.highlights.length,p=(o-a)/2,w=t.maxValue-t.minValue,k=we(r?d+p:d+s+l),y=f,x=r?c+n-s-l:c+p,T=we((t.ticksWidth/100+u)*o)+(f-t.ticksWidth/100*o),S=we(a+u*o);for(e.save();bn&&(d*=-1),e.moveTo(i-h,r),e.lineTo(i+h,r),e.lineTo(i+h,r+d),e.lineTo(i,n),e.lineTo(i-h,r+d),e.lineTo(i-h,r)):(i>o&&(d*=-1),e.moveTo(i,r-h),e.lineTo(i,r+h),e.lineTo(i+d,r+h),e.lineTo(o,r),e.lineTo(i+d,r-h),e.lineTo(i,r-h)),e.fill(),e.closePath()}function ae(e,t,i,r,o,n,a){var l=(parseFloat(t.fontValueSize)||0)*n/200,s=(.11*a-l)/2;e.barDimensions.isVertical&&Te.drawValueBox(e,t,i,r+n/2,o+a-l-s,n)}var le=function(){function e(e,t){var i=[],r=!0,o=!1,n=void 0;try{for(var a,l=e[Symbol.iterator]();!(r=(a=l.next()).done)&&(i.push(a.value),!t||i.length!==t);r=!0);}catch(e){o=!0,n=e}finally{try{!r&&l.return&&l.return()}finally{if(o)throw n}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),se=function e(t,i,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,i);if(void 0===o){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,i,r)}if("value"in o)return o.value;var a=o.get;if(void 0!==a)return a.call(r)},de=function e(t,i,r,o){var n=Object.getOwnPropertyDescriptor(t,i);if(void 0===n){var a=Object.getPrototypeOf(t);null!==a&&e(a,i,r,o)}else if("value"in n&&n.writable)n.value=r;else{var l=n.set;void 0!==l&&l.call(o,r)}return r},ce=function(){function e(e,t){for(var i=0;i>>0;if(0===o)return-1;var n=+t||0;if(Math.abs(n)===1/0&&(n=0),n>=o)return-1;for(i=Math.max(n>=0?n:o-Math.abs(n),0);i>>0,r=arguments[1],o=r>>0,n=o<0?Math.max(i+o,0):Math.min(o,i),a=arguments[2],l=void 0===a?i:a>>0,s=l<0?Math.max(i+l,0):Math.min(l,i);n1?r-1:0),n=1;n1?t-1:0),r=1;r=(7-4*t)/11)return-Math.pow((11-6*t-11*e)/4,2)+Math.pow(i,2)},elastic:function(e){return 1-fe.delastic(1-e)},delastic:function(e){return Math.pow(2,10*(e-1))*Math.cos(20*Math.PI*1.5/3*e)}},me=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"linear",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};if(o(this,e),this.duration=i,this.rule=t,this.draw=r,this.end=n,"function"!=typeof this.draw)throw new TypeError("Invalid animation draw callback:",r);if("function"!=typeof this.end)throw new TypeError("Invalid animation end callback:",n)}return ce(e,[{key:"animate",value:function(e,t){var i=this;this.frame&&this.cancel();var r=window.performance&&window.performance.now?window.performance.now():n("animationStartTime")||Date.now();e=e||this.draw,t=t||this.end,this.draw=e,this.end=t,this.frame=ue(function(o){return a(o,e,r,fe[i.rule]||i.rule,i.duration,t,i)})}},{key:"cancel",value:function(){if(this.frame){(n("cancelAnimationFrame")||function(e){})(this.frame),this.frame=null}}},{key:"destroy",value:function(){this.cancel(),this.draw=null,this.end=null}}]),e}();me.rules=fe;var ve=function(){function t(i,r,n){o(this,t),this.options=i,this.element=r.toLowerCase(),this.type=t.toDashed(n),this.Type=e[n],this.mutationsObserved=!1,this.isObservable=!!window.MutationObserver,window.GAUGES_NO_AUTO_INIT||t.domReady(this.traverse.bind(this))}return ce(t,[{key:"isValidNode",value:function(e){return!(!e.tagName||e.tagName.toLowerCase()!==this.element||e.getAttribute("data-type")!==this.type)}},{key:"traverse",value:function(){for(var e=document.getElementsByTagName(this.element),t=0,i=e.length;t1&&void 0!==arguments[1])||arguments[1],i=e.split(/-/),r=0,o=i.length,n="";r1&&void 0!==arguments[1]?arguments[1]:0;return e=parseFloat(e),!isNaN(e)&&isFinite(e)||(e=parseFloat(t)||0),e}},{key:"version",get:function(){return pe}}]),n}(he);void 0!==e&&(e.BaseGauge=xe,e.gauges=(window.document||{}).gauges=ye);var Te={roundRect:c,padValue:h,formatMajorTickNumber:u,radians:f,radialPoint:m,linearGradient:v,drawNeedleShadow:g,drawValueBox:y,verifyError:s,prepareTicks:d,drawShadow:b,font:p,normalizedValue:x},Se=Math.PI,We=Se/2,Oe=Object.assign({},ge,{ticksAngle:270,startAngle:45,colorNeedleCircleOuter:"#f0f0f0",colorNeedleCircleOuterEnd:"#ccc",colorNeedleCircleInner:"#e8e8e8",colorNeedleCircleInnerEnd:"#f5f5f5",needleCircleSize:10,needleCircleInner:!0,needleCircleOuter:!0,needleStart:20,animationTarget:"needle",useMinPath:!1,barWidth:0}),Ve=function(e){function t(e){return o(this,t),e=Object.assign({},Oe,e||{}),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,t.configure(e)))}return r(t,e),ce(t,[{key:"draw",value:function(){try{var e=this.canvas,i=[-e.drawX,-e.drawY,e.drawWidth,e.drawHeight],r=i[0],o=i[1],n=i[2],a=i[3],l=this.options;if("needle"===l.animationTarget){if(!e.elementClone.initialized){var s=e.contextClone;s.clearRect(r,o,n,a),s.save(),this.emit("beforePlate"),W(s,l),this.emit("beforeHighlights"),O(s,l),this.emit("beforeMinorTicks"),V(s,l),this.emit("beforeMajorTicks"),M(s,l),this.emit("beforeNumbers"),j(s,l),this.emit("beforeTitle"),C(s,l),this.emit("beforeUnits"),N(s,l),e.elementClone.initialized=!0}this.canvas.commit(),e.context.clearRect(r,o,n,a),e.context.save(),e.context.drawImage(e.elementClone,r,o,n,a),e.context.save(),this.emit("beforeProgressBar"),R(e.context,l),this.emit("beforeValueBox"),_(e.context,l,I(this)),this.emit("beforeNeedle"),E(e.context,l)}else{var d=-Te.radians((l.value-l.minValue)/(l.maxValue-l.minValue)*l.ticksAngle);if(e.context.clearRect(r,o,n,a),e.context.save(),this.emit("beforePlate"),W(e.context,l),e.context.rotate(d),this.emit("beforeHighlights"),O(e.context,l),this.emit("beforeMinorTicks"),V(e.context,l),this.emit("beforeMajorTicks"),M(e.context,l),this.emit("beforeNumbers"),j(e.context,l),this.emit("beforeProgressBar"),R(e.context,l),e.context.rotate(-d),e.context.save(),!e.elementClone.initialized){var c=e.contextClone;c.clearRect(r,o,n,a),c.save(),this.emit("beforeTitle"),C(c,l),this.emit("beforeUnits"),N(c,l),this.emit("beforeNeedle"),E(c,l),e.elementClone.initialized=!0}e.context.drawImage(e.elementClone,r,o,n,a)}this.emit("beforeValueBox"),_(e.context,l,I(this)),se(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"draw",this).call(this)}catch(e){Te.verifyError(e)}return this}},{key:"value",set:function(e){e=xe.ensureValue(e,this.options.minValue),this.options.animation&&360===this.options.ticksAngle&&this.options.useMinPath&&(this._value=e,e=this.options.value+((e-this.options.value)%360+540)%360-180),de(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"value",e,this)},get:function(){return se(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"value",this)}}],[{key:"configure",value:function(e){return e.barWidth>50&&(e.barWidth=50),isNaN(e.startAngle)&&(e.startAngle=45),isNaN(e.ticksAngle)&&(e.ticksAngle=270),e.ticksAngle>360&&(e.ticksAngle=360),e.ticksAngle<0&&(e.ticksAngle=0),e.startAngle<0&&(e.startAngle=0),e.startAngle>360&&(e.startAngle=360),e}}]),t}(xe);void 0!==e&&(e.RadialGauge=Ve),xe.initialize("RadialGauge",Oe);var Pe=Object.assign({},ge,{borderRadius:0,barBeginCircle:30,colorBarEnd:"",colorBarProgressEnd:"",needleWidth:6,tickSide:"both",needleSide:"both",numberSide:"both",ticksWidth:10,ticksWidthMinor:5,ticksPadding:5,barLength:85,fontTitleSize:26,highlightsWidth:10}),Me=function(e){function n(e){return o(this,n),e=Object.assign({},Pe,e||{}),i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,n.configure(e)))}return r(n,e),ce(n,[{key:"draw",value:function(){try{var e=this.canvas,i=[-e.drawX,-e.drawY,e.drawWidth,e.drawHeight],r=i[0],o=i[1],a=i[2],l=i[3],s=this.options;if(!e.elementClone.initialized){var d=e.contextClone;d.clearRect(r,o,a,l),d.save(),this.emit("beforePlate"),this.drawBox=L(d,s,r,o,a,l),this.emit("beforeBar"),X.apply(void 0,[d,s].concat(t(this.drawBox))),e.context.barDimensions=d.barDimensions,this.emit("beforeHighlights"),q(d,s),this.emit("beforeMinorTicks"),K(d,s),this.emit("beforeMajorTicks"),$(d,s),this.emit("beforeNumbers"),Q(d,s),this.emit("beforeTitle"),ee(d,s),this.emit("beforeUnits"),te(d,s),e.elementClone.initialized=!0}this.canvas.commit(),e.context.clearRect(r,o,a,l),e.context.save(),e.context.drawImage(e.elementClone,r,o,a,l),e.context.save(),this.emit("beforeProgressBar"),U.apply(void 0,[e.context,s].concat(t(this.drawBox))),this.emit("beforeNeedle"),ie(e.context,s),this.emit("beforeValueBox"),ae.apply(void 0,[e.context,s,s.animatedValue?this.options.value:this.value].concat(t(this.drawBox))),se(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"draw",this).call(this)}catch(e){Te.verifyError(e)}return this}}],[{key:"configure",value:function(e){return e.barStrokeWidth>=e.barWidth&&(e.barStrokeWidth=we(e.barWidth/2)),e.hasLeft=Y("right",e),e.hasRight=Y("left",e),e.value>e.maxValue&&(e.value=e.maxValue),e.value + + + + + + + + +
+
+
+ +
+
+ +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/Client/Speedometer/index.js b/Client/Speedometer/index.js new file mode 100644 index 00000000..3527a91e --- /dev/null +++ b/Client/Speedometer/index.js @@ -0,0 +1,30 @@ +let speedo = mp.browsers.new("package://speedometer/CEF/speedometer.html"); +let showed = false; +let player = mp.players.local; + +mp.events.add('render', () => +{ + if (player.vehicle && player.vehicle.getPedInSeat(-1) === player.handle && !globalData.InTuning && !globalData.HideGui) // Check if player is in vehicle and is driver + { + if(showed === false) // Check if speedo is already showed + { + speedo.execute("showSpeedo();"); + showed = true; + } + /*Get vehicle infos*/ + let vel = player.vehicle.getSpeed() * 3.6; //Doc: https://wiki.rage.mp/index.php?title=Entity::getSpeed + let rpm = player.vehicle.rpm * 1000; //Doc: https://wiki.rage.mp/index.php?title=Vehicle::rpm + let gas = player.vehicle.getPetrolTankHealth(); //Doc: https://wiki.rage.mp/index.php?title=Vehicle::getPetrolTankHealth + gas = gas < 0 ? 0: gas / 10; + + speedo.execute(`update(${vel}, ${rpm}, ${gas});`); // Send data do CEF + } + else + { + if(showed) + { + speedo.execute("hideSpeedo();"); + showed = false; + } + } +}); \ No newline at end of file diff --git a/Client/Tuning/main.js b/Client/Tuning/main.js index d73c9532..23c80d3b 100644 --- a/Client/Tuning/main.js +++ b/Client/Tuning/main.js @@ -6,7 +6,7 @@ var keyBound = false; -var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 23]; +var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 25, 27, 28, 30, 33, 34, 35, 38, 46, 48]; var carModSlotName = [ { Slot: 0, Name: "Spoiler" }, // 0 @@ -39,6 +39,33 @@ var customPartNames = [ Name: "Lüftungsschlitze" } ] + }, + { + Model: 159274291, + Names: [ + { + Slot: 8, + Name: "Kotflügel" + } + ] + }, + { + Model: 223240013, + Names: [ + { + Slot: 9, + Name: "Heckkotflügel" + } + ] + }, + { + Model: 1031562256, + Names: [ + { + Slot: 5, + Name: "Stoßdämpfer" + } + ] } ]; @@ -56,13 +83,13 @@ const ItemsCollection = NativeUI.ItemsCollection; const Color = NativeUI.Color; const ListItem = NativeUI.ListItem; +var mainMenu; + mp.events.add('showTuningInfo', () => { mp.game.ui.setTextComponentFormat('STRING'); mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Fahrzeug zu modifizieren'); mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1); - mp.gui.chat.push("Model: " + mp.players.local.vehicle.model); - mp.keys.bind(0x45, false, keyPressHandler); keyBound = true; }); @@ -71,6 +98,11 @@ mp.events.add('hideTuningInfo', (unbind) => { mp.game.ui.clearHelp(true); mp.gui.chat.show(true); + if (typeof mainMenu !== "undefined" && unbind) { + mainMenu.Visible = false; + globalData.InTuning = false; + } + if (keyBound && unbind) { mp.keys.unbind(0x45, false, keyPressHandler); keyBound = false; @@ -88,7 +120,13 @@ mp.events.add("showTuningMenu", () => { var localPlayer = mp.players.local; var localVehicle = localPlayer.vehicle; - var mainMenu = new Menu("Fahrzeugwerkstatt", "Modifiziere dein Fahrzeug", new Point(50, 50)); + if (typeof mainMenu !== "undefined" && mainMenu.Visible) { + return; + } + + globalData.InTuning = true; + + mainMenu = new Menu("Fahrzeugwerkstatt", "Modifiziere dein Fahrzeug", new Point(50, 50)); carModTypes.forEach((modType) => { if (localVehicle.getModSlotName(modType) !== "undefined") { @@ -99,6 +137,8 @@ mp.events.add("showTuningMenu", () => { if (slotName === undefined) slotName = getSlotName(modType); } + if (slotName === "undefined") slotName = "Slot " + modType; + var menuItem = new UIMenuItem(slotName); if(localVehicle.getNumMods(modType) !== 0) mainMenu.AddItem(menuItem); @@ -107,25 +147,60 @@ mp.events.add("showTuningMenu", () => { mainMenu.Visible = true; - mainMenu.ItemSelect.on(item => { + mainMenu.ItemSelect.on((item) => { var modSlot = getSlotId(item.Text); + var currentMod = localVehicle.getMod(modSlot); + var currentModItem; + + if (item.Text.startsWith("Slot")) { + restStr = item.Text.substring(5); + modSlot = parseInt(restStr); + } var modNum = localVehicle.getNumMods(modSlot); var modMenu = new Menu(item.Text, "Änderung: " + item.Text, new Point(50, 50)); - modMenu.AddItem(new UIMenuItem("Serie", "")); + for (var i = -1; i < modNum; i++) { + var modItem; - for (var i = 0; i < modNum; i++) { - var modName = localVehicle.getModTextLabel(modSlot, i); - var realModName = mp.game.ui.getLabelText(modName); - var modItem = new UIMenuItem(realModName, ""); + if (i === -1) { + modItem = new UIMenuItem("Serie", ""); + } else { + var modName = localVehicle.getModTextLabel(modSlot, i); + var realModName = mp.game.ui.getLabelText(modName); + modItem = new UIMenuItem(realModName, ""); + } + + if (i === currentMod) { + modItem.SetRightBadge(BadgeStyle.Car); + currentModItem = modItem; + modFound = true; + } modMenu.AddItem(modItem); } - modMenu.IndexChange.on(index => { + modMenu.ItemSelect.on((selectedItem, index) => { + if (currentModItem !== undefined) { + currentModItem.SetRightBadge(BadgeStyle.None); + } + if (selectedItem !== undefined) { + selectedItem.SetRightBadge(BadgeStyle.Car); + currentModItem = selectedItem; + } mp.events.callRemote("setVehicleMod", modSlot, index); + if (index === 0) index = -1; + currentMod = index - 1; + }); + + modMenu.IndexChange.on((index) => { + if (index === 0) index = -1; + localVehicle.setMod(modSlot, index - 1); + }); + + modMenu.MenuClose.on(() => { + localVehicle.setMod(modSlot, currentMod); }); modMenu.MenuClose.on(() => { @@ -138,11 +213,16 @@ mp.events.add("showTuningMenu", () => { }); mainMenu.MenuClose.on(() => { + globalData.InTuning = false; mp.events.call("hideTuningInfo", false); }); }); +mp.events.add("playerLeaveVehicle", () => { + mp.events.call("hideTuningInfo", true); +}); + function getSlotName(slot) { var toReturn = "undefined"; diff --git a/Client/index.js b/Client/index.js index 763019fb..da6ceb4e 100644 --- a/Client/index.js +++ b/Client/index.js @@ -4,20 +4,30 @@ * @copyright (c) 2008 - 2018 Life of German */ +let globalData = { + InTuning: false, + HideGui: false +}; require('./CharCreator/index.js'); -require('./Login/main.js'); +require('./FactionManagement/main.js'); -require('./Save/main.js'); +require('./DoorManager/doormanager.js'); require('./Gui/deathscreen.js'); require('./Gui/infobox.js'); +require('./Gui/nametags.js'); require('./Gui/playerlist.js'); require('./Gui/Inventory/inventory.js'); +require('./Login/main.js'); + +require('./Player/dutycloth.js'); require('./Player/keys.js'); -require('./FactionManagement/main.js'); +require('./Save/main.js'); -require('./Tuning/main.js'); \ No newline at end of file +require('./Speedometer/index.js'); + +require('./Tuning/main.js'); diff --git a/Main.cs b/Main.cs index c43059fe..f7dc1444 100644 --- a/Main.cs +++ b/Main.cs @@ -5,6 +5,8 @@ using Microsoft.EntityFrameworkCore; using reallife_gamemode.Model; using reallife_gamemode.Server.Entities; using reallife_gamemode.Server.Managers; +using reallife_gamemode.Server.Saves; +using reallife_gamemode.Server.Util; /** * @overview Life of German Reallife - Main Class (Main.cs) @@ -22,6 +24,8 @@ namespace reallife_gamemode [ServerEvent(Event.ResourceStart)] public void OnResourceStart() { + NAPI.Server.SetGlobalServerChat(false); + NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht."); NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); NAPI.Server.SetAutoSpawnOnConnect(false); @@ -29,17 +33,22 @@ namespace reallife_gamemode NAPI.Data.SetWorldData("playerCreatorDimension", 0); InventoryManager.LoadItems(); + TuningManager.AddTuningGarage(new Vector3(-341, -134, 38.5)); + DatabaseHelper.InitDatabaseFirstTime(); + FactionHelper.CheckFactionBankAccounts(); - TuningManager.AddTuningGarage(new Vector3(-341, -134, 38.5), new Vector3(-334, -143, 41)); - using (var context = new DatabaseContext()) + TempBlip tempBlip = new TempBlip() { - context.Bans.FirstOrDefault(); + Color = 1, + Name = "", + Transparency = 0, + ShortRange = true, + Sprite = 1, + Scale = 1, + }; - context.Factions.FirstOrDefault(); - context.Users.FirstOrDefault(); - context.SaveChanges(); - } + NAPI.Data.SetWorldData("blipTemplate", tempBlip); } - } + } } \ No newline at end of file diff --git a/Model/DatabaseContext.cs b/Model/DatabaseContext.cs index 9385feec..af473c6a 100644 --- a/Model/DatabaseContext.cs +++ b/Model/DatabaseContext.cs @@ -1,10 +1,4 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Configuration; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.Extensions.Configuration; +using Microsoft.EntityFrameworkCore; /** * @overview Life of German Reallife - DatabaseContext.cs @@ -37,11 +31,15 @@ namespace reallife_gamemode.Model } //User + public DbSet Bans { get; set; } + public DbSet Characters { get; set; } + public DbSet CharacterClothes { get; set; } + public DbSet DutyClothes { get; set; } + public DbSet ClothCombinations { get; set; } public DbSet Users { get; set; } public DbSet UserVehicles { get; set; } public DbSet UserBankAccounts { get; set; } - public DbSet Bans { get; set; } - public DbSet Characters { get; set; } + //Inventar public DbSet UserItems { get; set; } @@ -62,6 +60,7 @@ namespace reallife_gamemode.Model //Saves public DbSet Blips { get; set; } + public DbSet Doors { get; set; } public DbSet GotoPoints { get; set; } public DbSet Markers { get; set; } public DbSet Peds { get; set; } @@ -69,5 +68,8 @@ namespace reallife_gamemode.Model public DbSet TextLabels { get; set; } public DbSet Vehicles { get; set; } public DbSet ShopVehicles { get; set; } + + // Control Panel + public DbSet News { get; set; } } } diff --git a/Server/.gitkeep b/Server/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Server/Commands/Admin.cs b/Server/Commands/Admin.cs index 2319cb8a..8912d5f4 100644 --- a/Server/Commands/Admin.cs +++ b/Server/Commands/Admin.cs @@ -16,6 +16,7 @@ using reallife_gamemode.Server.Util; using reallife_gamemode.Server.Managers; using reallife_gamemode.Server.Inventory.Items; using reallife_gamemode.Server.Inventory.Interfaces; +using reallife_gamemode.Server.Saves; /** * @overview Life of German Reallife - Admin Commands (Admin.cs) @@ -97,49 +98,8 @@ namespace reallife_gamemode.Server.Commands dbContext.SaveChanges(); } } - [Command("vmod", "~m~Benutzung: ~s~/vmod [Slot] [Mod ID]")] - public void CmdAdminVmod(Client player, int slot, int mod) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - if (!player.IsInVehicle) - { - player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan nicht in einem Fahrzeug."); - return; - } - - if (mod == -1) player.Vehicle.RemoveMod(slot); - else player.Vehicle.SetMod(slot, mod); - } - - [Command("clothes", "~m~Benutzung: ~s~/clothes [Slot] [Component ID] (Textur)")] - public void CmdAdminClothes(Client player, int slot, int component, int texture = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - player.SetClothes(slot, component, texture); - } - - [Command("props", "~m~Benutzung: ~s~/props [Slot] [Component ID] (Textur)")] - public void CmdAdminProps(Client player, int slot, int component, int texture = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - player.SetAccessories(slot, component, texture); - } + #region Support [Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)] public void CmdAdminO(Client player, string message) { @@ -149,14 +109,689 @@ namespace reallife_gamemode.Server.Commands return; } - string publicMessage = "~b~(( " + player.Name + ": " + message + " ))"; + string publicMessage = "~b~(( " + player.GetUser().AdminLevel.GetName() + " " + player.Name + ": " + message + " ))"; NAPI.Chat.SendChatMessageToAll(publicMessage); } + [Command("team", "~m~Benutzung: ~s~/team")] + public void CmdAdminTeam(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + player.SendChatMessage("Online Teammitglieder:"); + + List playerlist = NAPI.Pools.GetAllPlayers(); + foreach (Client currentPlayer in playerlist) + { + if (currentPlayer.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? false) + { + player.SendChatMessage(currentPlayer.Name); + } + } + } + + [Command("dimension")] + public void CmdAdminDimension(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + player.SendChatMessage("Deine Dimension ist ~g~" + player.Dimension); + } + + [Command("to", "~m~Benutzung: ~s~/to [Name]")] + public void CmdAdminGoto(Client player, string name) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + //TODO: Als Supporter nur, wenn mit dem Ziel ein offenes Ticket besteht. Ansonsten kein Teleport + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = target.Position; + else player.Position = target.Position; + } + + [Command("position")] + public void CmdAdminShowPos(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + player.SendChatMessage("Position: X Y Z: " + player.Position); + } + + [Command("gh", "~m~Benutzung: ~s~/gh [Name]")] + public void CmdAdminGethere(Client player, string name) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + //TODO: Als Supporter nur, wenn mit dem Ziel ein offenes Ticket besteht. Ansonsten kein Teleport + if (target.IsInVehicle && target.VehicleSeat == -1) target.Vehicle.Position = player.Position; + else target.Position = player.Position; + target.SendChatMessage("Du wurdest von " + player.Name + " teleportiert."); + } + + [Command("aw", "~m~Benutzung: ~s~/aw [Spieler] [Nachricht]", GreedyArg = true)] + public void CmdAdminMsg(Client player, string name, string msg) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + /* if (target == player) //TODO: wieder reintun, musste testen + { + ChatService.ErrorMsg(player); + return; + }*/ + player.SendChatMessage("~y~PM an " + target.Name + ": " + msg + " "); + string Message = "~y~PM von " + player.GetUser().AdminLevel.GetName() + " " + player.Name + ": " + msg + ""; + NAPI.Chat.SendChatMessageToPlayer(target, Message); + } + + [Command("factionlist", "~m~Benutzung: ~s~/factionlist")] + public void CmdAdminFactionlist(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + using (var dbContext = new DatabaseContext()) + { + player.SendChatMessage("~m~__________ ~s~Fraktionen ~m~__________"); + foreach (Entities.Faction f in dbContext.Factions) + { + player.SendChatMessage(f.Id.ToString().PadRight(3) + " | " + f.Name); + } + } + } + #endregion + + + #region ALevel1 + [Command("a", "~m~Benutzung: ~s~/a [Nachricht]", GreedyArg = true)] + public void CmdAdminA(Client player, string message) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + ChatService.BroadcastAdmin("~r~[ADMINCHAT]: " + player.GetUser().AdminLevel.GetName() + " " + player.Name + "~w~: " + message, AdminLevel.ADMIN); + } + + [Command("freeze", "~m~Benutzung: ~s~/freeze [Spieler]")] + public void CmdAdminFreeze(Client player, string targetname) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(targetname); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + player.SendChatMessage("Du hast ~y~" + target.Name + " ~s~gefreezed."); + target.SendChatMessage("Du wurdest von ~y~" + player.Name + "~s~ gefreezed."); + target.Freeze(true); + } + + [Command("unfreeze", "~m~Benutzung: ~s~/unfreeze [Spieler]")] + public void CmdAdminUnfreeze(Client player, string targetname) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(targetname); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + player.SendChatMessage("Du hast ~y~" + target.Name + " ~s~unfreezed."); + target.SendChatMessage("Du wurdest von ~y~" + player.Name + "~s~ unfreezed."); + target.Freeze(false); + } + + [Command("gotolist")] //TODO Als Browser anzeigeN?? + public void CmdAdminGotoList(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + var gotoString = ""; + foreach (GotoPoint point in LoadManager.GotoPointList) + { + if (point.Active) + { + gotoString += point.Description + ", "; + } + } + player.SendChatMessage(gotoString); + } + + [Command("mark")] + public void CmdAdminMark(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + player.SetData("mark", player.Position); + player.SendNotification("~y~Mark ~s~gespeichert", true); + } + + [Command("gotomark")] + public void CmdAdminGotoMark(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (!player.HasData("mark")) + { + player.SendChatMessage("~r~[FEHLER]~s~ Du hast noch keine Markierung gesetzt. ~m~(/mark)"); + return; + } + + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = player.GetData("mark"); + else player.Position = player.GetData("mark"); + } + + [Command("clearchat", "~m~Benutzung: ~s~/clearchat")] + public void CmdAdminClearchat(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + for (int i = 0; i < 20; i++) + { + NAPI.Chat.SendChatMessageToAll(""); + } + } + + [Command("up", "~m~Benutzung: ~s~/up [Wert]")] + public void CmdAdminUp(Client player, int value = 5) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (player.IsInVehicle) + { + player.Vehicle.Position = new Vector3(player.Vehicle.Position.X, player.Vehicle.Position.Y, player.Vehicle.Position.Z + value); + } + else + { + player.Position = new Vector3(player.Position.X, player.Position.Y, player.Position.Z + value); + } + } + + [Command("dn", "~m~Benutzung: ~s~/dn [Wert]")] + public void CmdAdminDn(Client player, int value = 5) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (player.IsInVehicle) + { + player.Vehicle.Position = new Vector3(player.Vehicle.Position.X, player.Vehicle.Position.Y, player.Vehicle.Position.Z - value); + } + else + { + player.Position = new Vector3(player.Position.X, player.Position.Y, player.Position.Z - value); + } + } + + [Command("rt", "~m~Benutzung: ~s~/rt [Wert]")] + public void CmdAdminRt(Client player, int value = 5) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + float playerHeading = player.Heading; + + if (playerHeading < 45 || playerHeading >= 315) + { + Vector3 playerPosition = new Vector3(player.Position.X + value, player.Position.Y, player.Position.Z); + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; + else player.Position = playerPosition; + } + else if (playerHeading < 315 && playerHeading >= 225) + { + Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y - value, player.Position.Z); + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; + else player.Position = playerPosition; + } + else if (playerHeading >= 135 && playerHeading < 225) + { + Vector3 playerPosition = new Vector3(player.Position.X - value, player.Position.Y, player.Position.Z); + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; + else player.Position = playerPosition; + } + else if (playerHeading >= 45 && playerHeading < 135) + { + Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y + value, player.Position.Z); + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; + else player.Position = playerPosition; + } + } + + [Command("lt", "~m~Benutzung: ~s~/lt [Wert]")] + public void CmdAdminLt(Client player, int value = 5) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + float playerHeading = player.Heading; + + if (playerHeading < 45 || playerHeading >= 315) + { + Vector3 playerPosition = new Vector3(player.Position.X - value, player.Position.Y, player.Position.Z); + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; + else player.Position = playerPosition; + } + else if (playerHeading < 315 && playerHeading >= 225) + { + Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y + value, player.Position.Z); + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; + else player.Position = playerPosition; + } + else if (playerHeading >= 135 && playerHeading < 225) + { + Vector3 playerPosition = new Vector3(player.Position.X + value, player.Position.Y, player.Position.Z); + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; + else player.Position = playerPosition; + } + else if (playerHeading >= 45 && playerHeading < 135) + { + Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y - value, player.Position.Z); + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; + else player.Position = playerPosition; + } + } + + [Command("setdimension", "~m~Benutzung: ~s~/setdimension [Spieler] [Dimension]")] + public void CmdAdminSetDimension(Client player, string targetname, uint dimension) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(targetname); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + target.Dimension = dimension; + target.SendChatMessage("~s~Deine Dimension wurde auf ~g~" + dimension + "~s~ geändert."); + player.SendChatMessage("~s~Die Dimension von ~y~" + target.Name + " ~s~wurde auf ~g~" + dimension + "~s~ geändert."); + } + + [Command("kick", "~m~Benutzung: ~s~/kick [Player] [Grund]")] + public void CmdAdminKick(Client player, string targetname, string reason) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(targetname); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + string targetPlayername = NAPI.Player.GetPlayerName(target); + string adminPlayername = NAPI.Player.GetPlayerName(player); + + NAPI.Chat.SendChatMessageToPlayer(target, "~r~KICKINFO: ~w~Du wurdest von " + adminPlayername + " vom Server gekickt: " + reason); + target.Kick(); + NAPI.Chat.SendChatMessageToAll("~y~INFO: ~w~" + targetPlayername + " wurde von " + player.GetUser().AdminLevel.GetName() + " " + adminPlayername + " gekickt: " + reason); + } + + [Command("ip", "~m~Benutzung: ~s~/ip [Spieler]")] + public void CmdAdminIp(Client player, string targetname) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(targetname); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + player.SendChatMessage("IP von ~y~" + NAPI.Player.GetPlayerName(target) + ": ~g~" + target.Address); + } + + [Command("ban", "~m~Benutzung: ~s~/ban [User] [Zeit in Minuten(0 für Permanent)] [Grund] ", GreedyArg = true)] + public void CmdAdminBan(Client admin, string user, int mins, string reason) + { + if (!admin.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(admin); + return; + } + + Client target = ClientService.GetClientByNameOrId(user); + + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(admin); + return; + } + + target.GetUser().BanPlayer(admin, reason, mins); + } + + [Command("unban", "~m~Benutzung: ~s~/unban [Name] ", GreedyArg = true)] + public void CmdAdminUnban(Client admin, string userName) + { + if (!admin.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(admin); + return; + } + + Entities.User user; + + using (var dbContext = new DatabaseContext()) + { + user = dbContext.Users.FirstOrDefault(u => u.Name == userName); + if (user == null) + { + admin.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler existiert nicht."); + return; + } + + if (user.BanId == null) + { + admin.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist nicht gebannt."); + return; + } + + Ban ban = dbContext.Bans.FirstOrDefault(b => b.Id == user.BanId); + if (ban == null) + { + admin.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist nicht gebannt."); + return; + } + + if (ban.Applied == ban.UntilDateTime) + { + user.UnbanPlayer(admin); + } + else + { + int currentTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; + if (ban.UntilDateTime < currentTimestamp) + { + admin.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist nicht gebannt."); + return; + } + } + user.UnbanPlayer(admin); + } + + string message = "~b~[ADMIN] ~s~Der Spieler ~y~" + user.Name + " ~s~wurde von ~y~" + admin.Name + " ~s~entbannt."; + ChatService.BroadcastAdmin(message, AdminLevel.ADMIN); + } + + [Command("goto", "~m~Benutzung: ~s~/goto [Ort]")] + public void CmdAdminGotoPoint(Client player, string location) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + using (var dbContext = new DatabaseContext()) + { + Entities.GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == location); + + if(p == null) + { + player.SendChatMessage("~r~[FEHLER]~s~ Dieser Goto-Punkt existiert nicht."); + return; + } + + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = new Vector3(p.X, p.Y, p.Z); + else player.Position = new Vector3(p.X, p.Y, p.Z); + + } + } + + [Command("spec", "~m~Benutzung: ~s~/spec [Player]")] + public void CmdAdminSpectate(Client player, string name) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + if (target == player) + { + ChatService.ErrorMsg(player); + return; + } + + bool spec = player.GetData("spec"); + + if (spec == false) + { + NAPI.Player.SetPlayerToSpectatePlayer(player, target); + player.SetData("spec", true); + } + else + { + NAPI.Player.UnspectatePlayer(player); + player.SetData("spec", false); + } + + } + + [Command("slap", "~m~Benutzung: ~s~/slap [Spieler] (Höhe)")] + public void CmdAdminSlap(Client player, string name, int wert = 5) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + target.Position = new Vector3(target.Position.X, target.Position.Y, target.Position.Z + wert); + player.SendChatMessage("Du hast " + target.Name + " geslappt. Höhe: " + wert + ""); + } + + [Command("takeweapon", "~m~Benutzung: ~s~/takeweapon [Spieler]")] + public void CmdAdminTakeWeapon(Client player, string name) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + target.RemoveAllWeapons(); + target.SendChatMessage("~b~Deine Waffen wurden dir von " + player.Name + "(Admin) abgenommen"); + player.SendChatMessage("~b~Dem Spieler " + target.Name + " wurden erfolgreich alle Waffen abgenommen "); + } + #endregion + + + #region ALevel2 + [Command("sethp", "~m~Benutzung: ~s~/sethp [Spieler] (Hp)")] + public void CmdAdminSetHp(Client player, string name, int hp = 100) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN2) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + target.Health = hp; + target.SendChatMessage("~b~Deine HP wurden von " + player.Name + " auf " + hp + " gesetzt."); + player.SendChatMessage("~b~Du hast die HP von " + target.Name + " auf " + hp + " gesetzt."); + } + + [Command("clothes", "~m~Benutzung: ~s~/clothes [Spieler] [Slot] [Component ID] (Textur)")] + public void CmdAdminClothes(Client player, string name, int slot, int component, int texture = 0) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN2) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + target.SetClothes(slot, component, texture); + } + + [Command("props", "~m~Benutzung: ~s~/props [Spieler] [Slot] [Component ID] (Textur)")] + public void CmdAdminProps(Client player, string name, int slot, int component, int texture = 0) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN2) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + target.SetAccessories(slot, component, texture); + } + + [Command("gotox", "~m~Benutzung: ~s~/gotox [X] [Y] [Z]")] + public void CmdAdminGotoxyz(Client player, float x, float y, float z) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN2) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = new Vector3(x, y, z); + else player.Position = new Vector3(x, y, z); + } + #endregion + + + #region ALevel3 [Command("veh", "~m~Benutzung: ~s~/veh [Fahrzeug] (Farbe 1) (Farbe 2)")] public void CmdAdminVeh(Client player, string hash, int color1 = 111, int color2 = 111) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true) + //TODO: Bestimmte Autos nur ab Adminlevel 1337, "normale Fahrzeuge" schon ab Adminlevel 3. { ChatService.NotAuthorized(player); return; @@ -191,7 +826,7 @@ namespace reallife_gamemode.Server.Commands [Command("fv")] public void CmdAdminFixveh(Client player) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true) { ChatService.NotAuthorized(player); return; @@ -205,10 +840,202 @@ namespace reallife_gamemode.Server.Commands player.Vehicle.Repair(); } + [Command("vdestroy")] + public void CmdAdminDelveh(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (!player.IsInVehicle) // Man darf keine Autos erstellen, wenn man selbst in einem sitzt (verhindert Bugs) + { + player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan nicht in einem Fahrzeug."); + return; + } + + /* TODO: Checken, ob das Fahrzeug in einem System genutzt wird (Fraktions-Autos / Spieler-Auto) + * Wenn Ja: Abbrechen und mitteilen, dass man den System-spezifischen Befehl zu nutzen hat */ + + player.Vehicle.Delete(); + } + + [Command("vcolor", "~m~Benutzung: ~s~/vcolor [Farb-ID1] [Farb-ID2]")] + public void CmdAdminColor(Client player, int color1, int color2) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (!player.IsInVehicle) + { + player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan in keinem Fahrzeug!"); + return; + } + + player.Vehicle.PrimaryColor = color1; + player.Vehicle.SecondaryColor = color2; + player.SendChatMessage("Farb-ID1 " + color1 + ", Farb-ID2 " + color2 + ""); + } + + [Command("giveweapon", "~m~Benutzung: ~s~/giveweapon [Spieler] [Waffe] [Munition]")] + public void CmdAdminGiveweapon(Client player, string name, string weapon, int ammo) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (ammo <= 0) + { + player.SendChatMessage("~r~[FEHLER]~s~ Es muss mindestens 1 Munition vergeben werden."); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + WeaponHash wHash = NAPI.Util.WeaponNameToModel(weapon); + + if (wHash == default(WeaponHash)) + { + player.SendChatMessage("~r~[FEHLER]~s~ Diese Waffe existiert nicht."); + return; + } + + target.GiveWeapon(wHash, ammo); + target.SendChatMessage("~b~Du hast von " + player.Name + " eine/n " + wHash + " mit einer Munition von " + ammo + " erhalten."); + player.SendChatMessage("~b~Du hast " + target.Name + " eine/n " + wHash + " mit einer Munition von " + ammo + " gegeben."); + } + + [Command("arevive", "~m~Benutzung: ~s~/arevive [Spieler]")] + public void CmdAdminRevive(Client player, string name) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + if (target.Health != 0) + { + player.SendChatMessage("~r~[FEHLER]:~s~Spieler ist nicht tot"); + return; + } + target.TriggerEvent("onPlayerRevived"); + target.SendNotification("Du wurdest von Admin ~y~" + player.Name + "~s~ wiederbelebt."); + target.SetData("isDead", false); + NAPI.Player.SpawnPlayer(target, target.Position); + target.Health = 100; + } + + [Command("setarmor", "~m~Benutzung: ~s~/setarmor [Spieler] (Armor)")] + public void CmdAdminSetArmor(Client player, string name, int armor = 100) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Client target = ClientService.GetClientByNameOrId(name); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + target.Armor = armor; + target.SendChatMessage("~b~Deine Rüstung wurde von " + player.Name + " auf " + armor + " gesetzt."); + player.SendChatMessage("~b~Du hast die Rüstung von " + target.Name + " auf " + armor + " gesetzt."); + } + #endregion + + + #region ALevel1337 + [Command("editmode")] + public void CmdAdminToggleEditMode(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if(player.GetData("editmode") == false) + { + player.SetData("editmode", true); + player.SendNotification("Edit-Mode ~g~aktiviert"); + player.TriggerEvent("toggleEditMode", true); + } + else + { + player.SetData("editmode", false); + player.SendNotification("Edit-Mode ~r~deaktiviert"); + player.TriggerEvent("toggleEditMode", false); + } + + } + + [Command("setbliptemplate", "~m~Benutzung: ~s~/setbliptemplate [byte COLOR] [byte ALPHA] [bool SHORTRANGE] [uint SPRITE] [float SCALE] [string NAME]", GreedyArg = true)] + public void CmdAdminSetBlipTemplate(Client player, byte color, byte alpha, bool shortRange, uint sprite, float scale, string name) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + TempBlip newTempBlip = new TempBlip() + { + Color = color, + Name = name, + Transparency = alpha, + ShortRange = shortRange, + Sprite = sprite, + Scale = scale, + }; + + NAPI.Data.SetWorldData("blipTemplate", newTempBlip); + } + + [Command("vmod", "~m~Benutzung: ~s~/vmod [Slot] [Mod ID]")] + public void CmdAdminVmod(Client player, int slot, int mod) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (!player.IsInVehicle) + { + player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan nicht in einem Fahrzeug."); + return; + } + + if (mod == -1) player.Vehicle.RemoveMod(slot); + else player.Vehicle.SetMod(slot, mod); + } + [Command("aneon", "~m~Benutzung: ~s~/aneon [R][G][B]")] public void CmdAdminNeon(Client player, int r, int g, int b) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -228,7 +1055,7 @@ namespace reallife_gamemode.Server.Commands [Command("vehsmoke", "~m~Benutzung: ~s~/vehsmoke [R][G][B]")] public void CmdAdminVehSmoke(Client player, int r, int g, int b) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -242,119 +1069,12 @@ namespace reallife_gamemode.Server.Commands Vehicle veh = NAPI.Player.GetPlayerVehicle(player); NAPI.Vehicle.SetVehicleTyreSmokeColor(veh, new Color(r, g, b)); - - } - - [Command("vdestroy")] - public void CmdAdminDelveh(Client player) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - if (!player.IsInVehicle) // Man darf keine Autos erstellen, wenn man selbst in einem sitzt (verhindert Bugs) - { - player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan nicht in einem Fahrzeug."); - return; - } - - /* TODO: Checken, ob das Fahrzeug in einem System genutzt wird (Fraktions-Autos / Spieler-Auto) - * Wenn Ja: Abbrechen und mitteilen, dass man den System-spezifischen Befehl zu nutzen hat */ - - player.Vehicle.Delete(); - } - - [Command("to", "~m~Benutzung: ~s~/to [Name]")] - public void CmdAdminGoto(Client player, string name) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(name); - - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = target.Position; - else player.Position = target.Position; - } - - [Command("position")] - public void CmdAdminShowPos(Client player) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - player.SendChatMessage("Position: X Y Z: " + player.Position); - } - - [Command("goto", "~m~Benutzung: ~s~/goto [Ort]")] - public void CmdAdminGotoPoint(Client player, string location) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - using (var dbContext = new DatabaseContext()) - { - Entities.GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == location); - - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = new Vector3(p.X, p.Y, p.Z); - else player.Position = new Vector3(p.X, p.Y, p.Z); - - } - } - - [Command("gotox", "~m~Benutzung: ~s~/gotox [X] [Y] [Z]")] - public void CmdAdminGotoxyz(Client player, float x, float y, float z) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = new Vector3(x, y, z); - else player.Position = new Vector3(x, y, z); - } - - [Command("gh", "~m~Benutzung: ~s~/gh [Name]")] - public void CmdAdminGethere(Client player, string name) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(name); - - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - if (target.IsInVehicle && target.VehicleSeat == -1) target.Vehicle.Position = player.Position; - else target.Position = player.Position; - target.SendChatMessage("Du wurdest von " + player.Name + " teleportiert."); } [Command("ipl", "~m~Benutzung: ~s~/ipl [Load / Remove] [Name]")] public void CmdAdminIpl(Client player, string option, string name) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -378,221 +1098,10 @@ namespace reallife_gamemode.Server.Commands } } - [Command("giveweapon", "~m~Benutzung: ~s~/giveweapon [Spieler] [Waffe] [Munition]")] - public void CmdAdminGiveweapon(Client player, string name, string weapon, int ammo) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - if (ammo <= 0) - { - player.SendChatMessage("~r~[FEHLER]~s~ Es muss mindestens 1 Munition vergeben werden."); - return; - } - - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - WeaponHash wHash = NAPI.Util.WeaponNameToModel(weapon); - - if (wHash == default(WeaponHash)) - { - player.SendChatMessage("~r~[FEHLER]~s~ Diese Waffe existiert nicht."); - return; - } - - target.GiveWeapon(wHash, ammo); - target.SendChatMessage("~b~Du hast von " + player.Name + " eine/n " + wHash + " mit einer Munition von " + ammo + " erhalten."); - player.SendChatMessage("~b~Du hast " + target.Name + " eine/n " + wHash + " mit einer Munition von " + ammo + " gegeben."); - } - - [Command("sethp", "~m~Benutzung: ~s~/sethp [Spieler] (Leben)")] - public void CmdAdminSetHp(Client player, string name, int hp = 100) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - target.Health = hp; - target.SendChatMessage("~b~Dein Leben wurde von " + player.Name + " auf " + hp + " gesetzt."); - player.SendChatMessage("~b~Du hast das Leben von " + target.Name + " auf " + hp + " gesetzt."); - } - - [Command("arevive", "~m~Benutzung: ~s~/arevive [Spieler]")] - public void CmdAdminRevive(Client player, string name) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - if (target.Health != 0) - { - player.SendChatMessage("~r~[FEHLER]:~s~Spieler ist nicht tot"); - return; - } - target.TriggerEvent("onPlayerRevived"); - target.SendNotification("Du wurdest von Admin ~y~" + player.Name + "~s~ wiederbelebt."); - target.SetData("isDead", false); - NAPI.Player.SpawnPlayer(target, target.Position); - target.Health = 100; - } - - [Command("setarmor", "~m~Benutzung: ~s~/setarmor [Spieler] (Armor)")] - public void CmdAdminSetArmor(Client player, string name, int armor = 100) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - target.Armor = armor; - target.SendChatMessage("~b~Deine Rüstung wurde von " + player.Name + " auf " + armor + " gesetzt."); - player.SendChatMessage("~b~Du hast die Rüstung von " + target.Name + " auf " + armor + " gesetzt."); - } - - [Command("slap", "~m~Benutzung: ~s~/slap [Spieler] (Höhe)")] - public void CmdAdminSlap(Client player, string name, int wert = 5) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - target.Position = new Vector3(target.Position.X, target.Position.Y, target.Position.Z + wert); - player.SendChatMessage("Du hast "+target.Name+" geslappt. Höhe: "+wert+""); - } - - [Command("setskin", "~m~Benutzung: ~s~/setskin [Spieler] [Skin]")] - public void CmdAdminSetSkin(Client player, string name, string Skin) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - var skin = NAPI.Util.PedNameToModel(Skin); - target.SendChatMessage("~b~Dein Skin wurde von " + player.Name + " zu " + skin + " gesetzt."); - player.SendChatMessage("~b~Du hast den Skin von " + target.Name + " zu " + skin + " gesetzt."); - target.SetSkin(NAPI.Util.PedNameToModel(Skin)); - } - - [Command("vcolor", "~m~Benutzung: ~s~/vcolor [Farb-ID1] [Farb-ID2]")] - public void CmdAdminColor(Client player, int color1, int color2) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - if (!player.IsInVehicle) - { - player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan in keinem Fahrzeug!"); - return; - } - - player.Vehicle.PrimaryColor = color1; - player.Vehicle.SecondaryColor = color2; - player.SendChatMessage("Farb-ID1 " + color1 + ", Farb-ID2 " + color2 + ""); - } - - [Command("aw", "~m~Benutzung: ~s~/aw [Spieler] [Nachricht]", GreedyArg = true)] - public void CmdAdminMsg(Client player, string name, string msg) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - if (target == player) - { - ChatService.ErrorMsg(player); - return; - } - - target.SendChatMessage("~y~PM von " + player.Name + ": " + msg + " "); - player.SendChatMessage("~y~PM an " + target.Name + ": " + msg + " "); - } - - [Command("takeweapon", "~m~Benutzung: ~s~/takeweapon [Spieler]")] - public void CmdAdminTakeWeapon(Client player, string name) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - target.RemoveAllWeapons(); - target.SendChatMessage("~b~Deine Waffen wurden dir von " + player.Name + "(Admin) abgenommen"); - player.SendChatMessage("~b~Dem Spieler " + target.Name + " wurden erfolgreich alle Waffen abgenommen "); - } - [Command("rsethp", "~m~Benutzung: ~s~/rsethp [Radius] (Leben)")] public void CmdAdminRangeSetHP(Client player, float radius, int hp = 100) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -609,9 +1118,9 @@ namespace reallife_gamemode.Server.Commands } [Command("freekh", "~m~Benutzung: ~s~/freekh (Radius)")] - public void CmdAdminFreekh(Client player, float radius=9999999) + public void CmdAdminFreekh(Client player, float radius = 999999999) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -621,28 +1130,29 @@ namespace reallife_gamemode.Server.Commands foreach (var managedClient in peopleInRange) { if (!managedClient.IsLoggedIn()) return; - if (!managedClient.HasData("isDead") || managedClient.GetData("isDead") == false) continue; - if (radius == 9999999) + if (radius == 999999999) { managedClient.SendChatMessage("~b~Admin " + player.Name + " hat alle Spieler wiederbelebt"); + player.SendChatMessage("~b~Du hast " + peopleInRange.Count + " Spieler wiederbelebt"); } else { managedClient.SendChatMessage("~b~Admin " + player.Name + " hat im Radius von " + radius + " alle Spieler wiederbelebt"); + player.SendChatMessage("~b~Du hast " + peopleInRange.Count + " Spieler wiederbelebt"); } + if (!managedClient.HasData("isDead") || managedClient.GetData("isDead") == false) continue; managedClient.TriggerEvent("onPlayerRevived"); managedClient.SendNotification("Du wurdest von Admin ~y~" + player.Name + "~s~ wiederbelebt."); managedClient.SetData("isDead", false); NAPI.Player.SpawnPlayer(managedClient, managedClient.Position); managedClient.Health = 100; - player.SendChatMessage("~b~Du hast " + peopleInRange.Count + " Spieler wiederbelebt"); } } [Command("rsetarmor", "~m~Benutzung: ~s~/rsetarmor [Radius] (Armor)")] public void CmdAdminRangeSetArmor(Client player, float radius, int Armor = 100) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -658,33 +1168,10 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("~b~Die Rüstung von " + peopleInRange.Count + " Spielern wurde auf " + Armor + " gesetzt."); } - [Command("time", "~m~Benutzung: ~s~/time [Stunde] (Minuten) (Sekunden)")] - public void CmdAdminSetTime(Client player, int hour, int min = 0, int sec = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - string broadcastMsg = $"Serverzeit wurde auf {hour:D2}:{min:D2}:{sec:D2} gesetzt!"; - NAPI.Notification.SendNotificationToAll(broadcastMsg); - NAPI.World.SetTime(hour, min, sec); - return; - - } - - [Command("val")] - public void Val(Client player) - { - // TODO: Remove on release - NAPI.Chat.SendChatMessageToAll("Value of " + player.Name + ": " + player.Handle.Value); - } - [Command("rgiveweapon", "~m~Benutzung: ~s~/rgiveweapon [Radius] [Waffe] [Munition]")] public void CmdAdminRangeGiveWeapon(Client player, float radius, string weapon, int munition) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -709,35 +1196,32 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("~b~Du hast " + peopleInRange.Count + " Spielern eine " + weapon + " mit " + munition + " Munition gegeben"); } - [Command("factionlist", "~m~Benutzung: ~s~/factionlist")] - public void CmdAdminFactionlist(Client player) + [Command("time", "~m~Benutzung: ~s~/time [Stunde] (Minuten) (Sekunden)")] + public void CmdAdminSetTime(Client player, int hour, int min = 0, int sec = 0) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; } - using(var dbContext = new DatabaseContext()) - { - player.SendChatMessage("~m~__________ ~s~Fraktionen ~m~__________"); - foreach(Entities.Faction f in dbContext.Factions) - { - player.SendChatMessage(f.Id.ToString().PadRight(3) + " | " + f.Name); - } - } + string broadcastMsg = $"Serverzeit wurde auf {hour:D2}:{min:D2}:{sec:D2} gesetzt!"; + NAPI.Notification.SendNotificationToAll(broadcastMsg); + NAPI.World.SetTime(hour, min, sec); + return; + } [Command("ainvite", "~m~Benutzung: ~s~/ainvite [Name] [Fraktion]")] public void CmdAdminAinvite(Client player, string name, int faction) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; } - Client target = ClientService.GetClientByName(name); + Client target = ClientService.GetClientByNameOrId(name); if (target == null || !target.IsLoggedIn()) { ChatService.PlayerNotFound(player); @@ -752,7 +1236,7 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("~r~[FEHLER]~s~ Diese Fraktion existiert nicht (Liste: ~m~/factionlist)."); return; } - + Entities.User u = target.GetUser(dbContext); if (faction != 0) @@ -772,7 +1256,7 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("~b~[ADMIN]~s~ Du hast hast den Spieler ~y~" + target.Name + "~s~ administrativ aus seiner Fraktion geworfen."); target.SendChatMessage("~b~[ADMIN]~s~ Du wurdest von ~y~" + player.Name + "~s~ administrativ aus deiner Fraktion geworfen."); } - + u.FactionLeader = false; dbContext.SaveChanges(); @@ -782,13 +1266,13 @@ namespace reallife_gamemode.Server.Commands [Command("makeleader", "~m~Benutzung: ~s~/makeleader [Name] [Fraktion]")] public void CmdAdminMakeleader(Client player, string name, int faction) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; } - Client target = ClientService.GetClientByName(name); + Client target = ClientService.GetClientByNameOrId(name); if (target == null || !target.IsLoggedIn()) { ChatService.PlayerNotFound(player); @@ -805,7 +1289,7 @@ namespace reallife_gamemode.Server.Commands } Entities.User u = target.GetUser(dbContext); - + u.FactionId = f.Id; u.FactionRankId = dbContext.FactionRanks. OrderByDescending(x => x.Order) @@ -819,36 +1303,21 @@ namespace reallife_gamemode.Server.Commands } } - [Command("ban", "~m~Benutzung: ~s~/ban [User] [Zeit in Minuten(0 für Permanent)] [Grund] ", GreedyArg = true)] - public void CmdAdminBan(Client admin, string user, int mins, string reason) - { - if (!admin.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(admin); - return; - } - - Client target = ClientService.GetClientByName(user); - - if(target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(admin); - return; - } - - target.GetUser().BanPlayer(admin, reason, mins); - } - [Command("save", "~m~Benutzung: ~s~/save [Typ = ~g~Blip, Goto (X), ~r~Marker, Ped, Pickup, TextLabel, ~g~Vehicle, FVehicle, SVehicle] (Beschreibung) = (X)")] public void CmdAdminSave(Client player, string typ, string description = null) { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } switch (typ) { case "Blip": player.TriggerEvent("saveBlip"); break; case "Goto": - if(description == null) + if (description == null) { player.SendChatMessage("Für Goto musst du einen dritten Parameter angeben. Beispiel: Ort des Goto-Punktes."); return; @@ -858,9 +1327,9 @@ namespace reallife_gamemode.Server.Commands using (var dbContext = new DatabaseContext()) { GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == description); - if(p == null) + if (p == null) { - SaveManager.SaveGotoPoint(player, description); + SaveManager.SaveGotoPoint(player, description); player.SendNotification("Goto-Punkt ~g~" + description + "~s~ gespeichert.", true); } else @@ -868,9 +1337,9 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("Einen Goto-Punkt mit dieser Bezeichnung gibt es schon!"); } } - + } - + break; case "Vehicle": if (player.IsInVehicle) @@ -886,7 +1355,7 @@ namespace reallife_gamemode.Server.Commands case "FVehicle": if (player.IsInVehicle) { - if(player.GetUser().FactionId == null) + if (player.GetUser().FactionId == null) { player.SendChatMessage("~m~Du bist in keiner Fraktion! Invite dich erst mit ~y~/ainvite"); return; @@ -918,9 +1387,15 @@ namespace reallife_gamemode.Server.Commands } } + #region loadCommand [Command("load", "~m~Benutzung: ~s~/load [Typ = OnlineBunkers, ArcadiusBusinessCentre, MazeBankBuilding, LomBank, MazeBankWest, ClubWareHouse, SpecialLocations, GRHYacht, DHYacht, PYacht, AircraftCarrier, BridgeTC, BridgeTN, NorthYankton, ONeilsFarmB, ONeilsFarm, Morgue")] public void CmdAdminloadlocation(Client player, string typ) { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } switch (typ) { case "OnlineBunkers": @@ -1077,8 +1552,8 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("~y~Bridge Train Crash~s~ erfolgreich geladen!"); break; case "BridgeTN": - NAPI.World.RequestIpl("canyonriver01"); - NAPI.World.RequestIpl("railing_start"); + NAPI.World.RequestIpl("canyonriver01"); + NAPI.World.RequestIpl("railing_start"); player.SendChatMessage("~y~Bridge Train Normal~s~ erfolgreich geladen!"); break; case "NorthYankton": @@ -1123,7 +1598,7 @@ namespace reallife_gamemode.Server.Commands NAPI.World.RequestIpl("des_farmhs_end_occl"); player.SendChatMessage("~y~ONeils Farm Burnt~s~ erfolgreich geladen!"); break; - case "ONeilsFarm": + case "ONeilsFarm": NAPI.World.RequestIpl("farm"); NAPI.World.RequestIpl("farm_props"); NAPI.World.RequestIpl("farm_int"); @@ -1135,65 +1610,15 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("~y~Morgue~s~ erfolgreich geladen!"); break; } + } - - [Command("unban", "~m~Benutzung: ~s~/unban [Name] ", GreedyArg = true)] - public void CmdAdminUnban(Client admin, string userName) - { - if (!admin.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(admin); - return; - } - - Entities.User user; - - using (var dbContext = new DatabaseContext()) - { - user = dbContext.Users.FirstOrDefault(u => u.Name == userName); - if(user == null) - { - admin.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler existiert nicht."); - return; - } - - if(user.BanId == null) - { - admin.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist nicht gebannt."); - return; - } - - Ban ban = dbContext.Bans.FirstOrDefault(b => b.Id == user.BanId); - if(ban == null) - { - admin.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist nicht gebannt."); - return; - } - - if(ban.Applied == ban.UntilDateTime) - { - user.UnbanPlayer(admin); - } - else - { - int currentTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; - if(ban.UntilDateTime < currentTimestamp) - { - admin.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist nicht gebannt."); - return; - } - } - user.UnbanPlayer(admin); - } - - string message = "~y~INFO: ~s~Der Spieler ~y~" + user.Name + " ~s~wurde von ~y~" + admin.Name + " ~s~entbannt."; - ChatService.BroadcastAdmin(message, AdminLevel.ADMIN); - } - + #endregion + + // [Command("managefactionranks", "~m~Benutzung: ~s~/managefactionranks [Fraktions-ID]")] public void CmdFactionManageFactionRanks(Client player, int factionID) { - if(!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -1230,6 +1655,116 @@ namespace reallife_gamemode.Server.Commands player.TriggerEvent("manageFactionRanks", json); } } + [Command("setweather", "~m~Benutzung: ~s~/setweather [Wetter]")] + public void CmdAdminSetweather(Client player, string weather) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + bool found = false; + foreach (string w in Enum.GetNames(typeof(Weather))) + { + if (w.ToLower() == weather) + { + found = true; + break; + } + } + + if (!found) + { + player.SendChatMessage("~r~[FEHLER]~s~ Dieses Wetter existiert nicht."); + return; + } + + Weather weatherBefore = NAPI.World.GetWeather(); + NAPI.World.SetWeather(weather); + Weather weatherAfter = NAPI.World.GetWeather(); + + if (!weatherBefore.Equals(weatherAfter)) + { + NAPI.Chat.SendChatMessageToPlayer(player, "~w~Wetter geändert: " + NAPI.World.GetWeather()); + NAPI.Notification.SendNotificationToAll("Das Wetter wurde auf ~g~ " + NAPI.World.GetWeather() + "~s~ geändert.", true); + } + else + { + NAPI.Chat.SendChatMessageToPlayer(player, "~w~Das Wetter konnte nicht geändert werden"); + } + } + [Command("aspeed", "~m~Benutzung: ~s~/aspeed [Modifier]")] //TODO: Überarbeiten ?? SetPlayerVelocity ?? + public void CmdAdminAspeed(Client player, float modifier) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (!player.IsInVehicle) + { + player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan nicht in einem Fahrzeug."); + return; + } + + player.Vehicle.EnginePowerMultiplier = modifier; + } + [Command("setmoney")] + public void SetPlayerMoney(Client player, string receiver, int amount) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + Client target = ClientService.GetClientByNameOrId(receiver); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + using (var dbContext = new DatabaseContext()) + { + target.GetUser().GetBankAccount(dbContext).Balance = amount; + dbContext.SaveChanges(); + } + player.SendChatMessage("~b~[ADMIN]~s~ Du hast das Geld von " + target.Name + " auf ~g~$" + amount + "~s~ gesetzt."); + target.SendChatMessage("~b~[ADMIN]~s~ Dein Geld wurde von Admin " + player.Name + " auf ~g~$" + amount + "~s~ gesetzt."); + } + + [Command("givemoney")] + public void GivePlayerMoney(Client player, string receiver, int amount) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + Client target = ClientService.GetClientByNameOrId(receiver); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + using (var dbContext = new DatabaseContext()) + { + target.GetUser().GetBankAccount(dbContext).Balance += amount; + dbContext.SaveChanges(); + } + player.SendChatMessage("~b~[ADMIN]~s~ Du hast " + target.Name + " ~g~$" + amount + "~s~ gegeben."); + target.SendChatMessage("~b~[ADMIN]~s~ Admin " + player.Name + " hat dir ~g~$" + amount + "~s~ gegeben."); + } + #endregion + + #region ALevel1338 + // ): + #endregion + + /* ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ //TEST COMMAND [Command("own")] @@ -1270,338 +1805,12 @@ namespace reallife_gamemode.Server.Commands else player.SendChatMessage("~m~Du sitzt in keinem Fahrzeug!"); } - [Command("a", "~m~Benutzung: ~s~/a [Nachricht]", GreedyArg = true)] - public void CmdAdminA(Client player, string message) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - ChatService.BroadcastAdmin("~r~Admin " + player.Name + "~w~: " + message, AdminLevel.ADMIN); - } - [Command("team", "~m~Benutzung: ~s~/team")] - public void CmdAdminTeam(Client player) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - player.SendChatMessage("Online Teammitglieder:"); - List playerlist = NAPI.Pools.GetAllPlayers(); - foreach (Client currentPlayer in playerlist) - { - if (currentPlayer.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? false) - { - player.SendChatMessage(currentPlayer.Name); - } - } - } - - [Command("setweather", "~m~Benutzung: ~s~/setweather [Wetter]")] - public void CmdAdminSetweather(Client player, string weather) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - bool found = false; - foreach(string w in Enum.GetNames(typeof(Weather))) - { - if (w.ToLower() == weather) - { - found = true; - break; - } - } - - if(!found) - { - player.SendChatMessage("~r~[FEHLER]~s~ Dieses Wetter existiert nicht."); - return; - } - - Weather weatherBefore = NAPI.World.GetWeather(); - NAPI.World.SetWeather(weather); - Weather weatherAfter = NAPI.World.GetWeather(); - - if (!weatherBefore.Equals(weatherAfter)) - { - NAPI.Chat.SendChatMessageToPlayer(player, "~w~Wetter geändert: " + NAPI.World.GetWeather()); - NAPI.Notification.SendNotificationToAll("Das Wetter wurde auf ~g~ "+NAPI.World.GetWeather()+"~s~ geändert.", true); - } - else - { - NAPI.Chat.SendChatMessageToPlayer(player, "~w~Das Wetter konnte nicht geändert werden"); - } - } - - [Command("freeze", "~m~Benutzung: ~s~/freeze [Spieler]")] - public void CmdAdminFreeze(Client player, string targetname) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(targetname); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - target.Freeze(true); - } - - [Command("unfreeze", "~m~Benutzung: ~s~/unfreeze [Spieler]")] - public void CmdAdminUnfreeze(Client player, string targetname) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(targetname); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - target.Freeze(false); - } - - [Command("kick", "~m~Benutzung: ~s~/kick [Player] [Grund]")] - public void CmdAdminKick(Client player, string targetname, string reason) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(targetname); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - string targetPlayername = NAPI.Player.GetPlayerName(target); - string adminPlayername = NAPI.Player.GetPlayerName(player); - - NAPI.Chat.SendChatMessageToPlayer(target, "~r~KICKINFO: ~w~Du wurdest von " + adminPlayername + " vom Server gekickt: " + reason); - target.Kick(); - NAPI.Chat.SendChatMessageToAll("~y~INFO: ~w~" + targetPlayername + " wurde von " + adminPlayername + " gekickt: " + reason); - } - - [Command("clearchat", "~m~Benutzung: ~s~/clearchat")] - public void CmdAdminClearchat(Client player) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - for (int i = 0; i < 20; i++) - { - NAPI.Chat.SendChatMessageToAll(""); - } - } - - [Command("up", "~m~Benutzung: ~s~/up [Wert]")] - public void CmdAdminUp(Client player, int value = 5) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - if (player.IsInVehicle) - { - player.Vehicle.Position = new Vector3(player.Vehicle.Position.X, player.Vehicle.Position.Y, player.Vehicle.Position.Z + value); - } - else - { - player.Position = new Vector3(player.Position.X, player.Position.Y, player.Position.Z + value); - } - } - - [Command("dn", "~m~Benutzung: ~s~/dn [Wert]")] - public void CmdAdminDn(Client player, int value = 5) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - if (player.IsInVehicle) - { - player.Vehicle.Position = new Vector3(player.Vehicle.Position.X, player.Vehicle.Position.Y, player.Vehicle.Position.Z - value); - } else - { - player.Position = new Vector3(player.Position.X, player.Position.Y, player.Position.Z - value); - } - } - - [Command("rt", "~m~Benutzung: ~s~/rt [Wert]")] - public void CmdAdminRt(Client player, int value = 5) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - float playerHeading = player.Heading; - - if (playerHeading < 45 || playerHeading >= 315) - { - Vector3 playerPosition = new Vector3(player.Position.X + value, player.Position.Y, player.Position.Z); - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; - else player.Position = playerPosition; - } - else if (playerHeading < 315 && playerHeading >= 225) - { - Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y - value, player.Position.Z); - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; - else player.Position = playerPosition; - } - else if (playerHeading >= 135 && playerHeading < 225) - { - Vector3 playerPosition = new Vector3(player.Position.X - value, player.Position.Y, player.Position.Z); - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; - else player.Position = playerPosition; - } - else if (playerHeading >= 45 && playerHeading < 135) - { - Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y + value, player.Position.Z); - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; - else player.Position = playerPosition; - } - } - - [Command("lt", "~m~Benutzung: ~s~/lt [Wert]")] - public void CmdAdminLt(Client player, int value = 5) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - float playerHeading = player.Heading; - - if (playerHeading < 45 || playerHeading >= 315) - { - Vector3 playerPosition = new Vector3(player.Position.X - value, player.Position.Y, player.Position.Z); - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; - else player.Position = playerPosition; - } - else if (playerHeading < 315 && playerHeading >= 225) - { - Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y + value, player.Position.Z); - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; - else player.Position = playerPosition; - } - else if (playerHeading >= 135 && playerHeading < 225) - { - Vector3 playerPosition = new Vector3(player.Position.X + value, player.Position.Y, player.Position.Z); - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; - else player.Position = playerPosition; - } - else if (playerHeading >= 45 && playerHeading < 135) - { - Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y - value, player.Position.Z); - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = playerPosition; - else player.Position = playerPosition; - } - } - - [Command("spec", "~m~Benutzung: ~s~/spec [Player]")] - public void CmdAdminSpectate(Client player, string name) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - Client target = ClientService.GetClientByName(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - if (target == player) - { - ChatService.ErrorMsg(player); - return; - } - - bool spec = player.GetData("spec"); - - if (spec == false) - { - NAPI.Player.SetPlayerToSpectatePlayer(player, target); - player.SetData("spec", true); - } - else - { - NAPI.Player.UnspectatePlayer(player); - player.SetData("spec", false); - } - - } - - [Command("ip", "~m~Benutzung: ~s~/ip [Spieler]")] - public void CmdAdminIp(Client player, string targetname) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Client target = ClientService.GetClientByName(targetname); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - player.SendChatMessage("IP von " + NAPI.Player.GetPlayerName(target) + ": " + target.Address); - } //TODO TEST COMMAND - [Command("aspeed", "~m~Benutzung: ~s~/aspeed [Modifier]")] - public void CmdAdminAspeed(Client player, float modifier) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - if (!player.IsInVehicle) - { - player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan nicht in einem Fahrzeug."); - return; - } - - player.Vehicle.EnginePowerMultiplier = modifier; - } //TEST COMMAND [Command("myvehicles")] @@ -1627,53 +1836,6 @@ namespace reallife_gamemode.Server.Commands } } - [Command("setmoney")] - public void SetPlayerMoney(Client player, string receiver, int amount) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - Client target = ClientService.GetClientByName(receiver); - if(target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - using(var dbContext = new DatabaseContext()) - { - target.GetUser().GetUserBankAccount(dbContext).Balance = amount; - dbContext.SaveChanges(); - } - player.SendChatMessage("~b~[ADMIN]~s~ Du hast das Geld von " + target.Name + " auf ~g~$" + amount + "~s~ gesetzt."); - target.SendChatMessage("~b~[ADMIN]~s~ Dein Geld wurde von Admin " + player.Name + " auf ~g~$" + amount + "~s~ gesetzt."); - } - - [Command("givemoney")] - public void GivePlayerMoney(Client player, string receiver, int amount) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - Client target = ClientService.GetClientByName(receiver); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - using (var dbContext = new DatabaseContext()) - { - target.GetUser().GetUserBankAccount(dbContext).Balance += amount; - dbContext.SaveChanges(); - } - player.SendChatMessage("~b~[ADMIN]~s~ Du hast " + target.Name + " ~g~$" + amount + "~s~ gegeben."); - target.SendChatMessage("~b~[ADMIN]~s~ Admin " + player.Name + " hat dir ~g~$" + amount + "~s~ gegeben."); - } //TODO [Command("fpay")] @@ -1687,7 +1849,14 @@ namespace reallife_gamemode.Server.Commands using (var getFaction = new DatabaseContext()) { Entities.Faction receiverUser = getFaction.Factions.FirstOrDefault(u => u.Name == receiver); - BankManager.TransferUserMoneyToFaction(player.GetUser(), receiverUser, amount, "/FPAY"); + + if(receiverUser == null) + { + player.SendChatMessage("~r~[FEHLER]~s~ Diese Fraktion existiert nicht."); + return; + } + + BankManager.TransferMoney(player.GetUser(), receiverUser, amount, "/FPAY"); } } @@ -1709,7 +1878,7 @@ namespace reallife_gamemode.Server.Commands { ShopVehicle sVehicle = getShopVehicle.ShopVehicles.FirstOrDefault(u => u.Id == shopVehicleId); Entities.Faction receiverUser = getShopVehicle.Factions.FirstOrDefault(u => u.Name == "LSPD"); - BankManager.TransferUserMoneyToFaction(player.GetUser(), receiverUser, sVehicle.Price, "Fahrzeug gekauft: " + sVehicle.ModelName); + BankManager.TransferMoney(player.GetUser(), receiverUser, sVehicle.Price, "Fahrzeug gekauft: " + sVehicle.ModelName); //TODO Anpassen Vehicle boughtVehicle = NAPI.Vehicle.CreateVehicle(sVehicle.Model, new Vector3(sVehicle.PositionX, sVehicle.PositionY + 10, sVehicle.PositionZ + 0.5), sVehicle.Heading, sVehicle.PrimaryColor, sVehicle.SecondaryColor, "LoG", sVehicle.Alpha, false, true, 0); @@ -1721,57 +1890,6 @@ namespace reallife_gamemode.Server.Commands } } - //TODO Als Browser anzeigeN?? - [Command("gotolist")] - public void CmdAdminGotoList(Client player) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - var gotoString = ""; - foreach(GotoPoint point in LoadManager.GotoPointList) - { - if(point.Active) - { - gotoString += point.Description + ", "; - } - } - player.SendChatMessage(gotoString); - } - - [Command("mark")] - public void CmdAdminMark(Client player) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - player.SetData("mark", player.Position); - player.SendNotification("~y~Mark ~s~gespeichert", true); - } - - [Command("gotomark")] - public void CmdAdminGotoMark(Client player) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - if(!player.HasData("mark")) - { - player.SendChatMessage("~r~[FEHLER]~s~ Du hast noch keine Markierung gesetzt. ~m~(/mark)"); - return; - } - - if (player.IsInVehicle && player.VehicleSeat == -1) player.Vehicle.Position = player.GetData("mark"); - else player.Position = player.GetData("mark"); - } - [Command("getincar", "~m~Benutzung: ~s~/getincar [Name]")] public void CmdAdminGetincar(Client player, string name) { @@ -1781,7 +1899,7 @@ namespace reallife_gamemode.Server.Commands return; } - Client target = ClientService.GetClientByName(name); + Client target = ClientService.GetClientByNameOrId(name); if (target == null || !target.IsLoggedIn()) { ChatService.PlayerNotFound(player); @@ -1802,31 +1920,5 @@ namespace reallife_gamemode.Server.Commands { SaveManager.SaveAllOnSave(); } - - /* - [Command("restart")] - public void CmdAdminRestart(Client player) - { - if (ClientExtension.IsLoggedIn(player) == false) - { - ChatService.PlayerNotLoggedIn(player); - return; - } - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - var users = NAPI.Pools.GetAllPlayers(); - - foreach(Client user in users) - { - user.SendChatMessage("~r~Server startet neu.~s~ Bitte verbinde dich über ~y~F1~s~ neu."); - user.Kick(); - } - - NAPI.Resource.StopResource("reallife-gamemode"); - }*/ - } + } } diff --git a/Server/Commands/Faction.cs b/Server/Commands/Faction.cs index 1d5ac05c..b4a4e937 100644 --- a/Server/Commands/Faction.cs +++ b/Server/Commands/Faction.cs @@ -78,7 +78,7 @@ namespace reallife_gamemode.Server.Commands return; } - Client target = ClientService.GetClientByName(name); + Client target = ClientService.GetClientByNameOrId(name); if (target == null || !target.IsLoggedIn()) { ChatService.PlayerNotFound(player); @@ -109,7 +109,7 @@ namespace reallife_gamemode.Server.Commands return; } - Client target = ClientService.GetClientByName(name); + Client target = ClientService.GetClientByNameOrId(name); if (target == null || !target.IsLoggedIn()) { ChatService.PlayerNotFound(player); @@ -149,7 +149,7 @@ namespace reallife_gamemode.Server.Commands return; } - Client target = ClientService.GetClientByName(name); + Client target = ClientService.GetClientByNameOrId(name); if (target == null || !target.IsLoggedIn()) { ChatService.PlayerNotFound(player); @@ -239,27 +239,7 @@ namespace reallife_gamemode.Server.Commands [Command("duty", "~m~Benutzung: ~s~/duty")] public void CmdFactionDuty(Client player) { - if (player.GetUser()?.FactionId == null) - { - ChatService.NotAuthorized(player); - return; - } - - if(player.GetData("duty") != true) - { - player.SetData("duty", true); - player.SendNotification("Du bist nun ~g~im Dienst."); - if(player.GetUser().FactionId == 2) - { - NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", true); - } - } - else - { - player.SetData("duty", false); - player.SendNotification("Du bist nun ~r~außer Dienst."); - NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false); - } + } #endregion } diff --git a/Server/Commands/User.cs b/Server/Commands/User.cs index 9ca97415..3119c56c 100644 --- a/Server/Commands/User.cs +++ b/Server/Commands/User.cs @@ -27,9 +27,18 @@ namespace reallife_gamemode.Server.Commands return; } + player.ResetData("accept_data"); + using(var dbContext = new DatabaseContext()) { Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_invite")); + + if(leader == null) + { + player.SendChatMessage("~r~[FEHLER]~s~ Die Einladung ist abgelaufen."); + return; + } + Entities.User u = leader.GetUser(dbContext); Entities.User own = player.GetUser(dbContext); diff --git a/Server/Entities/CharacterCloth.cs b/Server/Entities/CharacterCloth.cs new file mode 100644 index 00000000..50364c6d --- /dev/null +++ b/Server/Entities/CharacterCloth.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +/** + * @overview Life of German Reallife - Entities CharacterCloth CharacterCloth.cs + * @author VegaZ + * @copyright (c) 2008 - 2018 Life of German + */ + +namespace reallife_gamemode.Server.Entities +{ + public class CharacterCloth + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + + [ForeignKey("User")] + public int UserId { get; set; } + public User User { get; set; } + + public bool Duty { get; set; } + + public byte SlotType { get; set; } + public int SlotId { get; set; } + public int ClothId { get; set; } + } +} diff --git a/Server/Entities/ClothCombination.cs b/Server/Entities/ClothCombination.cs new file mode 100644 index 00000000..bbf9223f --- /dev/null +++ b/Server/Entities/ClothCombination.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Numerics; +using System.Text; + +/** +* @overview Life of German Reallife - Entities MaleCombination (MaleCombination.cs) +* @author VegaZ +* @copyright (c) 2008 - 2018 Life of German +*/ + +namespace reallife_gamemode.Server.Entities +{ + public class ClothCombination + { + [Key] + public int Id { get; set; } + public bool Gender { get; set; } + public int Top { get; set; } + public int Torso { get; set; } + public int Undershirt { get; set; } + } +} diff --git a/Server/Entities/Door.cs b/Server/Entities/Door.cs new file mode 100644 index 00000000..87dd5a66 --- /dev/null +++ b/Server/Entities/Door.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Numerics; +using System.Text; + +/** +* @overview Life of German Reallife - Entities Door (Door.cs) +* @author VegaZ +* @copyright (c) 2008 - 2018 Life of German +*/ + +namespace reallife_gamemode.Server.Entities +{ + public class Door + { + [Key] + public int Id { get; set; } + public string Category { get; set; } + public string Name { get; set; } + public bool Locked { get; set; } + public int Model { get; set; } + public float X { get; set; } + public float Y { get; set; } + public float Z { get; set; } + public float Radius { get; set; } + + [ForeignKey("FactionId")] + public int? FactionId { get; set; } + public Faction Faction { get; set; } + } +} diff --git a/Server/Entities/DutyCloth.cs b/Server/Entities/DutyCloth.cs new file mode 100644 index 00000000..dd3a875d --- /dev/null +++ b/Server/Entities/DutyCloth.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; + +/** + * @overview Life of German Reallife - Entities DutyCloth DutyCloth.cs + * @author VegaZ + * @copyright (c) 2008 - 2018 Life of German + */ + +namespace reallife_gamemode.Server.Entities +{ + public class DutyCloth + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + + [ForeignKey("Faction")] + public int FactionId { get; set; } + public Faction Faction { get; set; } + + public bool Gender { get; set; } + + public byte SlotType { get; set; } + public int SlotId { get; set; } + public int ClothId { get; set; } + } +} diff --git a/Server/Entities/Faction.cs b/Server/Entities/Faction.cs index 88db5333..9dc14faa 100644 --- a/Server/Entities/Faction.cs +++ b/Server/Entities/Faction.cs @@ -1,8 +1,11 @@ using Microsoft.EntityFrameworkCore; +using reallife_gamemode.Model; +using reallife_gamemode.Server.Util; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; using System.Text; /** @@ -13,14 +16,28 @@ using System.Text; namespace reallife_gamemode.Server.Entities { - public class Faction + public class Faction : IBankAccountOwner { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [StringLength(32)] public string Name { get; set; } - public int BankAccount { get; set; } public bool StateOwned { get; set; } + + public IBankAccount GetBankAccount(DatabaseContext databaseContext = null) + { + if (databaseContext == null) + { + using (databaseContext = new DatabaseContext()) + { + return databaseContext.FactionBankAccounts.FirstOrDefault(u => u.FactionId == this.Id); + } + } + else + { + return databaseContext.FactionBankAccounts.FirstOrDefault(u => u.FactionId == this.Id); + } + } } } diff --git a/Server/Entities/FactionBankAccount.cs b/Server/Entities/FactionBankAccount.cs index 7abac2be..a4be3a30 100644 --- a/Server/Entities/FactionBankAccount.cs +++ b/Server/Entities/FactionBankAccount.cs @@ -13,7 +13,7 @@ using System.Text; */ namespace reallife_gamemode.Server.Entities { - public class FactionBankAccount + public class FactionBankAccount : IBankAccount { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] diff --git a/Server/Entities/News.cs b/Server/Entities/News.cs new file mode 100644 index 00000000..b88141b9 --- /dev/null +++ b/Server/Entities/News.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; + +namespace reallife_gamemode.Server.Entities +{ + public class News + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + + [ForeignKey("User")] + public int? UserId { get; set; } + public User User { get; set; } + + public string Caption { get; set; } + public string Content { get; set; } + public bool Active { get; set; } + public int Timestamp { get; set; } + } +} diff --git a/Server/Entities/User.cs b/Server/Entities/User.cs index 336cddc6..d42bf296 100644 --- a/Server/Entities/User.cs +++ b/Server/Entities/User.cs @@ -1,5 +1,6 @@ using GTANetworkAPI; using reallife_gamemode.Model; +using reallife_gamemode.Server.Extensions; using reallife_gamemode.Server.Util; using System; using System.Collections.Generic; @@ -16,7 +17,7 @@ using System.Text; namespace reallife_gamemode.Server.Entities { - public class User + public class User : IBankAccountOwner { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] @@ -28,8 +29,8 @@ namespace reallife_gamemode.Server.Entities [StringLength(64)] public string Password { get; set; } public int LogUserId { get; set; } - [Timestamp] - public byte[] RegistrationDate { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public DateTime RegistrationDate { get; set; } [EmailAddress] [StringLength(64)] @@ -122,12 +123,11 @@ namespace reallife_gamemode.Server.Entities { using (var unbanUser = new DatabaseContext()) { - var targetUser = unbanUser.Bans.FirstOrDefault(u => u.Id == BanId); - unbanUser.Bans.Remove(targetUser); + User user = admin.GetUser(); + var targetUser = unbanUser.Users.FirstOrDefault(u => u.Id == user.Id); + targetUser.BanId = null; unbanUser.SaveChanges(); } - admin.SendChatMessage(this.Name + " wurde entbannt."); - //TODO ***Admin Info: {ADMIN-NAME} hat {USER-NAME} entbannt. } public List GetItems() @@ -138,5 +138,20 @@ namespace reallife_gamemode.Server.Entities } } public bool IsAdmin(AdminLevel level) => AdminLevel >= level; + + public IBankAccount GetBankAccount(DatabaseContext databaseContext = null) + { + if (databaseContext == null) + { + using (databaseContext = new DatabaseContext()) + { + return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id); + } + } + else + { + return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id); + } + } } } diff --git a/Server/Entities/UserBankAccount.cs b/Server/Entities/UserBankAccount.cs index 12d532d8..4efcfbc3 100644 --- a/Server/Entities/UserBankAccount.cs +++ b/Server/Entities/UserBankAccount.cs @@ -17,8 +17,9 @@ using System.Linq; namespace reallife_gamemode.Server.Entities { - public class UserBankAccount + public class UserBankAccount : IBankAccount { + [NotMapped] private int _balance; [Key] @@ -38,7 +39,7 @@ namespace reallife_gamemode.Server.Entities _balance = value; using(var dbContext = new DatabaseContext()) { - ClientService.GetClientByName(dbContext.Users.First(u => u.Id == UserId).Name).TriggerEvent("updateMoney", value); + ClientService.GetClientByNameOrId(dbContext.Users.First(u => u.Id == UserId).Name).TriggerEvent("updateMoney", value); } } } diff --git a/Server/Events/Chat.cs b/Server/Events/Chat.cs new file mode 100644 index 00000000..42cfe262 --- /dev/null +++ b/Server/Events/Chat.cs @@ -0,0 +1,13 @@ +using GTANetworkAPI; + +namespace reallife_gamemode.Server.Events +{ + public class Chat : Script + { + [ServerEvent(Event.ChatMessage)] + public void ChatEvent(Client player, string message) + { + NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p => p.SendChatMessage($"{player.Name} sagt: {message}")); + } + } +} \ No newline at end of file diff --git a/Server/Events/Connect.cs b/Server/Events/Connect.cs index 95135938..5c7ac1df 100644 --- a/Server/Events/Connect.cs +++ b/Server/Events/Connect.cs @@ -27,10 +27,7 @@ namespace reallife_gamemode.Server.Events "datgame_", "xSprite", "xPrike", - "balboistderbeste", "xNccPlay", - "Marvino01" - }; @@ -76,7 +73,7 @@ namespace reallife_gamemode.Server.Events if (bannedUser.Applied == bannedUser.UntilDateTime) { player.SendChatMessage("!{#FF4040}Du wurdest permanent gebannt! [" + bannedUser.Reason + "]"); - //player.Kick(); + player.Kick(); } else { @@ -86,14 +83,14 @@ namespace reallife_gamemode.Server.Events if(timeStamp > unixTimestamp) { player.SendChatMessage("Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]"); + player.Kick(); } else { - player.GetUser().BanId = null; + user.BanId = null; loginUser.SaveChanges(); player.TriggerEvent("showLogin"); - } - //player.Kick(); + } } } else player.TriggerEvent("showLogin"); diff --git a/Server/Events/Key.cs b/Server/Events/Key.cs index cbe9e732..7d3a56c6 100644 --- a/Server/Events/Key.cs +++ b/Server/Events/Key.cs @@ -1,8 +1,15 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using GTANetworkAPI; using Newtonsoft.Json; +using reallife_gamemode.Model; +using reallife_gamemode.Server.Entities; +using reallife_gamemode.Server.Extensions; +using reallife_gamemode.Server.Managers; +using reallife_gamemode.Server.Saves; +using reallife_gamemode.Server.Services; using reallife_gamemode.Server.Util; /** * @overview Life of German Reallife - Event Key (Key.cs) @@ -14,6 +21,81 @@ namespace reallife_gamemode.Server.Events { public class Key : Script { + [RemoteEvent("keyPress:NUM2")] + public void KeyPressNUM2(Client player) + { + if(player.GetData("editmode") == true && player.GetUser().IsAdmin(AdminLevel.HEADADMIN) == true) + { + TempBlip tempBlip = NAPI.Data.GetWorldData("blipTemplate"); + SaveManager.OnSaveBlipData(player, tempBlip.Sprite.ToString(), tempBlip.Name, tempBlip.Scale.ToString(), tempBlip.Color.ToString(), + tempBlip.Transparency.ToString(), 200.ToString(), tempBlip.ShortRange.ToString(), 0.ToString(), 0.ToString()); + player.SendNotification("~y~Blip~s~ erstellt!", false); + } + } + [RemoteEvent("keyPress:E")] + public void KeyPressE(Client player) + { + var user = player.GetUser(); + if (user?.FactionId != null) + { + DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5); + if (nearest == null) return; + if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId) + { + var nameTagColor = new Color(0, 0, 0); + var factionId = user.FactionId; + + if (player.GetData("duty") == false) + { + player.SetData("duty", true); + player.SendNotification("Du bist nun ~g~im Dienst."); + if (player.GetUser().FactionId == 2) //Fire Department + { + NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", true); + } + switch (factionId) + { + //LSPD + case 1: + nameTagColor = new Color(28, 134, 238); + break; + } + player.NametagColor = nameTagColor; + using (var context = new DatabaseContext()) + { + List clothes = context.CharacterClothes.ToList().FindAll(u => u.UserId == user.Id && u.Duty == true); + + foreach(var cloth in clothes) + { + if(cloth.SlotType == 0) + { + player.SetClothes(cloth.SlotId, cloth.ClothId, 0); + } + else + { + if(cloth.ClothId != -1) + { + player.SetAccessories(cloth.SlotId, cloth.ClothId, 0); + } + else + { + player.ClearAccessory(cloth.SlotId); + } + } + } + } + } + else + { + player.SetData("duty", false); + player.SendNotification("Du bist nun ~r~außer Dienst."); + NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false); + player.NametagColor = new Color(255, 255, 255); + UpdateCharacterCloth.LoadCharacterDefaults(player); + } + } + } + } [RemoteEvent("keyPress:I")] public void KeyPressI(Client player) { @@ -31,36 +113,78 @@ namespace reallife_gamemode.Server.Events } player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(ListPlayers)); } + [RemoteEvent("keyPress:K")] + public void KeyPressK(Client player) + { + var user = player.GetUser(); + if (user?.FactionId != null) + { + DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5); + if (nearest == null) return; + if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId) + { + List hats = new List(); + List tops = new List(); + List legs = new List(); + List shoes = new List(); + + using (var context = new DatabaseContext()) + { + List clothes = context.DutyClothes.ToList().FindAll(c => c.FactionId == user.FactionId && c.Gender == user.GetCharacter().Gender); + foreach(var cloth in clothes) + { + if(cloth.SlotType == 1) + { + if (cloth.ClothId != -1) + { + hats.Add(cloth.ClothId.ToString()); + } + else + { + hats.Add("Keinen"); + } + continue; + } + + switch (cloth.SlotId) + { + case 11: + tops.Add(cloth.ClothId.ToString()); + break; + case 4: + legs.Add(cloth.ClothId.ToString()); + break; + case 6: + shoes.Add(cloth.ClothId.ToString()); + break; + } + } + } + player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray()); + } + } + + } + [RemoteEvent("keyPress:L")] + public void KeyPressL(Client player) + { + DoorManager.ChangeDoorState(player); + } [RemoteEvent("keyPress:N")] public void KeyPressN(Client player) { - if (NAPI.Player.IsPlayerInAnyVehicle(player)) + if (player.IsInVehicle && player.VehicleSeat == -1) { - bool engineStatus = NAPI.Vehicle.GetVehicleEngineStatus(player.Vehicle); - if (engineStatus == false) - { - player.Vehicle.EngineStatus = true; - } - else - { - player.Vehicle.EngineStatus = false; - } + player.Vehicle.EngineStatus = !player.Vehicle.EngineStatus; } } [RemoteEvent("keyPress:X")] public void KeyPressX(Client player) { - if (NAPI.Player.IsPlayerInAnyVehicle(player)) + if (player.IsInVehicle) { - if (player.Seatbelt == false) - { - player.Seatbelt = true; - } - else - { - player.Seatbelt = false; - } + player.Seatbelt = !player.Seatbelt; } - } + } } } diff --git a/Server/Events/Login.cs b/Server/Events/Login.cs index 7945cdf2..5f165c59 100644 --- a/Server/Events/Login.cs +++ b/Server/Events/Login.cs @@ -48,6 +48,11 @@ namespace reallife_gamemode.Server.Events player.SetData("spec", true); player.SetData("duty", false); + if(user.IsAdmin(AdminLevel.HEADADMIN) == true) + { + player.SetData("editmode", false); + } + var userBankAccount = loginUser.UserBankAccounts.SingleOrDefault(u => u.UserId == user.Id); userBankAccount.Balance = userBankAccount.Balance; @@ -66,8 +71,9 @@ namespace reallife_gamemode.Server.Events else { CharacterCreator.ApplyCharacter(player); + UpdateCharacterCloth.LoadCharacterDefaults(player); NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0); - player.TriggerEvent("draw", player.Name, player.Handle.Value); + player.TriggerEvent("draw", player.Name, player.Handle.Value); } if (user.Dead == true) { diff --git a/Server/Events/UpdateCharacterCloth.cs b/Server/Events/UpdateCharacterCloth.cs new file mode 100644 index 00000000..7e646a41 --- /dev/null +++ b/Server/Events/UpdateCharacterCloth.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GTANetworkAPI; +using Newtonsoft.Json; +using reallife_gamemode.Model; +using reallife_gamemode.Server.Entities; +using reallife_gamemode.Server.Extensions; + +namespace reallife_gamemode.Server.Events +{ + public class UpdateCharacterCloth : Script + { + [RemoteEvent("updateDutyProp")] + public void UpdateDutyProp(Client player, int componentId, int componentVariation) + { + if (componentId != -1) + { + player.SetAccessories(componentId, componentVariation, 0); + } + else + { + player.ClearAccessory(0); + } + + } + + [RemoteEvent("updateDutyCloth")] + public void UpdateDutyCloth(Client player, int componentId, int componentVariation) + { + if (componentId == 11) + { + //TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL) + using (var context = new DatabaseContext()) + { + var character = player.GetUser().GetCharacter(); + + var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender); + player.SetClothes(11, componentVariation, 0); + if (combination != null) + { + player.SetClothes(3, combination.Torso, 0); + player.SetClothes(8, combination.Undershirt, 0); + } + } + } + else + { + player.SetClothes(componentId, componentVariation, 0); + } + } + + [RemoteEvent("saveCharacterCloth")] + public void SaveDutyCloth(Client client, string JSlotType, string JSlotId, string JClothId) + { + using (var context = new DatabaseContext()) + { + int[] slotType = JsonConvert.DeserializeObject(JSlotType); + int[] slotId = JsonConvert.DeserializeObject(JSlotId); + int[] clothId = JsonConvert.DeserializeObject(JClothId); + + User user = client.GetUser(); + user = context.Users.FirstOrDefault(u => u.Id == user.Id); + + var character = client.GetUser().GetCharacter(); + + var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id); + if (charClothes == null) + { + for (var x = 0; x < slotType.Length; x++) + { + CharacterCloth newCloth = new CharacterCloth + { + UserId = user.Id, + + Duty = true, + + SlotType = (byte)slotType[x], + SlotId = slotId[x], + ClothId = clothId[x] + }; + context.CharacterClothes.Add(newCloth); + } + if (user.GetCharacter().Gender == false) + { + CharacterCloth newTorso = new CharacterCloth + { + UserId = user.Id, + + Duty = true, + + SlotType = 0, + SlotId = 3, + ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso + }; + CharacterCloth newUndershirt = new CharacterCloth + { + UserId = user.Id, + + Duty = true, + + SlotType = 0, + SlotId = 8, + ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt + }; + context.CharacterClothes.Add(newTorso); + context.CharacterClothes.Add(newUndershirt); + } + } + else + { + for (var x = 0; x < slotType.Length; x++) + { + var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]); + loopCloth.ClothId = clothId[x]; + } + CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3); + CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8); + + torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso; + undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt; + } + context.SaveChanges(); + } + LoadCharacterDefaults(client); + } + + [RemoteEvent("defaultCharacterCloth")] + public static void LoadCharacterDefaults(Client player) + { + User user = player.GetUser(); + using (var context = new DatabaseContext()) + { + List charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false); + player.ClearAccessory(0); + player.ClearAccessory(1); + player.ClearAccessory(2); + player.ClearAccessory(6); + player.ClearAccessory(7); + + foreach (var cloth in charClothes) + { + if(cloth.SlotType == 1) + { + player.SetAccessories(cloth.SlotId, cloth.ClothId, 0); + } + else + { + player.SetClothes(cloth.SlotId, cloth.ClothId, 0); + } + } + } + } + } +} \ No newline at end of file diff --git a/Server/Extensions/AdminLevelExtension.cs b/Server/Extensions/AdminLevelExtension.cs new file mode 100644 index 00000000..fcca308a --- /dev/null +++ b/Server/Extensions/AdminLevelExtension.cs @@ -0,0 +1,35 @@ +using reallife_gamemode.Server.Util; +using static reallife_gamemode.Server.Util.AdminLevel; +using System; +using System.Collections.Generic; +using System.Text; + +namespace reallife_gamemode.Server.Extensions +{ + public static class AdminLevelExtension + { + /// + /// Gibt den richtigen Namen eines Admin Levels zurück + /// + /// Das Admin Level, dessen Namen man bekommen möchte + /// + public static string GetName(this AdminLevel level) + { + switch(level) + { + case SUPPORTER: + return "Supporter"; + case ADMIN: + case ADMIN2: + case ADMIN3: + return "Admin"; + case HEADADMIN: + return "Headadmin"; + case PROJEKTLEITUNG: + return "Projektleiter"; + default: + return "Spieler"; + } + } + } +} diff --git a/Server/Extensions/ClientExtension.cs b/Server/Extensions/ClientExtension.cs index 354086f3..a7334ff6 100644 --- a/Server/Extensions/ClientExtension.cs +++ b/Server/Extensions/ClientExtension.cs @@ -19,6 +19,13 @@ namespace reallife_gamemode.Server.Extensions { public static class ClientExtension { + /// + /// Gibt das User-Objekt eines Client's zurück. + /// Gibt nichts zurück, wenn der Client nicht eingeloggt ist + /// + /// Der Client, dessen User man bekommen möchte + /// Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will + /// public static User GetUser(this Client client, DatabaseContext context = null) { if (!client.IsLoggedIn()) return null; @@ -35,6 +42,26 @@ namespace reallife_gamemode.Server.Extensions } } + public static Character GetCharacter(this User user, DatabaseContext context = null) + { + if (context == null) + { + using (context = new DatabaseContext()) + { + return context.Characters.FirstOrDefault(u => u.UserId == user.Id); + } + } + else + { + return context.Characters.FirstOrDefault(u => u.UserId == user.Id); + } + } + + /// + /// Gibt zurück, ob ein Client eingeloggt ist + /// + /// Der Client, dessen Login-Status man bekommen möchte + /// public static bool IsLoggedIn(this Client player) { return player.HasData("isLoggedIn") ? player.GetData("isLoggedIn") : false; diff --git a/Server/Extensions/FactionExtension.cs b/Server/Extensions/FactionExtension.cs deleted file mode 100644 index b5ca655a..00000000 --- a/Server/Extensions/FactionExtension.cs +++ /dev/null @@ -1,35 +0,0 @@ -using GTANetworkAPI; -using Microsoft.EntityFrameworkCore; -using reallife_gamemode.Model; -using reallife_gamemode.Server.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -/** -* @overview Life of German Reallife - Faction Extension (FactionExtension.cs) -* @author VegaZ -* @copyright (c) 2008 - 2018 Life of German -*/ - -namespace reallife_gamemode.Server.Extensions -{ - public static class FactionExtension - { - public static FactionBankAccount GetFactionBankAccount(this Faction faction, DatabaseContext context = null) - { - if (context == null) - { - using (context = new DatabaseContext()) - { - return context.FactionBankAccounts.FirstOrDefault(u => u.FactionId == faction.Id); - } - } - else - { - return context.FactionBankAccounts.FirstOrDefault(u => u.FactionId == faction.Id); - } - } - } -} diff --git a/Server/Extensions/UserExtension.cs b/Server/Extensions/UserExtension.cs deleted file mode 100644 index 005b2415..00000000 --- a/Server/Extensions/UserExtension.cs +++ /dev/null @@ -1,49 +0,0 @@ -using GTANetworkAPI; -using Microsoft.EntityFrameworkCore; -using reallife_gamemode.Model; -using reallife_gamemode.Server.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -/** -* @overview Life of German Reallife - User Extension (UserExtension.cs) -* @author VegaZ -* @copyright (c) 2008 - 2018 Life of German -*/ - -namespace reallife_gamemode.Server.Extensions -{ - public static class UserExtension - { - public static UserBankAccount GetUserBankAccount(this User user, DatabaseContext context = null) - { - if (context == null) - { - using (context = new DatabaseContext()) - { - return context.UserBankAccounts.FirstOrDefault(u => u.UserId == user.Id); - } - } - else - { - return context.UserBankAccounts.FirstOrDefault(u => u.UserId == user.Id); - } - } - public static Character GetUserCharacter(this User user, DatabaseContext context = null) - { - if (context == null) - { - using (context = new DatabaseContext()) - { - return context.Characters.FirstOrDefault(u => u.UserId == user.Id); - } - } - else - { - return context.Characters.FirstOrDefault(u => u.UserId == user.Id); - } - } - } -} diff --git a/Server/Extensions/VehicleExtension.cs b/Server/Extensions/VehicleExtension.cs index c572dd1b..7a6e9886 100644 --- a/Server/Extensions/VehicleExtension.cs +++ b/Server/Extensions/VehicleExtension.cs @@ -18,6 +18,11 @@ namespace reallife_gamemode.Server.Extensions { public static class VehicleExtension { + /// + /// Gibt zurück, ob das Vehicle ein Fraktions-Fahrzeug ist + /// + /// Das Vehicle, von dem man wissen möchte, ob es ein Fraktionsfahrzeug ist + /// public static bool IsFactionVehicle(this Vehicle vehicle) { return LoadManager.FactionVehicleList.Contains(vehicle); diff --git a/Server/Logs/BankAccountTransactionHistory.cs b/Server/Logs/BankAccountTransactionHistory.cs index 425d324f..88146e6f 100644 --- a/Server/Logs/BankAccountTransactionHistory.cs +++ b/Server/Logs/BankAccountTransactionHistory.cs @@ -30,7 +30,7 @@ namespace reallife_gamemode.Server.Logs public int Fee { get; set; } [StringLength(32)] public string Origin { get; set; } - [Timestamp] - public byte[] Timestamp { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public DateTime Timestamp { get; set; } } } diff --git a/Server/Logs/Death.cs b/Server/Logs/Death.cs index b9f48eb3..95d2bb21 100644 --- a/Server/Logs/Death.cs +++ b/Server/Logs/Death.cs @@ -39,7 +39,7 @@ namespace reallife_gamemode.Server.Logs [StringLength(64)] public string CauseOfDeath { get; set; } - [Timestamp] - public byte[] Timestamp { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public DateTime Timestamp { get; set; } } } diff --git a/Server/Managers/.gitkeep b/Server/Managers/.gitkeep deleted file mode 100644 index 5f282702..00000000 --- a/Server/Managers/.gitkeep +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Server/Managers/BankManager.cs b/Server/Managers/BankManager.cs index d070da45..4d4b1d77 100644 --- a/Server/Managers/BankManager.cs +++ b/Server/Managers/BankManager.cs @@ -5,6 +5,7 @@ using System.Text; using GTANetworkAPI; using reallife_gamemode.Server.Entities; using reallife_gamemode.Server.Extensions; +using reallife_gamemode.Server.Util; /** * @overview Life of German Reallife - Managers BankManager (BankManager.cs) @@ -17,99 +18,42 @@ namespace reallife_gamemode.Server.Managers { public class BankManager : Script { - public static void TransferUserMoneyToUser(User sender, User receiver, int amount, string origin) + public static TransactionResult TransferMoney(IBankAccountOwner sender, IBankAccountOwner receiver, int amount, string origin) { using (var transferMoney = new Model.DatabaseContext()) { + if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT; + + IBankAccount senderAccount = sender.GetBankAccount(transferMoney); + IBankAccount receiverAccount = receiver.GetBankAccount(transferMoney); + + if (senderAccount == null) return TransactionResult.SENDER_NO_BANKACCOUNT; + if (receiverAccount == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT; + + if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY; + var transactionLog = new Logs.BankAccountTransactionHistory { Sender = sender.Name, - SenderBalance = sender.GetUserBankAccount().Balance, - MoneySent = amount, + SenderBalance = senderAccount.Balance, Receiver = receiver.Name, - ReceiverBalance = receiver.GetUserBankAccount().Balance, - NewReceiverBalance = receiver.GetUserBankAccount().Balance + amount, - NewSenderBalance = sender.GetUserBankAccount().Balance - amount, + ReceiverBalance = receiverAccount.Balance, + NewReceiverBalance = receiverAccount.Balance + amount, + NewSenderBalance = senderAccount.Balance - amount, + MoneySent = amount, Fee = 0, Origin = origin }; + // add log transferMoney.BankAccountTransactionLogs.Add(transactionLog); - sender.GetUserBankAccount(transferMoney).Balance -= amount; - receiver.GetUserBankAccount(transferMoney).Balance += amount; + + senderAccount.Balance -= amount; + receiverAccount.Balance += amount; + transferMoney.SaveChanges(); - } - } - public static void TransferUserMoneyToFaction(User sender, Faction receiver, int amount, string origin) - { - using (var transferMoney = new Model.DatabaseContext()) - { - var transactionLog = new Logs.BankAccountTransactionHistory - { - Sender = sender.Name, - SenderBalance = sender.GetUserBankAccount().Balance, - MoneySent = amount, - Receiver = receiver.Name, - ReceiverBalance = receiver.BankAccount, - NewReceiverBalance = receiver.BankAccount + amount, - NewSenderBalance = sender.GetUserBankAccount().Balance - amount, - Fee = 0, - Origin = origin - }; - - transferMoney.BankAccountTransactionLogs.Add(transactionLog); - sender.GetUserBankAccount(transferMoney).Balance -= amount; - receiver.BankAccount += amount; - transferMoney.SaveChanges(); - } - } - - public static void TransferFactionMoneyToUser(Faction sender, User receiver, int amount, string origin) - { - using (var transferMoney = new Model.DatabaseContext()) - { - var transactionLog = new Logs.BankAccountTransactionHistory - { - Sender = sender.Name, - SenderBalance = sender.BankAccount, - MoneySent = amount, - Receiver = receiver.Name, - ReceiverBalance = receiver.GetUserBankAccount().Balance, - NewReceiverBalance = receiver.GetUserBankAccount().Balance + amount, - NewSenderBalance = sender.BankAccount - amount, - Fee = 0, - Origin = origin - }; - - transferMoney.BankAccountTransactionLogs.Add(transactionLog); - sender.BankAccount -= amount; - receiver.GetUserBankAccount(transferMoney).Balance += amount; - transferMoney.SaveChanges(); - } - } - - public static void TransferFactionMoneyToFaction(Faction sender, Faction receiver, int amount, string origin) - { - using (var transferMoney = new Model.DatabaseContext()) - { - var transactionLog = new Logs.BankAccountTransactionHistory - { - Sender = sender.Name, - SenderBalance = sender.GetFactionBankAccount().Balance, - MoneySent = amount, - Receiver = receiver.Name, - ReceiverBalance = receiver.BankAccount, - NewReceiverBalance = receiver.BankAccount + amount, - NewSenderBalance = sender.BankAccount - amount, - Fee = 0, - Origin = origin - }; - - transferMoney.BankAccountTransactionLogs.Add(transactionLog); - sender.BankAccount -= amount; - receiver.BankAccount += amount; - transferMoney.SaveChanges(); + return TransactionResult.SUCCESS; } } } diff --git a/Server/Managers/CharacterCreator.cs b/Server/Managers/CharacterCreator.cs index d5c4518d..caf1b351 100644 --- a/Server/Managers/CharacterCreator.cs +++ b/Server/Managers/CharacterCreator.cs @@ -179,6 +179,10 @@ namespace reallife_gamemode.Server.Managers player.Dimension = 0; } + /// + /// Wendet den Character eines Spielers auf diesen an + /// + /// Der Client, dessen Aussehen man setzen will public static void ApplyCharacter(Client player) { var userId = player.GetUser().Id; diff --git a/Server/Managers/DoorManager.cs b/Server/Managers/DoorManager.cs new file mode 100644 index 00000000..4fe0f3fb --- /dev/null +++ b/Server/Managers/DoorManager.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GTANetworkAPI; +using reallife_gamemode.Model; +using reallife_gamemode.Server.Entities; +using reallife_gamemode.Server.Extensions; +using reallife_gamemode.Server.Util; +/** +* @overview Life of German Reallife - Managers BankManager (BankManager.cs) +* @author VegaZ +* @copyright (c) 2008 - 2018 Life of German +*/ + +namespace reallife_gamemode.Server.Managers +{ + public class DoorManager : Script + { + public static void ChangeDoorState(Client player) + { + List NearDoors = new List(); + var user = player.GetUser(); + + using (var saveDoor = new DatabaseContext()) + { + NearDoors = saveDoor.Doors.ToList().FindAll(d => new Vector3(d.X, d.Y, d.Z).DistanceTo(player.Position) <= d.Radius); + foreach (Door d in NearDoors) + { + Door currentDoor = saveDoor.Doors.FirstOrDefault(c => c.Id == d.Id); + + if(!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null)) + { + string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!"; + player.SendNotification(lockState, true); + continue; + } + + currentDoor.Locked = !currentDoor.Locked; + + string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen"; + + player.SendNotification(notStr, true); + + NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (currentDoor.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f)); + } + saveDoor.SaveChanges(); + } + } + } +} diff --git a/Server/Managers/LoadManager.cs b/Server/Managers/LoadManager.cs index d412ed02..b97c8f48 100644 --- a/Server/Managers/LoadManager.cs +++ b/Server/Managers/LoadManager.cs @@ -20,7 +20,6 @@ namespace reallife_gamemode.Server.Managers public static List ShopVehicleList = new List(); public static List UserVehicleList = new List(); - [ServerEvent(Event.ResourceStart)] public void OnResourceStart() { @@ -69,7 +68,7 @@ namespace reallife_gamemode.Server.Managers NAPI.Vehicle.SetVehicleEngineHealth(current, 0); var tLabel = NAPI.TextLabel.CreateTextLabel(v.ModelName + " | " + v.Price + "~g~$", new Vector3(v.PositionX, v.PositionY, v.PositionZ + 1.5), 10, 1, 0, new Color(255, 255, 255), false, v.Dimension); current.SetData("shopVehicleId", v.Id); - tLabel.AttachTo(current, "SKEL_ROOT", new Vector3(v.PositionX, v.PositionY, v.PositionZ + 1.5), new Vector3(0, 0, 0)); + tLabel.AttachTo(current, "chassis", new Vector3(0, 0, 1.5), new Vector3(0, 0, 0)); } } foreach (UserVehicle v in loadData.UserVehicles) diff --git a/Server/Managers/PositionManager.cs b/Server/Managers/PositionManager.cs new file mode 100644 index 00000000..b319eee0 --- /dev/null +++ b/Server/Managers/PositionManager.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; +using reallife_gamemode.Server.Entities; + +namespace reallife_gamemode.Server.Managers +{ + public class PositionManager : Script + { + public static List DutyPoints = new List(); + public static List DutyColShapes = new List(); + + [ServerEvent(Event.ResourceStart)] + public void OnResourceStart() + { + DutyPoint dutyPointLSPD = new DutyPoint() + { + Position = new Vector3(458.24, -990.86, 30.68), + FactionId = 1 + }; + + DutyPoints.Add(dutyPointLSPD); + + foreach (DutyPoint d in DutyPoints) + { + NAPI.Marker.CreateMarker(1, new Vector3(d.Position.X, d.Position.Y, d.Position.Z - 2), new Vector3(d.Position.X, d.Position.Y, d.Position.Z + 1), + new Vector3(0,0,0), 3, new Color(255, 255, 255, 50), false, 0); + NAPI.TextLabel.CreateTextLabel("Stempeluhr - Dr\u00fccke ~y~E\n~s~Dienstkleidung - Dr\u00fccke ~y~K", d.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); + } + } + } + + public class DutyPoint + { + public Vector3 Position { get; set; } + public int FactionId { get; set; } + } + +} + diff --git a/Server/Managers/SaveManager.cs b/Server/Managers/SaveManager.cs index 8a4f4c27..686412fb 100644 --- a/Server/Managers/SaveManager.cs +++ b/Server/Managers/SaveManager.cs @@ -11,7 +11,7 @@ namespace reallife_gamemode.Server.Events public class SaveManager : Script { [RemoteEvent("OnSaveBlipData")] - public void OnSaveBlipData(Client player, string blipSprite, string blipName, string blipScale, string blipColor, + public static void OnSaveBlipData(Client player, string blipSprite, string blipName, string blipScale, string blipColor, string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension) { float x = player.Position.X; @@ -162,7 +162,7 @@ namespace reallife_gamemode.Server.Events foreach (Vehicle v in LoadManager.FactionVehicleList) { int factionId = v.GetData("factionId"); - Entities.UserVehicle factionVehicle = saveAll.UserVehicles.FirstOrDefault(u => u.UserId == factionId); + Entities.FactionVehicle factionVehicle = saveAll.FactionVehicles.FirstOrDefault(u => u.FactionId == factionId); factionVehicle.PositionX = v.Position.X; factionVehicle.PositionY = v.Position.Y; factionVehicle.PositionZ = v.Position.Z; diff --git a/Server/Managers/TuningManager.cs b/Server/Managers/TuningManager.cs index f2c73e73..7d209b9b 100644 --- a/Server/Managers/TuningManager.cs +++ b/Server/Managers/TuningManager.cs @@ -7,15 +7,19 @@ namespace reallife_gamemode.Server.Managers { private static List tuningGarages = new List(); - public static void AddTuningGarage(Vector3 pos1, Vector3 pos2) + /// + /// Fügt eine Tuning-Garage zum Spiel hinzu + /// + /// Die Position der Garage + public static void AddTuningGarage(Vector3 pos) { - ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos1, 10, 0); + ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos, 10, 0); colShape.OnEntityEnterColShape += (cs, c) => { if(c.IsInVehicle) { - c.TriggerEvent("showTuningInfo"); + c.TriggerEvent("showTuningInfo", c.GetData("duty")); } }; diff --git a/Server/Saves/SavedBlip.cs b/Server/Saves/SavedBlip.cs index f7b14343..8080ca21 100644 --- a/Server/Saves/SavedBlip.cs +++ b/Server/Saves/SavedBlip.cs @@ -35,4 +35,14 @@ namespace reallife_gamemode.Server.Saves public byte Dimension { get; set; } public bool Active { get; set; } } + + public class TempBlip + { + public byte Color { get; set; } + public string Name { get; set; } + public byte Transparency { get; set; } + public bool ShortRange { get; set; } + public uint Sprite { get; set; } + public float Scale { get; set; } + } } diff --git a/Server/Services/ChatService.cs b/Server/Services/ChatService.cs index b9d98f93..ad742b97 100644 --- a/Server/Services/ChatService.cs +++ b/Server/Services/ChatService.cs @@ -37,6 +37,11 @@ namespace reallife_gamemode.Server.Services player.SendChatMessage("~r~[FEHLER]~s~ Die Aktion wurde nicht ausgeführt."); } + /// + /// Sendet eine Nachricht an eine Liste von Fraktionen + /// + /// Die Nachricht, die gesendet werden soll + /// Die Liste an Fraktionen, die diese Nachricht bekommen sollen public static void BroadcastFaction(string message, List factions) { foreach (Client c in NAPI.Pools.GetAllPlayers()) @@ -52,11 +57,21 @@ namespace reallife_gamemode.Server.Services } } + /// + /// Sendet eine Nachricht an eine Fraktion + /// + /// Die Nachricht, die gesendet werden soll + /// Die Fraktion, die diese Nachricht bekommen soll public static void BroadcastFaction(string message, Faction f) { BroadcastFaction(message, new List() { f }); } + /// + /// Sendet eine Nachricht an alle Spieler mit einem bestimmten Admin Level + /// + /// Die Nachricht, die gesendet werden soll + /// Das mindest Admin Level, das für das Erhalten dieser Nachricht benötigt wird public static void BroadcastAdmin(string message, AdminLevel minLevel) { NAPI.Pools.GetAllPlayers().ForEach(p => diff --git a/Server/Services/ClientService.cs b/Server/Services/ClientService.cs index 2cd766f9..7b668770 100644 --- a/Server/Services/ClientService.cs +++ b/Server/Services/ClientService.cs @@ -13,29 +13,29 @@ namespace reallife_gamemode.Server.Services { class ClientService { - public static Client GetClientByName(string name) + /// + /// Gibt einen Client anhand seines Namens oder der ID zurück + /// + /// Die ID oder der Name, nach dem gesucht werden soll + /// + public static Client GetClientByNameOrId(string nameOrId) { - /* Funktionsaufbau: Prüft erst, ob ein Spieler mit exakt diesem Namen online ist - * Wenn Ja: Wird dieser zurückgegeben - * Wenn Nein: Wird der erste Spieler zurückgegeben, dessen Namen mit dem eingegebenen Parameter übereinstimmt - * Gibt "null" zurück, falls kein Client gefunden wurde - */ Client toReturn = null; - name = name.ToLower(); + nameOrId = nameOrId.ToLower(); List playerList = NAPI.Pools.GetAllPlayers(); - if(int.TryParse(name, out int id)) + if(int.TryParse(nameOrId, out int id)) { toReturn = playerList.Find(p => p.Handle.Value == id); return toReturn; } - toReturn = playerList.Find(p => p.Name.ToLower() == name); + toReturn = playerList.Find(p => p.Name.ToLower() == nameOrId); if(toReturn == null) { - toReturn = playerList.Find(p => p.Name.ToLower().StartsWith(name)); + toReturn = playerList.Find(p => p.Name.ToLower().StartsWith(nameOrId)); } return toReturn; diff --git a/Server/Util/AdminLevel.cs b/Server/Util/AdminLevel.cs index 37be0ba7..3ef29297 100644 --- a/Server/Util/AdminLevel.cs +++ b/Server/Util/AdminLevel.cs @@ -12,8 +12,12 @@ namespace reallife_gamemode.Server.Util { public enum AdminLevel : int { - PLAYER, - SUPPORTER, - ADMIN + PLAYER = 0, + SUPPORTER = 1, + ADMIN = 2, + ADMIN2 = 3, + ADMIN3 = 4, + HEADADMIN = 1337, + PROJEKTLEITUNG = 1338 } } diff --git a/Server/Util/Converter.cs b/Server/Util/Converter.cs new file mode 100644 index 00000000..6bc4d355 --- /dev/null +++ b/Server/Util/Converter.cs @@ -0,0 +1,40 @@ +using GTANetworkAPI; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; + +namespace reallife_gamemode.Server.Util +{ + public class Converter + { + public static Color HexToColor(string hexColor) + { + //Remove # if present + if (hexColor.IndexOf('#') != -1) + hexColor = hexColor.Replace("#", ""); + + int red = 0; + int green = 0; + int blue = 0; + + if (hexColor.Length == 6) + { + //#RRGGBB + red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier); + green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier); + blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier); + } + else if (hexColor.Length == 3) + { + //#RGB + red = int.Parse(hexColor[0].ToString() + hexColor[0].ToString(), NumberStyles.AllowHexSpecifier); + green = int.Parse(hexColor[1].ToString() + hexColor[1].ToString(), NumberStyles.AllowHexSpecifier); + blue = int.Parse(hexColor[2].ToString() + hexColor[2].ToString(), NumberStyles.AllowHexSpecifier); + } + + Color returnColor = new Color(red, green, blue); + return returnColor; + } + } +} diff --git a/Server/Util/DatabaseHelper.cs b/Server/Util/DatabaseHelper.cs new file mode 100644 index 00000000..e049fcee --- /dev/null +++ b/Server/Util/DatabaseHelper.cs @@ -0,0 +1,22 @@ +using GTANetworkAPI; +using reallife_gamemode.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace reallife_gamemode.Server.Util +{ + class DatabaseHelper + { + public static void InitDatabaseFirstTime() + { + NAPI.Util.ConsoleOutput("Initializing database..."); + using(var dbContext = new DatabaseContext()) + { + dbContext.Users.First(); + dbContext.SaveChanges(); + } + } + } +} diff --git a/Server/Util/FactionHelper.cs b/Server/Util/FactionHelper.cs new file mode 100644 index 00000000..daf93237 --- /dev/null +++ b/Server/Util/FactionHelper.cs @@ -0,0 +1,37 @@ +using GTANetworkAPI; +using reallife_gamemode.Model; +using reallife_gamemode.Server.Entities; +using System; +using System.Collections.Generic; +using System.Text; + +namespace reallife_gamemode.Server.Util +{ + class FactionHelper + { + public static void CheckFactionBankAccounts() + { + NAPI.Util.ConsoleOutput("Checking faction bank accounts..."); + using(var dbContext = new DatabaseContext()) + { + foreach(Faction faction in dbContext.Factions) + { + if(faction.GetBankAccount(dbContext) == null) + { + NAPI.Util.ConsoleOutput("Adding bank account for faction: " + faction.Name); + FactionBankAccount factionBankAccount = new FactionBankAccount() + { + Balance = 0, + Bic = "", + Iban = "", + FactionId = faction.Id, + Active = true + }; + dbContext.FactionBankAccounts.Add(factionBankAccount); + } + } + dbContext.SaveChanges(); + } + } + } +} diff --git a/Server/Util/IBankAccount.cs b/Server/Util/IBankAccount.cs new file mode 100644 index 00000000..4a8b4a2c --- /dev/null +++ b/Server/Util/IBankAccount.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace reallife_gamemode.Server.Util +{ + public interface IBankAccount + { + int Balance { get; set; } + } +} diff --git a/Server/Util/IBankAccountOwner.cs b/Server/Util/IBankAccountOwner.cs new file mode 100644 index 00000000..a13c7969 --- /dev/null +++ b/Server/Util/IBankAccountOwner.cs @@ -0,0 +1,14 @@ +using reallife_gamemode.Model; +using System; +using System.Collections.Generic; +using System.Text; + +namespace reallife_gamemode.Server.Util +{ + public interface IBankAccountOwner + { + string Name { get; } + + IBankAccount GetBankAccount(DatabaseContext databaseContext = null); + } +} diff --git a/Server/Util/TransactionResult.cs b/Server/Util/TransactionResult.cs new file mode 100644 index 00000000..7ce9b001 --- /dev/null +++ b/Server/Util/TransactionResult.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace reallife_gamemode.Server.Util +{ + public enum TransactionResult + { + SUCCESS, + SENDER_NO_BANKACCOUNT, + RECEIVER_NO_BANKACCOUNT, + SENDER_NOT_ENOUGH_MONEY, + NEGATIVE_MONEY_SENT + } +} diff --git a/build.csproj b/build.csproj deleted file mode 100644 index 3d263cde..00000000 --- a/build.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - netcoreapp2.0 - reallife_gamemode - true - true - true - - - - Always - - - - - - - - - - - - \ No newline at end of file diff --git a/reallife-gamemode.csproj b/reallife-gamemode.csproj new file mode 100644 index 00000000..95166b1a --- /dev/null +++ b/reallife-gamemode.csproj @@ -0,0 +1,28 @@ + + + netcoreapp2.0 + reallife_gamemode + true + true + true + + + + + + + + + + ..\..\bridge\runtime\Bootstrapper.dll + + + + + ..\Bootstrapper.dll + + + + + + \ No newline at end of file