Merge branch 'feature/hanf' into 'develop'

HANF

See merge request log-gtav/reallife-gamemode!76
This commit is contained in:
hydrant
2021-05-27 19:13:07 +00:00
59 changed files with 7208 additions and 986 deletions

View File

@@ -31,7 +31,7 @@ export default function factionInteraction(globalData: IGlobalData) {
var ticketName: string; var ticketName: string;
var pointsName: string; var pointsName: string;
var factionInteractionMenu; var factionInteractionMenu: NativeUI.Menu;
var healTaskMenuMedic; var healTaskMenuMedic;
var reviveTaskMenuMedic; var reviveTaskMenuMedic;
var insDate; var insDate;
@@ -42,7 +42,10 @@ export default function factionInteraction(globalData: IGlobalData) {
//LSPD //LSPD
let ticketTaskMenuLSPD; let ticketTaskMenuLSPD;
let pointsTaskMenuLSPD; let pointsTaskMenuLSPD;
let wantedsMenuLSPD let wantedsMenuLSPD;
let friskUserMenuItem: NativeUI.UIMenuItem;
let friskVehicleMenuItem: NativeUI.UIMenuItem;
if (userFactionId == 1 || userFactionId == 3) { if (userFactionId == 1 || userFactionId == 3) {
if (isDuty) { if (isDuty) {
mp.gui.chat.activate(false); mp.gui.chat.activate(false);
@@ -59,6 +62,12 @@ export default function factionInteraction(globalData: IGlobalData) {
wantedsMenuLSPD = new UIMenuItem("Verbrecher Liste"); wantedsMenuLSPD = new UIMenuItem("Verbrecher Liste");
factionInteractionMenu.AddItem(wantedsMenuLSPD); factionInteractionMenu.AddItem(wantedsMenuLSPD);
friskUserMenuItem = new UIMenuItem("Spieler durchsuchen", "Einen Spieler auf illegale Gegenstände durchsuchen.");
factionInteractionMenu.AddItem(friskUserMenuItem);
friskVehicleMenuItem = new UIMenuItem("Fahrzeug durchsuchen", "Das nächste Fahrzeug auf illegale Gegenstände durchsuchen.")
factionInteractionMenu.AddItem(friskVehicleMenuItem);
/*TaskMenuLSPD = new UIMenuItem(""); /*TaskMenuLSPD = new UIMenuItem("");
TaskMenuLSPD.SetRightLabel(""); TaskMenuLSPD.SetRightLabel("");
factionInteractionMenu.AddItem(TaskMenuLSPD);*/ //weiteres factionInteractionMenu.AddItem(TaskMenuLSPD);*/ //weiteres
@@ -107,6 +116,20 @@ export default function factionInteraction(globalData: IGlobalData) {
globalData.InMenu = false; globalData.InMenu = false;
mp.events.callRemote("CLIENT:wantedlist"); mp.events.callRemote("CLIENT:wantedlist");
break; break;
case friskUserMenuItem:
factionInteractionMenu.Visible = false;
var input = new InputHelper("Welchem Spieler möchtest du Strafpunkte geben (Name / ID)?", globalData);
input.show();
input.getValue(name => {
mp.events.callRemote("CLIENT:InteractionMenu_LSPD_FriskUser", name);
globalData.InMenu = false;
});
break;
case friskVehicleMenuItem:
factionInteractionMenu.Close();
mp.events.callRemote("CLIENT:InteractionMenu_LSPD_FriskVehicle");
} }
}); });

File diff suppressed because it is too large Load Diff

View File

@@ -1,36 +1 @@
<?xml version="1.0" encoding="iso-8859-1"?> <svg id="Layer_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g><path d="m264.07 325.054c-.001-4.203-3.409-7.609-7.612-7.609-.001 0-.002 0-.003 0-4.204.001-7.61 3.411-7.609 7.614l.072 179.332c.001 4.203 3.409 7.609 7.612 7.609h.003c4.204-.001 7.61-3.411 7.609-7.614z" fill="#57cc62"/><path d="m339.319 454.146s-30.581-5.883-53.885-39.335c-25.318-36.343-28.975-79.606-28.975-79.606s39.269 18.354 64.587 54.697c23.304 33.453 18.273 64.244 18.273 64.244z" fill="#9affa3"/><path d="m321.046 389.902c-25.318-36.343-64.587-54.697-64.587-54.697s.779 9.196 4.097 22.665c10.179 8.375 21 19.049 30.044 32.032 13.29 19.077 17.36 37.278 18.408 49.407 16.288 12.126 30.312 14.837 30.312 14.837s5.03-30.791-18.274-64.244z" fill="#78f583"/><path d="m256.531 0s39.379 51.679 39.379 145.956c0 102.424-39.379 189.249-39.379 189.249s-39.379-86.826-39.379-189.249c0-94.277 39.379-145.956 39.379-145.956z" fill="#70e07a"/><path d="m256.531 0s-10.254 13.465-20.297 39.172c9.638 24.67 19.082 60.615 19.082 106.783 0 50.158-9.444 96.567-19.082 130.878 10.043 35.754 20.297 58.371 20.297 58.371s39.379-86.826 39.379-189.249c0-94.276-39.379-145.955-39.379-145.955z" fill="#56d661"/><path d="m462.193 129.131s-7.498 56.029-65.341 113.987c-62.841 62.967-140.322 92.087-140.322 92.087s29.062-77.636 91.903-140.603c57.843-57.958 113.76-65.471 113.76-65.471z" fill="#9affa3"/><path d="m417.982 144.266c-6.179 20.539-22.193 59.242-61.724 98.852-29.419 29.478-62.045 51.537-88.429 66.664-7.601 15.552-11.298 25.424-11.298 25.424s77.48-29.12 140.322-92.087c57.842-57.958 65.341-113.987 65.341-113.987s-18.036 2.427-44.212 15.134z" fill="#78f583"/><path d="m508.194 335.205s-38.963 29.809-110.042 29.809c-77.222 0-142.683-29.809-142.683-29.809s65.462-29.809 142.683-29.809c71.079 0 110.042 29.809 110.042 29.809z" fill="#70e07a"/><path d="m398.152 305.396c-7.257 0-14.41.264-21.415.741 58.877 4.599 90.863 29.068 90.863 29.068s-31.986 24.47-90.863 29.068c7.005.477 14.158.741 21.415.741 71.079 0 110.042-29.809 110.042-29.809s-38.963-29.809-110.042-29.809z" fill="#56d661"/><path d="m3.806 335.205s38.963-29.809 110.042-29.809c77.222 0 142.683 29.809 142.683 29.809s-65.462 29.809-142.683 29.809c-71.079 0-110.042-29.809-110.042-29.809z" fill="#70e07a"/><path d="m113.848 305.396c-6.679 0-13.074.264-19.18.741 67.532 4.599 121.268 29.068 121.268 29.068s-53.736 24.469-121.268 29.068c6.106.477 12.501.741 19.18.741 77.222 0 142.683-29.809 142.683-29.809s-65.461-29.809-142.683-29.809z" fill="#56d661"/><path d="m173.598 454.146s30.581-5.883 53.885-39.335c25.318-36.343 28.975-79.606 28.975-79.606s-39.269 18.354-64.587 54.697c-23.304 33.453-18.273 64.244-18.273 64.244z" fill="#9affa3"/><path d="m221.916 357.87c-3.879 15.752-11.231 37.35-24.879 56.941-7.525 10.802-15.806 18.716-23.573 24.499-.79 9.14.134 14.837.134 14.837s30.581-5.883 53.885-39.335c25.318-36.343 28.975-79.606 28.975-79.606s-16.227 7.595-34.542 22.664z" fill="#78f583"/><path d="m50.725 129.131s7.498 56.029 65.341 113.987c62.841 62.967 140.322 92.087 140.322 92.087s-29.062-77.636-91.903-140.603c-57.844-57.958-113.76-65.471-113.76-65.471z" fill="#9affa3"/><path d="m123.889 194.602c40.438 40.519 66.885 87.108 80.605 115.179 29.975 17.186 51.892 25.424 51.892 25.424s-29.062-77.636-91.903-140.603c-57.842-57.958-113.759-65.471-113.759-65.471s.754 5.621 3.617 15.135c19.92 9.67 44.552 25.29 69.548 50.336z" fill="#78f583"/></g></svg>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 505.501 505.501" style="enable-background:new 0 0 505.501 505.501;" xml:space="preserve" width="512" height="512">
<g>
<path style="fill:#A2DB18;" d="M470.802,163.55c-1.482-1.481-3.497-2.294-5.605-2.222l-12.513,0.384 c-1.963,0.06-3.825,0.878-5.198,2.282l-8.857,9.056l-12.673,0.32c-2.087,0.052-4.06,0.962-5.456,2.514l-8.48,9.428l-12.652,0.878 c-2.095,0.145-4.036,1.151-5.363,2.78l-8.033,9.857l-12.617,1.588c-2.11,0.266-4.012,1.404-5.244,3.137l-7.398,10.411 l-12.511,2.608c-2.137,0.446-3.979,1.789-5.057,3.689l-6.371,11.23l-12.186,4.326c-2.191,0.778-3.905,2.516-4.652,4.717 l-3.941,11.61l-10.74,5.878c-1.991,1.09-3.39,3.013-3.815,5.242l-2.269,11.908l-9.939,6.925c-1.817,1.266-2.991,3.262-3.215,5.465 l-1.219,11.993l-9.363,7.585c-1.7,1.377-2.724,3.42-2.809,5.606l-0.47,12.008l-8.907,8.058c-1.613,1.459-2.523,3.54-2.5,5.714 l0.129,12.004l-8.51,8.47c-1.465,1.459-2.273,3.451-2.237,5.518l0.212,12.037c0.072,4.091,3.371,7.39,7.462,7.462l12.025,0.212 c0.045,0,0.089,0.001,0.134,0.001c2.019,0,3.958-0.804,5.385-2.239l8.466-8.509l12.014,0.126c2.158,0.018,4.253-0.887,5.712-2.499 l8.063-8.91l12.01-0.471c2.185-0.086,4.228-1.109,5.605-2.808l7.589-9.366l11.993-1.219c2.203-0.224,4.199-1.398,5.465-3.215 l6.923-9.938l11.906-2.268c2.23-0.425,4.153-1.825,5.242-3.816l5.877-10.738l11.607-3.939c2.201-0.747,3.94-2.461,4.718-4.652 l4.327-12.188l11.231-6.372c1.899-1.077,3.242-2.919,3.688-5.056l2.61-12.515l10.413-7.401c1.734-1.232,2.871-3.134,3.137-5.243 l1.588-12.617l9.855-8.03c1.628-1.326,2.634-3.268,2.78-5.363l0.878-12.65l9.424-8.475c1.553-1.396,2.463-3.371,2.515-5.458 l0.318-12.665l9.056-8.859c1.403-1.372,2.221-3.235,2.281-5.198l0.384-12.521C473.088,167.06,472.284,165.031,470.802,163.55z"/>
<path style="fill:#A2DB18;" d="M264.193,376.4l-8.343-12.099l0.434-12.694c0.074-2.172-0.785-4.273-2.362-5.769l-8.707-8.266 l-0.158-12.003c-0.029-2.18-0.993-4.243-2.647-5.663l-9.125-7.837l-0.819-12.006c-0.149-2.194-1.242-4.215-2.995-5.541 l-9.631-7.286l-1.692-11.964c-0.314-2.215-1.587-4.179-3.481-5.369l-10.302-6.471l-2.994-11.804 c-0.57-2.248-2.136-4.113-4.251-5.063l-11.288-5.07l-5.479-11.694c-0.949-2.026-2.743-3.531-4.904-4.113l-12.397-3.338 l-6.957-10.774c-1.166-1.806-3.042-3.033-5.163-3.378l-12.577-2.044l-7.745-10.111c-1.284-1.676-3.207-2.742-5.308-2.942 l-12.643-1.209l-8.269-9.63c-1.364-1.588-3.322-2.543-5.412-2.64l-12.661-0.586l-8.679-9.244c-1.428-1.521-3.42-2.388-5.506-2.397 l-13.343-0.056l-12.542-8.908c-3.022-2.146-7.152-1.798-9.771,0.822c-2.62,2.621-2.968,6.75-0.821,9.771l8.912,12.546l0.057,13.345 c0.009,2.087,0.876,4.079,2.398,5.507l9.239,8.67l0.585,12.655c0.097,2.091,1.052,4.049,2.64,5.413l9.629,8.268l1.207,12.64 c0.2,2.102,1.267,4.025,2.942,5.308l10.112,7.746l2.045,12.58c0.345,2.121,1.572,3.997,3.377,5.163l10.777,6.96l3.339,12.4 c0.582,2.16,2.087,3.955,4.112,4.904l11.694,5.479l5.068,11.285c0.95,2.116,2.814,3.682,5.063,4.252l11.801,2.993l6.47,10.3 c1.189,1.895,3.154,3.168,5.369,3.482l11.962,1.692l7.286,9.63c1.326,1.753,3.347,2.846,5.54,2.996l12.011,0.821l7.839,9.126 c1.42,1.653,3.482,2.617,5.661,2.646l12.01,0.16l8.275,8.712c1.497,1.576,3.607,2.437,5.769,2.361l12.69-0.436l12.093,8.337 c1.307,0.901,2.812,1.342,4.309,1.342c1.96,0,3.905-0.756,5.375-2.225C265.904,383.491,266.275,379.418,264.193,376.4z"/>
<path style="fill:#6ABA0F;" d="M470.802,163.55c-1.482-1.481-3.497-2.294-5.605-2.222l-12.513,0.384 c-1.963,0.06-3.825,0.878-5.198,2.282l-4.855,4.963c0,0.066,0.006,0.131,0.004,0.198l-0.384,12.521 c-0.06,1.963-0.878,3.825-2.281,5.198l-9.056,8.859l-0.318,12.665c-0.052,2.088-0.962,4.062-2.515,5.458l-9.424,8.475l-0.878,12.65 c-0.145,2.095-1.151,4.037-2.78,5.363l-9.855,8.03l-1.588,12.617c-0.266,2.109-1.403,4.011-3.137,5.243l-10.413,7.401l-2.61,12.515 c-0.446,2.137-1.789,3.979-3.688,5.056l-11.231,6.372l-4.327,12.188c-0.778,2.191-2.516,3.905-4.718,4.652l-11.606,3.939 l-5.877,10.738c-1.09,1.991-3.013,3.391-5.242,3.816l-11.906,2.268l-6.923,9.938c-1.266,1.817-3.262,2.991-5.465,3.215 l-11.993,1.219l-7.589,9.366c-1.377,1.699-3.42,2.723-5.605,2.808l-12.01,0.471l-8.063,8.91c-1.459,1.612-3.554,2.516-5.712,2.499 l-12.014-0.126l-3.083,3.099c0.086,4.079,3.378,7.364,7.461,7.436l12.025,0.212c0.045,0,0.089,0.001,0.134,0.001 c2.019,0,3.958-0.804,5.385-2.239l8.466-8.509l12.014,0.126c2.158,0.018,4.253-0.887,5.712-2.499l8.063-8.91l12.01-0.471 c2.185-0.086,4.228-1.109,5.605-2.808l7.589-9.366l11.993-1.219c2.203-0.224,4.199-1.398,5.465-3.215l6.923-9.938l11.906-2.268 c2.23-0.425,4.153-1.825,5.242-3.816l5.877-10.738l11.607-3.939c2.201-0.747,3.94-2.461,4.718-4.652l4.327-12.188l11.231-6.372 c1.899-1.077,3.242-2.919,3.688-5.056l2.61-12.515l10.413-7.401c1.734-1.232,2.871-3.134,3.137-5.243l1.588-12.617l9.855-8.03 c1.628-1.326,2.634-3.268,2.78-5.363l0.878-12.65l9.424-8.475c1.553-1.396,2.463-3.371,2.515-5.458l0.318-12.665l9.056-8.859 c1.403-1.372,2.221-3.235,2.281-5.198l0.384-12.521C473.088,167.06,472.284,165.031,470.802,163.55z"/>
<path style="fill:#A2DB18;" d="M263.308,354.836c-2.816-2.816-7.329-2.979-10.34-0.374l-6.257,5.41l-6.502-1.556 c-3.175-0.758-6.481,0.594-8.211,3.362l-2.853,4.565l-5.292-1.004c-3.213-0.612-6.456,0.906-8.049,3.762l-2.639,4.728l-5.37-0.716 c-3.259-0.434-6.432,1.279-7.855,4.246l-2.367,4.937l-5.471-0.328c-3.321-0.2-6.392,1.789-7.565,4.906l-1.968,5.229l-5.593,0.27 c-3.414,0.164-6.297,2.588-7.046,5.922l-1.286,5.722l-5.985,1.473c-3.211,0.791-5.542,3.568-5.763,6.868l-0.409,6.078l-5.651,2.237 c-2.988,1.183-4.909,4.118-4.797,7.33l0.209,5.97l-5.355,2.636c-2.847,1.401-4.523,4.424-4.203,7.581l0.596,5.891l-5.154,2.905 c-2.748,1.549-4.253,4.633-3.782,7.752l0.88,5.829l-5.002,3.119c-2.671,1.666-4.038,4.806-3.437,7.897l1.364,7.011l-5.805,6.583 c-2.652,3.008-2.51,7.561,0.326,10.397c1.479,1.478,3.424,2.225,5.373,2.225c1.79,0,3.584-0.63,5.024-1.9l6.583-5.807l7.014,1.364 c3.088,0.598,6.232-0.768,7.897-3.44l3.112-4.995l5.821,0.88c3.121,0.473,6.206-1.034,7.754-3.782l2.903-5.152l5.886,0.597 c3.154,0.32,6.181-1.355,7.583-4.203l2.637-5.357l5.974,0.209c3.214,0.109,6.145-1.808,7.329-4.795l2.24-5.657l6.083-0.41 c3.299-0.222,6.076-2.553,6.866-5.763l1.474-5.986l5.721-1.286c3.335-0.749,5.758-3.633,5.922-7.047l0.269-5.589l5.225-1.966 c3.118-1.173,5.108-4.241,4.908-7.566l-0.328-5.469l4.936-2.366c2.967-1.421,4.681-4.592,4.248-7.853l-0.716-5.377l4.731-2.64 c2.855-1.594,4.371-4.836,3.762-8.048L251.904,389l4.573-2.862c2.767-1.731,4.118-5.035,3.359-8.209l-1.557-6.5l5.405-6.254 C266.288,362.163,266.124,357.651,263.308,354.836z"/>
<path style="fill:#A2DB18;" d="M391.025,478.043l-4.93-3.215l1.003-5.805c0.536-3.103-0.898-6.214-3.604-7.823l-5.073-3.016 l0.747-5.855c0.401-3.136-1.184-6.192-3.977-7.674l-5.249-2.783l0.421-5.928c0.227-3.182-1.559-6.166-4.471-7.471l-5.485-2.459 l-0.056-6.018c-0.03-3.25-2.124-6.121-5.21-7.142l-5.874-1.943l-0.899-6.14c-0.494-3.372-3.173-6.003-6.554-6.435l-5.654-0.723 l-1.68-5.432c-0.995-3.215-3.983-5.421-7.35-5.351l-5.529,0.067l-2.19-5.068c-1.312-3.036-4.438-4.874-7.726-4.546l-5.418,0.539 L303.754,373c-1.514-2.908-4.724-4.521-7.96-3.99l-5.33,0.868l-2.749-4.643c-1.665-2.81-4.937-4.241-8.132-3.557l-5.262,1.131 l-2.963-4.499c-1.826-2.772-5.241-4.04-8.43-3.127l-7.078,2.02c-2.525,0.721-4.498,2.694-5.219,5.218l-2.019,7.068 c-0.912,3.192,0.354,6.607,3.127,8.432l4.499,2.962l-1.13,5.272c-0.684,3.192,0.748,6.464,3.556,8.128l4.646,2.752l-0.868,5.331 c-0.527,3.235,1.081,6.443,3.987,7.958l4.829,2.515l-0.54,5.419c-0.328,3.291,1.511,6.416,4.547,7.727l5.066,2.188l-0.068,5.525 c-0.042,3.366,2.137,6.357,5.352,7.352l5.429,1.678l0.722,5.653c0.432,3.381,3.063,6.061,6.435,6.554l6.141,0.899l1.945,5.876 c1.021,3.084,3.89,5.178,7.139,5.209l6.024,0.058l2.462,5.49c1.305,2.911,4.286,4.698,7.47,4.469l5.928-0.421l2.78,5.245 c1.481,2.794,4.537,4.381,7.675,3.978l5.853-0.747l3.012,5.069c1.609,2.709,4.725,4.142,7.827,3.606l5.797-1.004l3.216,4.93 c1.422,2.179,3.832,3.446,6.361,3.446c0.546,0,1.096-0.059,1.645-0.181l7.402-1.64c2.883-0.639,5.135-2.89,5.773-5.773l1.639-7.398 C394.976,482.96,393.675,479.771,391.025,478.043z"/>
<path style="fill:#6ABA0F;" d="M391.025,478.043l-4.93-3.215l1.003-5.805c0.536-3.103-0.898-6.214-3.604-7.823l-5.073-3.016 l0.747-5.855c0.401-3.136-1.184-6.192-3.977-7.674l-5.249-2.783l0.421-5.928c0.227-3.182-1.559-6.166-4.471-7.471l-5.485-2.459 l-0.056-6.018c-0.03-3.25-2.124-6.121-5.21-7.142l-5.874-1.943l-0.899-6.14c-0.494-3.372-3.173-6.003-6.554-6.435l-5.654-0.723 l-1.68-5.432c-0.995-3.215-3.983-5.421-7.35-5.351l-5.529,0.067l-2.19-5.068c-1.312-3.036-4.438-4.874-7.726-4.546l-5.418,0.539 L303.754,373c-1.514-2.908-4.724-4.521-7.96-3.99l-5.33,0.868l-2.749-4.643c-1.665-2.81-4.937-4.241-8.132-3.557l-5.262,1.131 l-2.963-4.499c-1.826-2.772-5.241-4.04-8.43-3.127l-7.078,2.02c-2.22,0.634-4.012,2.237-4.903,4.33 c2.586,0.054,5.02,1.407,6.379,3.701l2.749,4.643l5.33-0.868c3.236-0.531,6.445,1.082,7.96,3.99l2.512,4.824l5.418-0.539 c3.289-0.327,6.415,1.51,7.726,4.546l2.19,5.068l5.529-0.067c3.367-0.07,6.355,2.137,7.35,5.351l1.68,5.432l5.654,0.723 c3.381,0.432,6.06,3.063,6.554,6.435l0.899,6.14l5.874,1.943c3.086,1.021,5.18,3.892,5.21,7.142l0.056,6.018l5.485,2.459 c2.911,1.305,4.697,4.289,4.471,7.471l-0.421,5.928l5.249,2.783c2.793,1.481,4.378,4.537,3.977,7.674l-0.747,5.855l5.073,3.016 c2.706,1.609,4.14,4.72,3.604,7.823l-1.003,5.805l4.93,3.215c2.65,1.728,3.951,4.918,3.266,8.006l-1.639,7.398 c-0.019,0.085-0.052,0.163-0.074,0.247c0.089-0.012,0.177-0.01,0.267-0.025l5.797-1.004l3.216,4.93 c1.422,2.179,3.832,3.446,6.361,3.446c0.546,0,1.096-0.059,1.645-0.181l7.402-1.64c2.883-0.639,5.135-2.89,5.773-5.773l1.639-7.398 C394.976,482.96,393.675,479.771,391.025,478.043z"/>
<path style="fill:#80C433;" d="M503.579,369.461l-6.7-7.528c-1.596-1.793-3.942-2.731-6.338-2.517l-9.538,0.835l-6.423-7.113 c-1.671-1.851-4.142-2.765-6.617-2.442l-9.508,1.235l-6.734-6.828c-1.76-1.784-4.289-2.583-6.753-2.143l-9.473,1.703l-7.132-6.465 c-1.877-1.701-4.477-2.356-6.937-1.743l-9.399,2.339l-7.682-5.913c-2.053-1.58-4.769-2.004-7.208-1.128l-9.255,3.333l-8.552-4.9 c-2.376-1.362-5.302-1.338-7.658,0.061l-7.971,4.738l-8.653-3.286c-2.515-0.955-5.347-0.508-7.446,1.173l-7.121,5.704l-8.821-2.3 c-2.547-0.664-5.259,0.038-7.164,1.857l-6.546,6.251l-8.892-1.646c-2.56-0.472-5.189,0.399-6.959,2.313l-6.118,6.616l-8.932-1.152 c-2.568-0.331-5.136,0.672-6.8,2.661l-5.772,6.902l-8.97-0.725c-2.522-0.207-4.971,0.857-6.547,2.83l-6.068,7.593 c-2.216,2.773-2.216,6.711-0.001,9.484l6.06,7.586c1.576,1.973,4.035,3.032,6.548,2.831l8.969-0.726l5.779,6.907 c1.664,1.989,4.227,2.993,6.798,2.66l8.937-1.151l6.12,6.617c1.769,1.914,4.396,2.787,6.958,2.312l8.899-1.645l6.546,6.251 c1.904,1.819,4.616,2.521,7.164,1.857l8.818-2.301l7.119,5.702c2.099,1.681,4.932,2.127,7.447,1.173l8.651-3.286l7.968,4.737 c1.195,0.711,2.539,1.067,3.882,1.067c1.303,0,2.606-0.335,3.777-1.005l8.553-4.9l9.259,3.333c2.438,0.879,5.154,0.452,7.206-1.128 l7.685-5.914l9.404,2.338c2.46,0.612,5.059-0.043,6.936-1.744l7.132-6.465l9.466,1.703c2.466,0.444,4.995-0.358,6.755-2.143 l6.732-6.827l9.504,1.236c2.476,0.323,4.948-0.592,6.619-2.444l6.415-7.109l9.539,0.835c2.392,0.215,4.741-0.725,6.338-2.517 l6.705-7.534C506.142,376.683,506.142,372.34,503.579,369.461z"/>
<g>
<path style="fill:#6ABA0F;" d="M357.496,413.941l-6.533,3.743c1.35,0.252,2.763,0.149,4.09-0.355l5.768-2.191L357.496,413.941z"/>
<path style="fill:#6ABA0F;" d="M357.495,335.085l3.323-1.197l-5.769-2.191c-1.326-0.503-2.738-0.607-4.086-0.356L357.495,335.085z "/>
<path style="fill:#6ABA0F;" d="M503.579,369.461l-6.7-7.528c-1.596-1.793-3.942-2.731-6.338-2.517l-9.538,0.835l-6.423-7.113 c-1.671-1.851-4.142-2.765-6.617-2.442l-9.508,1.235l-6.734-6.828c-1.76-1.784-4.289-2.583-6.753-2.143l-9.473,1.703l-7.132-6.465 c-1.877-1.701-4.477-2.356-6.937-1.743l-9.399,2.339l-7.682-5.913c-2.053-1.58-4.769-2.004-7.208-1.128l-9.255,3.333l-8.552-4.9 c-2.376-1.362-5.302-1.338-7.658,0.061l-1.83,1.088c1.473,0.101,2.909,0.618,4.115,1.546l7.682,5.913l9.399-2.339 c2.459-0.612,5.06,0.042,6.937,1.743l7.132,6.465l9.473-1.703c2.464-0.44,4.993,0.358,6.753,2.143l6.734,6.828l9.508-1.235 c2.474-0.322,4.945,0.592,6.617,2.442l6.423,7.113l9.538-0.835c2.396-0.214,4.742,0.724,6.338,2.517l6.7,7.528 c2.562,2.879,2.562,7.222,0,10.101l-6.705,7.534c-1.597,1.792-3.946,2.732-6.338,2.517l-9.539-0.835l-6.415,7.109 c-1.671,1.852-4.143,2.767-6.619,2.444l-9.504-1.236l-6.732,6.827c-1.76,1.785-4.29,2.586-6.755,2.143l-9.466-1.703l-7.132,6.465 c-1.876,1.701-4.476,2.356-6.936,1.744l-9.404-2.338l-7.685,5.914c-1.206,0.928-2.643,1.446-4.116,1.547l1.827,1.086 c1.195,0.711,2.539,1.067,3.882,1.067c1.303,0,2.606-0.335,3.777-1.005l8.553-4.9l9.259,3.333 c2.438,0.879,5.154,0.452,7.206-1.128l7.685-5.914l9.404,2.338c2.46,0.612,5.059-0.043,6.936-1.744l7.132-6.465l9.466,1.703 c2.466,0.444,4.995-0.358,6.755-2.143l6.732-6.827l9.504,1.236c2.476,0.323,4.948-0.592,6.619-2.444l6.415-7.109l9.539,0.835 c2.392,0.215,4.741-0.725,6.338-2.517l6.705-7.534C506.142,376.683,506.142,372.34,503.579,369.461z"/>
</g>
<path style="fill:#80C433;" d="M264.582,374.314c-0.756-3.679-4.082-6.25-7.84-6.058l-9.037,0.474l-5.622-7.054 c-1.616-2.027-4.158-3.094-6.731-2.821l-8.95,0.937l-5.936-6.763c-1.714-1.953-4.309-2.894-6.875-2.496l-8.916,1.384l-6.315-6.447 c-1.831-1.87-4.498-2.666-7.054-2.104l-8.865,1.945l-6.809-6.01c-1.992-1.758-4.758-2.347-7.293-1.555l-8.755,2.735l-7.501-5.3 c-2.238-1.581-5.154-1.833-7.63-0.663l-8.501,4.02l-8.959-4.041c-2.414-1.089-5.217-0.842-7.403,0.649l-8.062,5.498l-9.342-2.771 c-2.45-0.727-5.103-0.173-7.057,1.475l-7.38,6.222l-9.44-1.992c-2.463-0.519-5.023,0.214-6.837,1.96l-6.923,6.664l-9.491-1.456 c-2.467-0.377-4.969,0.481-6.681,2.301l-6.57,6.975l-9.53-1.031c-2.473-0.266-4.93,0.696-6.562,2.582l-6.837,7.9l-12.236,1.557 C2.843,371.513,0,374.742,0,378.567s2.844,7.053,6.639,7.536l12.242,1.556l6.839,7.901c1.633,1.886,4.089,2.851,6.563,2.581 l9.521-1.033l6.565,6.973c1.714,1.819,4.213,2.683,6.682,2.301l9.489-1.455l6.916,6.661c1.814,1.746,4.374,2.481,6.838,1.961 l9.442-1.992l7.384,6.224c1.954,1.647,4.607,2.202,7.056,1.475l9.345-2.77l8.066,5.499c2.187,1.491,4.992,1.737,7.403,0.648 l8.959-4.041l8.499,4.019c1.033,0.489,2.143,0.73,3.247,0.73c1.544,0,3.08-0.471,4.385-1.393l7.498-5.299l8.752,2.736 c2.535,0.792,5.301,0.203,7.293-1.555l6.808-6.008l8.863,1.945c2.555,0.562,5.222-0.233,7.053-2.103l6.323-6.451l8.918,1.384 c2.567,0.397,5.161-0.543,6.874-2.495l5.94-6.767l8.96,0.935c2.58,0.271,5.115-0.795,6.73-2.822l6.731-8.449l10.939-4.028 C263.29,381.674,265.337,377.994,264.582,374.314z"/>
<path style="fill:#80C433;" d="M318.583,193.964l-6.135-15.68l3.305-16.491c0.355-1.772,0.067-3.612-0.813-5.191l-8.128-14.585 l1.6-16.611c0.168-1.743-0.272-3.491-1.244-4.947l-9.237-13.833l0.503-16.62c0.052-1.725-0.484-3.416-1.521-4.796l-9.975-13.266 l-0.308-16.594c-0.032-1.713-0.642-3.366-1.731-4.688l-10.544-12.804l-1.002-16.556c-0.095-1.577-0.68-3.085-1.673-4.314 l-9.983-12.362c-1.442-1.786-3.615-2.824-5.91-2.824c-2.296,0-4.468,1.038-5.91,2.824l-9.981,12.36 c-0.993,1.229-1.577,2.737-1.673,4.314l-1.002,16.56l-10.547,12.809c-1.089,1.323-1.699,2.974-1.731,4.688l-0.309,16.596 l-9.975,13.269c-1.037,1.379-1.574,3.07-1.521,4.795l0.503,16.619l-9.236,13.832c-0.972,1.457-1.412,3.204-1.244,4.948 l1.601,16.608l-8.126,14.581c-0.88,1.579-1.168,3.419-0.813,5.191l3.305,16.488l-6.135,15.68c-0.708,1.808-0.696,3.819,0.033,5.619 l6.019,14.867l-3.354,15.667c-0.394,1.839-0.091,3.759,0.849,5.388l7.953,13.778l-1.637,15.815 c-0.188,1.817,0.284,3.641,1.331,5.137l9.083,12.983l-0.489,15.831c-0.055,1.799,0.53,3.56,1.651,4.967l9.849,12.366l0.376,15.804 c0.043,1.786,0.714,3.501,1.896,4.842l10.444,11.851l1.125,15.759c0.119,1.661,0.78,3.237,1.882,4.486l10.088,11.43 c1.442,1.634,3.516,2.57,5.696,2.57c2.179,0,4.253-0.936,5.696-2.57l10.084-11.424c1.102-1.248,1.763-2.825,1.882-4.486 l1.126-15.76l10.447-11.856c1.182-1.341,1.853-3.055,1.895-4.842l0.377-15.805l9.85-12.369c1.121-1.408,1.706-3.168,1.65-4.967 l-0.489-15.832l9.083-12.983c1.047-1.497,1.52-3.321,1.331-5.137l-1.638-15.814l7.952-13.776c0.94-1.629,1.243-3.549,0.849-5.389 l-3.354-15.664l6.018-14.866C319.279,197.783,319.291,195.772,318.583,193.964z"/>
<path style="fill:#6ABA0F;" d="M318.583,193.964l-6.135-15.68l3.305-16.491c0.355-1.772,0.067-3.612-0.813-5.191l-8.128-14.585 l1.6-16.611c0.168-1.743-0.272-3.491-1.244-4.947l-9.237-13.833l0.503-16.62c0.052-1.725-0.484-3.416-1.521-4.796l-9.975-13.266 l-0.308-16.594c-0.032-1.713-0.642-3.366-1.731-4.688l-10.544-12.804l-1.002-16.556c-0.095-1.577-0.68-3.085-1.673-4.314 l-9.983-12.362c-1.442-1.786-3.615-2.824-5.91-2.824c-2.296,0-4.468,1.038-5.91,2.824l-9.283,11.496l0.699,0.866 c0.993,1.229,1.577,2.737,1.673,4.314l1.002,16.556l10.544,12.804c1.089,1.323,1.699,2.975,1.731,4.688l0.308,16.594l9.975,13.266 c1.037,1.379,1.573,3.07,1.521,4.796l-0.503,16.62l9.237,13.833c0.972,1.457,1.412,3.204,1.244,4.947l-1.6,16.611l8.128,14.585 c0.88,1.579,1.168,3.419,0.813,5.191l-3.305,16.491l6.135,15.68c0.708,1.808,0.696,3.819-0.033,5.619l-6.018,14.866l3.354,15.664 c0.394,1.839,0.091,3.759-0.849,5.389l-7.952,13.776l1.638,15.814c0.188,1.817-0.284,3.641-1.331,5.137l-9.083,12.983l0.489,15.832 c0.055,1.799-0.53,3.559-1.65,4.967l-9.85,12.369l-0.377,15.805c-0.043,1.786-0.714,3.501-1.895,4.842l-10.447,11.856l-1.126,15.76 c-0.119,1.661-0.78,3.238-1.882,4.486l-0.585,0.663l9.498,10.761c1.442,1.634,3.516,2.57,5.696,2.57 c2.179,0,4.253-0.936,5.696-2.57l10.084-11.424c1.102-1.248,1.763-2.825,1.882-4.486l1.126-15.76l10.447-11.856 c1.182-1.341,1.853-3.055,1.895-4.842l0.377-15.805l9.85-12.369c1.121-1.408,1.706-3.168,1.65-4.967l-0.489-15.832l9.083-12.983 c1.047-1.497,1.52-3.321,1.331-5.137l-1.638-15.814l7.952-13.776c0.94-1.629,1.243-3.549,0.849-5.389l-3.354-15.664l6.018-14.866 C319.279,197.783,319.291,195.772,318.583,193.964z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -0,0 +1 @@
<svg id="Layer_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g><g><g><path d="m169.626 92.712-70.403 92.403 85.13 319.201c1.473 5.522 7.143 8.805 12.666 7.332l307.297-81.956c5.522-1.473 8.805-7.143 7.332-12.666l-100.796-377.938c-1.473-5.522-7.143-8.805-12.666-7.332z" fill="#ffdb0d"/></g><path d="m511.648 417.027-100.796-377.939c-1.473-5.522-7.143-8.805-12.666-7.332l-42.806 11.416c5.522-1.473 12.606 2.628 14.079 8.15l100.796 377.939c1.032 3.871-.278 7.81-3.053 10.329l37.114-9.898c5.522-1.472 8.805-7.143 7.332-12.665z" fill="#f2cf00"/><g><path d="m477.043 398.412c-1.106-4.141-5.358-6.598-9.499-5.5l-256.952 68.529c-4.141 1.105-6.604 5.358-5.5 9.5.927 3.472 4.065 5.763 7.494 5.763.662 0 1.335-.086 2.005-.264l256.952-68.529c4.142-1.104 6.605-5.358 5.5-9.499z" fill="#d6b80b"/><g><path d="m128.056 147.271-1.948 2.557 4.717-1.238c-1.003-.26-1.949-.695-2.769-1.319z" fill="#ffdb0d"/><path d="m384.613 81.962c4.141-1.105 6.604-5.358 5.5-9.499-1.106-4.141-5.36-6.599-9.5-5.5l-239.22 62.803-15.286 20.062z" fill="#d6b80b"/></g></g><g><circle cx="297.603" cy="271.702" fill="#f5f5f5" r="130.582"/><path d="m397.222 284.469c-20.723-9.596-44.51-5.671-64.952 2.633 17.847-20.726 32.659-45.451 30.549-73.853-23.764 10.994-41.628 34.966-51.21 58.724-2.253-31.776-10.15-64.798-36.512-85.529-12.551 31.141-2.923 63.752 10.978 92.453-20.101-15.824-47.596-28.604-73.76-25.508 12.249 25.779 37.59 39.805 63.372 48.868-21.981 2.927-44.884 11.313-58.116 30.125 22.114 8.353 48.483 3.767 68.407-7.984-1.851 17.024 3.739 27.816 3.739 27.816 11.051-5.822 18.862-15.753 22.133-27.84 8.403 8.4 19.47 13.635 31.416 13.558 0 0 1.019-11.943-8.936-26.43 22.954.393 48.076-8.871 62.892-27.033z" fill="#70e07a"/></g></g><g fill="#ab7f63"><ellipse cx="128.749" cy="33.77" rx="26.14" ry="16.927" transform="matrix(.54 -.841 .841 .54 30.76 123.852)"/><ellipse cx="71.519" cy="102.568" rx="16.927" ry="26.14" transform="matrix(.866 -.5 .5 .866 -41.702 49.501)"/><ellipse cx="23.827" cy="170.781" rx="16.927" ry="26.14" transform="matrix(.54 -.841 .841 .54 -132.746 98.541)"/><ellipse cx="24.175" cy="19.64" rx="26.14" ry="16.927" transform="matrix(.866 -.5 .5 .866 -6.581 14.719)"/></g></g></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1 @@
<svg id="Layer_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g><g><ellipse cx="346.95" cy="372.079" fill="#70e07a" rx="136.201" ry="136.115"/><path d="m346.949 235.964c-6.898 0-13.675.517-20.297 1.506 65.594 9.795 115.904 66.328 115.904 134.609s-50.31 124.814-115.904 134.609c6.622.989 13.399 1.506 20.297 1.506 75.222 0 136.201-60.941 136.201-136.115s-60.979-136.115-136.201-136.115z" fill="#56d661"/><g><g><path d="m436.605 412.934c-16.926-14.121-40.066-16.379-61.178-13.717 21.781-14.908 41.728-34.307 46.82-61.352-24.876 4.348-47.479 22.283-62.313 42.08 5.797-30.232 6.645-63.033-12.767-88.956-19.435 25.953-18.567 58.801-12.747 89.062-14.798-19.782-37.243-38.562-62.392-42.187 5.007 27.122 25.135 46.529 46.908 61.412-21.21-2.741-44.635-.614-61.64 13.657 18.531 13.307 44.242 15.591 65.728 9.581-5.955 15.436-3.428 26.905-3.428 26.905 11.744-2.684 21.491-10.012 27.543-20.484 5.743 9.936 14.754 17.58 25.905 20.484 0 0 3.918-10.898-1.759-26.905 21.289 6.084 47.001 3.69 65.32-9.58z" fill="#f5f5f5"/></g></g></g><g><g><path d="m396.727 161.373-297.295 329.017c-7.104 7.115-19.633 7.505-33.392 1.661-8.267-3.512-44.11 24.703-55.638 13.495-11.48-11.161 16.418-46.537 12.599-54.503-6.357-13.258-6.359-25.414.745-32.529l329.331-298.594 43.65-4.109z" fill="#ab7c5e"/><g><path d="m365.989 118.704 8.891 21.921-320.715 354.195c5.308-2.321 9.619-3.727 11.875-2.769 13.759 5.844 26.288 5.454 33.392-1.661l297.295-329.018v-45.562z" fill="#a17152"/></g><g><path d="m492.14 6.618 16.677 15.838c4.022 3.82 4.264 10.148.546 14.263l-112.636 124.654-43.65-41.453 125.142-113.462c3.967-3.597 10.038-3.527 13.921.16z" fill="#f5f5f5"/></g><path d="m508.817 22.456-14.618-13.882-119.319 132.051 21.847 20.748 112.635-124.654c3.719-4.116 3.477-10.443-.545-14.263z" fill="#ededed"/><path d="m23.001 451.043 10.375 17.841" fill="#ab7c5e"/></g><g><path d="m326.557 207.758c9.795 0 9.811-15.223 0-15.223-9.796 0-9.812 15.223 0 15.223z" fill="#916146"/></g><g><path d="m249.458 258.365c9.795 0 9.811-15.223 0-15.223-9.796 0-9.812 15.223 0 15.223z" fill="#916146"/></g><g><path d="m236.156 301.813c9.795 0 9.811-15.223 0-15.223-9.796 0-9.812 15.223 0 15.223z" fill="#916146"/></g><g><path d="m180.389 325.838c9.795 0 9.811-15.223 0-15.223-9.795 0-9.812 15.223 0 15.223z" fill="#916146"/></g><g><path d="m158.901 385.643c9.795 0 9.811-15.223 0-15.223-9.795 0-9.812 15.223 0 15.223z" fill="#916146"/></g><g><path d="m94.437 400.978c9.795 0 9.811-15.223 0-15.223-9.795 0-9.812 15.223 0 15.223z" fill="#916146"/></g><g><path d="m95.972 450.049c9.795 0 9.811-15.223 0-15.223-9.796 0-9.812 15.223 0 15.223z" fill="#916146"/></g></g><g fill="#c9ccd3"><path d="m37.106 213.1c0-4.204-3.408-7.611-7.611-7.611-4.204 0-7.611 3.408-7.611 7.611 0 11.76-4.139 17.182-9.38 24.047-5.862 7.677-12.504 16.378-12.504 33.284 0 16.908 6.642 25.611 12.502 33.288 5.241 6.866 9.381 12.29 9.381 24.052s-4.14 17.185-9.381 24.052c-5.86 7.676-12.502 16.379-12.502 33.287 0 4.204 3.408 7.612 7.611 7.612s7.611-3.408 7.611-7.612c0-11.762 4.14-17.185 9.381-24.052 5.86-7.677 12.502-16.38 12.502-33.287s-6.642-25.61-12.502-33.287c-5.241-6.867-9.381-12.29-9.381-24.052 0-11.76 4.139-17.182 9.38-24.047 5.862-7.678 12.504-16.379 12.504-33.285z"/><path d="m55.231 153.147c0-11.76 4.139-17.182 9.38-24.048 5.861-7.677 12.503-16.378 12.503-33.284 0-4.204-3.408-7.611-7.611-7.611s-7.611 3.408-7.611 7.611c0 11.76-4.139 17.182-9.38 24.047-5.86 7.677-12.503 16.378-12.503 33.284 0 16.908 6.642 25.61 12.502 33.287 5.241 6.866 9.381 12.29 9.381 24.052s-4.14 17.185-9.381 24.052c-5.86 7.677-12.502 16.38-12.502 33.288 0 4.204 3.408 7.612 7.611 7.612s7.611-3.408 7.611-7.612c0-11.762 4.14-17.185 9.381-24.052 5.86-7.677 12.502-16.38 12.502-33.287s-6.642-25.61-12.502-33.288c-5.241-6.866-9.381-12.29-9.381-24.051z"/></g></g></svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -0,0 +1,443 @@
import { Menu, Point, UIMenuSliderItem, UIMenuItem, Color, UIMenuListItem, ItemsCollection } from "../libs/NativeUI";
import { createMenuItem } from "../util";
import moneyformat from "../moneyformat";
import { getAnimFromId } from "../util/animationSync";
import { getCreatedPedByName } from "../Ped/PedCreator";
import KeyBinder from 'ragemp-better-bindings';
export const hanfPlantObjects = {
stage1: mp.game.joaat('bkr_prop_weed_bud_pruned_01a'),
stage2: mp.game.joaat('bkr_prop_weed_bud_01b'),
stage3: mp.game.joaat('prop_weed_02'),
stage4: mp.game.joaat('prop_weed_01')
};
const hanfTimeToObject = [
{
minutes: 15,
object: hanfPlantObjects.stage1,
},
{
minutes: 60 * 1,
object: hanfPlantObjects.stage2
},
{
minutes: 60 * 3,
object: hanfPlantObjects.stage3
},
{
minutes: 60 * 4,
object: hanfPlantObjects.stage4
}
]
const minimumPlantDistance = 2;
const maximumPlantDuration = 6 * 60 * 60 * 1000; // 6 Stunden / 360 Minuten / 21600 Sekunden / 21600000 Millisekunden
const timeToHarvestPlant = 4 * 60 * 60 * 1000; // 4 Stunden
export default function hanfSystem(globalData: IGlobalData) {
let currentPlantingPreviewObject: ObjectMp = null;
let currentPlantingMarkerPreview: MarkerMp = null;
let currentlyPlanting: boolean = false;
let lastPlantingState = true;
mp.events.add("SERVER:Hanf_BuySeed", (maxSeedsToBuy, price) => {
if (globalData.InMenu || globalData.InChat) {
return;
}
globalData.InMenu = true;
var menu = new Menu("Samen kaufen", "Kaufe dir Hanfsamen", new Point(50, 50));
var seedsToBuy = 0;
var countItems = [...Array(maxSeedsToBuy).keys()].map(x => x + 1);
var soloPriceItem = createMenuItem("Einzelpreis", "Preis pro Samen", item => {
item.SetRightLabel("$" + moneyformat(price));
});
menu.AddItem(soloPriceItem);
var countItem = new UIMenuListItem("Anzahl", "Wähle die Anzahl der Samen aus", new ItemsCollection(countItems), 0);
menu.AddItem(countItem);
var buyItem = new UIMenuItem("Kaufen", "Kaufe die Samen");
buyItem.BackColor = new Color(0, 100, 0);
buyItem.HighlightedBackColor = new Color(0, 150, 0);
menu.AddItem(buyItem);
var completePriceItem = new UIMenuItem("Gesamtpreis", "Preis für alle Samen");
menu.AddItem(completePriceItem);
menu.ListChange.on((item, index) => {
if (item === countItem) {
seedsToBuy = Number(countItem.SelectedValue);
completePriceItem.SetRightLabel("$" + moneyformat(seedsToBuy * price));
}
});
menu.ItemSelect.on((item, index) => {
if (item === buyItem) {
mp.events.callRemote("CLIENT:Hanf_BuySeeds", seedsToBuy);
menu.Close();
}
});
menu.MenuClose.on(() => {
globalData.InMenu = false;
});
menu.Open();
});
mp.events.add("SERVER:Hanf_SellCannabisMenu", (maxCannabisToSell, price) => {
if (globalData.InMenu || globalData.InChat) {
return;
}
globalData.InMenu = true;
var menu = new Menu("Cannabis verkaufen", "Verkaufe dein Cannabis", new Point(50, 50));
var cannabisToSell = 0;
var countItems = [...Array(maxCannabisToSell).keys()].map(x => x + 1);
var soloPriceItem = createMenuItem("Einzelpreis", "Preis pro Hanfblüte", item => {
item.SetRightLabel("$" + moneyformat(price));
});
menu.AddItem(soloPriceItem);
var countItem = new UIMenuListItem("Anzahl", "Wähle die Anzahl der Blüten aus", new ItemsCollection(countItems), 0);
menu.AddItem(countItem);
var buyItem = new UIMenuItem("Verkaufen", "Verkaufe dein Cannabis");
buyItem.BackColor = new Color(0, 100, 0);
buyItem.HighlightedBackColor = new Color(0, 150, 0);
menu.AddItem(buyItem);
var completePriceItem = new UIMenuItem("Gesamtpreis", "Preis für alle Blüten");
menu.AddItem(completePriceItem);
menu.ListChange.on((item, index) => {
if (item === countItem) {
cannabisToSell = Number(countItem.SelectedValue);
completePriceItem.SetRightLabel("$" + moneyformat(cannabisToSell * price));
}
});
menu.ItemSelect.on((item, index) => {
if (item === buyItem) {
mp.events.callRemote("CLIENT:Hanf_SellCannabis", cannabisToSell);
menu.Close();
}
});
menu.MenuClose.on(() => {
globalData.InMenu = false;
});
menu.Open();
});
mp.events.add("SERVER:Hanf_PlayManufacturerAnim", animId => {
var anim = getAnimFromId(animId);
var npc = getCreatedPedByName("hanf_verarbeiter_typ");
npc.taskPlayAnim(anim.dict, anim.name, 1, 0, 1000 * 10, 1, 0, !1, !1, !1);
setTimeout(() => {
npc.stopAnim(anim.name, anim.dict, 3);
npc.stopAnimTask(anim.dict, anim.name, 3);
}, 1000 * 10);
});
mp.events.add("SERVER:Hanf_StartPlanting", _ => {
let player = mp.players.local;
currentPlantingPreviewObject = mp.objects.new(hanfPlantObjects.stage1, player.position, {
alpha: 255
});
currentPlantingPreviewObject.notifyStreaming = true;
currentlyPlanting = true;
});
mp.events.add(RageEnums.EventKey.RENDER, _ => {
if (!currentlyPlanting) {
return;
}
var player = mp.players.local;
var newPlantState = isAbleToPlant();
var markerColor: [number, number, number, number] = [0, 255, 0, 255];
if (!newPlantState) {
markerColor = [255, 0, 0, 255];
}
if (currentPlantingMarkerPreview) {
currentPlantingMarkerPreview.destroy();
}
var playerPos = player.position;
var objectPos = new mp.Vector3(playerPos.x, playerPos.y, playerPos.z - 1.0);
currentPlantingMarkerPreview = mp.markers.new(25, objectPos, 0.7, {
color: markerColor,
visible: true,
rotation: new mp.Vector3(1, 0, 0)
});
});
mp.events.add(RageEnums.EventKey.ENTITY_STREAM_IN, entity => {
if (entity === currentPlantingPreviewObject) {
currentPlantingPreviewObject.attachTo(Number(mp.players.local.handle), 0, 0, 0.2, -0.95, 0, 0, 0, true, false, false, false, 0, true);
}
});
function isAbleToPlant() {
var player = mp.players.local;
if (isNearPlant(minimumPlantDistance)) {
return false;
}
if (!isSurfaceAllowed()) {
return false;
}
if (currentPlantingPreviewObject) {
var objectPos = getPlantPreviewPosition();
var realZ = mp.game.gameplay.getGroundZFor3dCoord(objectPos.x, objectPos.y, objectPos.z + 1, 0, false);
if (realZ > objectPos.z + 1) {
return false;
}
}
if (player.isSwimming() || player.isSwimmingUnderWater() || !player.isOnFoot() || player.isSprinting() || player.isShooting()) {
return false;
}
return true;
}
const RAYCAST_POINT_TO_POINT_NATIVE = "0x377906D8A31E5586";
const GET_RAYCAST_RESULT_NATIVE = "0x65287525D951F6BE";
function isSurfaceAllowed() {
return true;
const player = mp.players.local;
var position = getPlantPreviewPosition();
var raycast = mp.game.invoke(RAYCAST_POINT_TO_POINT_NATIVE, position.x, position.y, position.z + 5, position.x, position.y, position.z - 5, 1, 0, 7);
mp.gui.chat.push("raycast = " + raycast);
var resultObj = {
hit: [false],
coord: [new mp.Vector3()],
surface: [new mp.Vector3()],
material: [0],
entityHit: [null]
};
var raycastResult = -1;
var retries = 10;
do {
raycastResult = mp.game.invoke(GET_RAYCAST_RESULT_NATIVE, raycast, resultObj.hit, resultObj.coord, resultObj.surface, resultObj.material, resultObj.entityHit);
retries--;
} while (raycastResult != 0 && raycastResult != 2 && retries > 0);
mp.gui.chat.push("result: " + raycastResult + ", result = " + JSON.stringify(resultObj));
return true;
}
KeyBinder.bind('e', _ => {
if (globalData.InChat) {
return;
}
if (!currentlyPlanting) {
var nearPlant = isNearPlant(0.5);
if (!nearPlant) {
return;
}
mp.events.callRemote("CLIENT:Hanf_HarvestHanf", nearPlant.Id);
return;
}
if (!lastPlantingState) {
mp.game.graphics.notify("~r~Hier kann kein Hanf platziert werden");
return;
}
currentlyPlanting = false;
var player = mp.players.local;
if (currentPlantingPreviewObject) {
currentPlantingPreviewObject.destroy();
currentPlantingPreviewObject = null;
}
if (currentPlantingMarkerPreview) {
currentPlantingMarkerPreview.destroy();
currentPlantingMarkerPreview = null;
}
var position = getPlantPreviewPosition();
var realZ = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z + 2, 0, false);
mp.events.callRemote("CLIENT:Hanf_PlantHanf", position.x, position.y, realZ);
});
function getPlantPreviewPosition(): Vector3Mp {
return mp.players.local.getOffsetFromInWorldCoords(0, 0.2, -1);
}
function getPlantText(plant: CannabisData) {
var time = Date.now() - Date.parse(plant.Time);
if (time > maximumPlantDuration) {
return ("~g~Hanf~n~~r~Verrottet");
}
return (`~g~Hanf~n~Fortschritt: ${getPlantPercentage(plant).toFixed(2)}%`);
}
function getPlantPercentage(plant: CannabisData) {
var time = Date.now() - Date.parse(plant.Time);
return Math.min((time / timeToHarvestPlant) * 100, 100);
}
function isNearPlant(distance: number): CannabisData {
var pos = getPlantPreviewPosition();
var nearPlants = currentHanfData.filter(h =>
mp.game.gameplay.getDistanceBetweenCoords(pos.x, pos.y, pos.z, h.X, h.Y, h.Z, true) < distance);
if (!nearPlants || nearPlants.length == 0) {
return null;
}
nearPlants = nearPlants.sort((a, b) =>
Number(mp.game.gameplay.getDistanceBetweenCoords(pos.x, pos.y, pos.z, a.X, a.Y, a.Z, true) <
mp.game.gameplay.getDistanceBetweenCoords(pos.x, pos.y, pos.z, b.X, b.Y, b.Z, true)));
return nearPlants[0];
}
let currentHanfData: Array<CannabisData> = [];
let hanfDataIdToObjectMap: Map<number, ObjectMp> = new Map<number, ObjectMp>();
let hanfDataIdToTextLabelMap: Map<number, TextLabelMp> = new Map<number, TextLabelMp>();
mp.events.add("SERVER:Hanf_UpdateHanfData", dataJson => {
mp.console.logInfo(dataJson);
var data: Array<CannabisData> = <Array<CannabisData>>JSON.parse(dataJson)
var newPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 0);
var removedPlants = currentHanfData.filter(d => data.filter(x => x.Id === d.Id).length == 0);
var existingPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 1);
newPlants.forEach(plant => {
var model = getPlantModel(plant);
var object = mp.objects.new(getPlantModel(plant), new mp.Vector3(plant.X, plant.Y, plant.Z));
hanfDataIdToObjectMap.set(plant.Id, object);
var textLabel = mp.labels.new(getPlantText(plant), new mp.Vector3(plant.X, plant.Y, plant.Z + 1), {
los: true,
drawDistance: 2
});
hanfDataIdToTextLabelMap.set(plant.Id, textLabel);
});
removedPlants.forEach(plant => {
var object = hanfDataIdToObjectMap.get(plant.Id);
hanfDataIdToObjectMap.delete(plant.Id);
object.destroy();
var textLabel = hanfDataIdToTextLabelMap.get(plant.Id);
textLabel.destroy();
hanfDataIdToTextLabelMap.delete(plant.Id);
});
existingPlants.forEach(plant => {
var object = hanfDataIdToObjectMap.get(plant.Id);
var model = getPlantModel(plant);
if (model != object.model) {
object.destroy();
var object = mp.objects.new(model, new mp.Vector3(plant.X, plant.Y, plant.Z));
hanfDataIdToObjectMap.delete(plant.Id);
hanfDataIdToObjectMap.set(plant.Id, object);
}
var textLabel = hanfDataIdToTextLabelMap.get(plant.Id);
textLabel.text = getPlantText(plant);
});
currentHanfData = data;
});
function getPlantModel(plant: CannabisData): number {
var diff = Date.now() - Date.parse(plant.Time);
var model = -1;
var dbgTxt;
if (diff <= 30 * 60 * 1000) { // 0 - 30 Minuten
model = hanfPlantObjects.stage1;
dbgTxt = "30 Minuten";
} else if (diff <= 4 * 60 * 60 * 1000) { // 30 - 240 Minuten / 4 Stunden
model = hanfPlantObjects.stage3;
dbgTxt = "3 Stunden";
} else { // Ausgewachsen / Ab 4 Stunden
model = hanfPlantObjects.stage4;
dbgTxt = "4 Stunden";
}
//mp.gui.chat.push("plant id = " + plant.Id + ", age = " + dbgTxt);
return model;
}
mp.events.addProc("SERVER:Hanf_GetModelToGivePlayer", id => {
var plant = currentHanfData.filter(x => x.Id == id)[0];
var model = getPlantModel(plant);
if (model == hanfPlantObjects.stage1) {
return 1;
} else if (model == hanfPlantObjects.stage3) {
return 2;
} else if (model == hanfPlantObjects.stage4) {
return 3;
}
});
//var rotationTestObject: ObjectMp = null;
//var a1: number, a2: number, a3: number, a4: number, a5: number, a6: number;
//mp.events.add(RageEnums.EventKey.PLAYER_COMMAND, (f) => {
// var args = f.split(' ');
// if (args[0] != "a") {
// return;
// }
// a1 = parseFloat(args[1] || "0");
// a2 = parseFloat(args[2] || "0");
// a3 = parseFloat(args[3] || "0");
// a4 = parseFloat(args[4] || "0");
// a5 = parseFloat(args[5] || "0");
// a6 = parseFloat(args[6] || "0");
// mp.gui.chat.push(`a1: ${a1.toFixed(2)}, a2: ${a2.toFixed(2)}, a3: ${a3.toFixed(2)}, a4: ${a4.toFixed(2)}, a5: ${a5.toFixed(2)}, a6: ${a6.toFixed(2)},`)
// if (rotationTestObject != null) {
// rotationTestObject.attachTo(Number(mp.players.local.handle), mp.players.local.getBoneIndex(57005), a1, a2, a3, a4, a5, a6, true, false, false, false, 0, true);
// return;
// }
// rotationTestObject = mp.objects.new(mp.game.joaat("prop_cs_trowel"), mp.players.local.position, {
// alpha: 255
// });
//});
}

View File

@@ -168,5 +168,5 @@ export {
EntityType, EntityType,
AccountData, AccountData,
VehicleData, VehicleData,
DoorState DoorState,
} }

View File

@@ -97,6 +97,14 @@ declare type RentcarProperty = {
Price: number; Price: number;
} }
declare type CannabisData = {
Id: number;
X: number;
Y: number;
Z: number;
Time: string;
}
declare type PlayerCharacterData = { declare type PlayerCharacterData = {
Gender: boolean; Gender: boolean;
Father: number; Father: number;

View File

@@ -295,6 +295,9 @@ rentCar(globalData);
import Carwash from './util/carwash'; import Carwash from './util/carwash';
Carwash(globalData); Carwash(globalData);
import hanfSystem from './drugs/hanf';
hanfSystem(globalData);
require('./Gui/policedepartment'); require('./Gui/policedepartment');
require('./Gui/helptext'); require('./Gui/helptext');
require('./admin/spectate'); require('./admin/spectate');

View File

@@ -21,14 +21,14 @@
invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html'); invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html');
}); });
mp.events.add('inventoryShow', () => { mp.events.add('inventoryShow', (force = undefined) => {
if (!globalData.InMenu && !loaded) { if (!globalData.InMenu && !loaded || force === true) {
globalData.InMenu = true; globalData.InMenu = true;
mp.gui.cursor.show(true, true); mp.gui.cursor.show(true, true);
loaded = true; loaded = true;
invBrowser.execute(`showInventory()`); invBrowser.execute(`showInventory()`);
} else if (loaded) { } else if (loaded || force === true) {
globalData.InMenu = false; globalData.InMenu = false;
mp.gui.cursor.show(false, false); mp.gui.cursor.show(false, false);
loaded = false; loaded = false;

View File

@@ -1,5 +1,43 @@
import { debug } from "util"; import { debug } from "util";
const animationSyncData =
{
animations: [],
register: function (name, animDict, animName, duration, loop, flag, endless, eventAfter: string = null) {
let id = mp.game.joaat(name);
if (!this.animations.hasOwnProperty(id)) {
this.animations[id] =
{
id: id,
name: name,
animDict: animDict,
animName: animName,
duration: duration,
loop: loop,
flag: flag,
endless: endless,
eventAfter: eventAfter
};
} else {
mp.game.graphics.notify("Animation Sync Error: ~r~Duplicate Entry");
}
},
getAnimFromId: function (name: string): { dict: string, name: string } {
var anim = this.animations[mp.game.joaat(name)];
return {
dict: anim.animDict,
name: anim.animName
}
}
};
export function getAnimFromId(name: string) {
return animationSyncData.getAnimFromId(name);
}
export default function animationSync() { export default function animationSync() {
let blockInput = false; let blockInput = false;
let animationBreakTimer; let animationBreakTimer;
@@ -12,37 +50,17 @@ export default function animationSync() {
animationSyncData.register("getUncuff", "mp_arresting", "b_uncuff", 5500, false, 0, false); animationSyncData.register("getUncuff", "mp_arresting", "b_uncuff", 5500, false, 0, false);
animationSyncData.register("hup", "mp_am_hold_up", "handsup_base", -1, true, 50, true); animationSyncData.register("hup", "mp_am_hold_up", "handsup_base", -1, true, 50, true);
animationSyncData.register("carryBox", "anim@heists@box_carry@", "idle", -1, true, 50, true); animationSyncData.register("carryBox", "anim@heists@box_carry@", "idle", -1, true, 50, true);
animationSyncData.register("manufacturJoint", "anim@mp_snowball", "pickup_snowball", 1000 * 10, false, 1, false);
//animationSyncData.register("harvestPlantEnter", "amb@world_human_gardener_plant@female@enter", "enter_female", 1000 * 3.5, false, 1, false);
animationSyncData.register("harvestPlant", "amb@world_human_gardener_plant@male@base", "base", 1000 * 10, false, 1, false, "Hanf_FinishDiggingAnimation");
//animationSyncData.register("harvestPlantExit", "amb@world_human_gardener_plant@female@exit", "exit_female", 1000 * 3.5, false, 1, false, "Hanf_FinishDiggingAnimation");
animationSyncData.register("jointUse", "amb@world_human_smoking_pot@male@base", "base", 1000 * 10, false, 1, false);
}); });
const animationBreakMessage = [ const animationBreakMessage = [
{ animName: "Cuffed", msg: "Handschellen gebrochen." } { animName: "Cuffed", msg: "Handschellen gebrochen." }
]; ];
const animationSyncData =
{
animations: [],
register: function (name, animDict, animName, duration, loop, flag, endless) {
let id = mp.game.joaat(name);
if (!this.animations.hasOwnProperty(id)) {
this.animations[id] =
{
id: id,
name: name,
animDict: animDict,
animName: animName,
duration: duration,
loop: loop,
flag: flag,
endless: endless
};
} else {
mp.game.graphics.notify("Animation Sync Error: ~r~Duplicate Entry");
}
}
};
/* /*
mp.events.add("entityStreamIn", (entity) => { mp.events.add("entityStreamIn", (entity) => {
if (entity.type === "player" && entity.animationData) { if (entity.type === "player" && entity.animationData) {
@@ -90,6 +108,7 @@ export default function animationSync() {
clearTimeout(animationBreakTimer); clearTimeout(animationBreakTimer);
animationBreakTimer = null; animationBreakTimer = null;
} }
if (string == null) { if (string == null) {
blockInput = false; blockInput = false;
return; return;
@@ -101,7 +120,7 @@ export default function animationSync() {
let animData = animationSyncData.animations[index]; let animData = animationSyncData.animations[index];
let { id, name, animDict, animName, duration, loop, flag, endless } = animData; let { id, name, animDict, animName, duration, loop, flag, endless, eventAfter } = animData;
loadAnimDict(animDict, function () { loadAnimDict(animDict, function () {
mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1)
@@ -116,6 +135,9 @@ export default function animationSync() {
let a = setTimeout(function () { let a = setTimeout(function () {
clearTimeout(a); clearTimeout(a);
mp.events.callRemote("CLIENT:ClearAnimationData", true); mp.events.callRemote("CLIENT:ClearAnimationData", true);
if (eventAfter) {
mp.events.callRemote("CLIENT:" + eventAfter);
}
}, duration); }, duration);
} }
} }

View File

@@ -1,4 +1,5 @@
import { IGame, IEntity } from "../game"; import { IGame, IEntity } from "../game";
import { hanfPlantObjects } from "../drugs/hanf";
export default function attachmentManager(game: IGame) { export default function attachmentManager(game: IGame) {
mp.events.add("SERVER:LoadAttachments", () => { mp.events.add("SERVER:LoadAttachments", () => {
@@ -9,6 +10,10 @@ export default function attachmentManager(game: IGame) {
attachmentMngr.register("weapondeal1", "ex_office_swag_guns02", "chassis_dummy", new mp.Vector3(0, 0.8, 0), new mp.Vector3(0, 0, 0)); attachmentMngr.register("weapondeal1", "ex_office_swag_guns02", "chassis_dummy", new mp.Vector3(0, 0.8, 0), new mp.Vector3(0, 0, 0));
attachmentMngr.register("weapondeal2", "w_sg_pumpshotgun", "chassis_dummy", new mp.Vector3(0.4, 1.6, 0.62), new mp.Vector3(90, 0, 180)); attachmentMngr.register("weapondeal2", "w_sg_pumpshotgun", "chassis_dummy", new mp.Vector3(0.4, 1.6, 0.62), new mp.Vector3(90, 0, 180));
attachmentMngr.register("handcuffs", "p_cs_cuffs_02_s", 28422, new mp.Vector3(-0.05, 0, 0), new mp.Vector3(90, 90, 0)); attachmentMngr.register("handcuffs", "p_cs_cuffs_02_s", 28422, new mp.Vector3(-0.05, 0, 0), new mp.Vector3(90, 90, 0));
attachmentMngr.register("shovel", "prop_cs_trowel", 28422, new mp.Vector3(0.1, 0.0, 0.0), new mp.Vector3(120, 70, 0));
attachmentMngr.register("CannabisPlantInHand1", hanfPlantObjects.stage1, 28422, new mp.Vector3(), new mp.Vector3());
attachmentMngr.register("CannabisPlantInHand2", hanfPlantObjects.stage3, 28422, new mp.Vector3(), new mp.Vector3());
attachmentMngr.register("CannabisPlantInHand3", hanfPlantObjects.stage4, 28422, new mp.Vector3(), new mp.Vector3());
}); });
const attachmentMngr = const attachmentMngr =
@@ -140,7 +145,7 @@ export default function attachmentManager(game: IGame) {
targetEntity, bone, targetEntity, bone,
offset.x, offset.y, offset.z, offset.x, offset.y, offset.z,
rotation.x, rotation.y, rotation.z, rotation.x, rotation.y, rotation.z,
false, false, false, false, 2, true true, false, false, false, 0, true
); );
} }

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace ReallifeGamemode.Database.Entities
{
public class CannabisPlant
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public DateTime PlantDate { get; set; }
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
public bool Harvested { get; set; }
public User PlantedBy { get; set; }
[ForeignKey(nameof(PlantedBy))]
public int PlantedById { get; set; }
}
}

View File

@@ -129,6 +129,10 @@ namespace ReallifeGamemode.Database.Entities
public bool FreeSurgery { get; set; } = true; public bool FreeSurgery { get; set; } = true;
public DateTime? LastTimeBoughtCannabisSeeds { get; set; }
public int CannabisSeedsBoughtToday { get; set; }
[NotMapped] [NotMapped]
public Player Player public Player Player
{ {

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Database.Migrations
{
public partial class AddCannabisPlants : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CannabisPlants",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PlantDate = table.Column<DateTime>(nullable: false),
X = table.Column<float>(nullable: false),
Y = table.Column<float>(nullable: false),
Z = table.Column<float>(nullable: false),
Harvested = table.Column<bool>(nullable: false),
PlantedById = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CannabisPlants", x => x.Id);
table.ForeignKey(
name: "FK_CannabisPlants_Users_PlantedById",
column: x => x.PlantedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CannabisPlants_PlantedById",
table: "CannabisPlants",
column: "PlantedById");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CannabisPlants");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Database.Migrations
{
public partial class AddUserCannabisSeedBuyData : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "CannabisSeedsBoughtToday",
table: "Users",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<DateTime>(
name: "LastTimeBoughtCannabisSeeds",
table: "Users",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CannabisSeedsBoughtToday",
table: "Users");
migrationBuilder.DropColumn(
name: "LastTimeBoughtCannabisSeeds",
table: "Users");
}
}
}

View File

@@ -154,6 +154,37 @@ namespace ReallifeGamemode.Database.Migrations
b.ToTable("BusinessData"); b.ToTable("BusinessData");
}); });
modelBuilder.Entity("ReallifeGamemode.Database.Entities.CannabisPlant", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("Harvested")
.HasColumnType("tinyint(1)");
b.Property<DateTime>("PlantDate")
.HasColumnType("datetime(6)");
b.Property<int>("PlantedById")
.HasColumnType("int");
b.Property<float>("X")
.HasColumnType("float");
b.Property<float>("Y")
.HasColumnType("float");
b.Property<float>("Z")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("PlantedById");
b.ToTable("CannabisPlants");
});
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Character", b => modelBuilder.Entity("ReallifeGamemode.Database.Entities.Character", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -1425,6 +1456,9 @@ namespace ReallifeGamemode.Database.Migrations
b.Property<int?>("BusinessId") b.Property<int?>("BusinessId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("CannabisSeedsBoughtToday")
.HasColumnType("int");
b.Property<int?>("CharacterId") b.Property<int?>("CharacterId")
.HasColumnType("int"); .HasColumnType("int");
@@ -1474,6 +1508,9 @@ namespace ReallifeGamemode.Database.Migrations
b.Property<int?>("JobId") b.Property<int?>("JobId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<DateTime?>("LastTimeBoughtCannabisSeeds")
.HasColumnType("datetime(6)");
b.Property<int>("LogUserId") b.Property<int>("LogUserId")
.HasColumnType("int"); .HasColumnType("int");
@@ -1931,6 +1968,15 @@ namespace ReallifeGamemode.Database.Migrations
.HasForeignKey("BusRouteId"); .HasForeignKey("BusRouteId");
}); });
modelBuilder.Entity("ReallifeGamemode.Database.Entities.CannabisPlant", b =>
{
b.HasOne("ReallifeGamemode.Database.Entities.User", "PlantedBy")
.WithMany()
.HasForeignKey("PlantedById")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Character", b => modelBuilder.Entity("ReallifeGamemode.Database.Entities.Character", b =>
{ {
b.HasOne("ReallifeGamemode.Database.Entities.User", "User") b.HasOne("ReallifeGamemode.Database.Entities.User", "User")

View File

@@ -179,6 +179,8 @@ namespace ReallifeGamemode.Database.Models
//Server Variablen //Server Variablen
public DbSet<Entities.ServerVariable> ServerVariables { get; set; } public DbSet<Entities.ServerVariable> ServerVariables { get; set; }
public DbSet<Entities.CannabisPlant> CannabisPlants { get; set; }
} }
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<DatabaseContext> public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<DatabaseContext>

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Server.Log;
namespace ReallifeGamemode.Server
{
public abstract class BaseScript : Script
{
protected static ILogger logger { get; private set; }
public BaseScript()
{
logger = LogManager.GetLogger(this.GetType());
}
}
}

View File

@@ -2231,26 +2231,19 @@ namespace ReallifeGamemode.Server.Commands
return; return;
} }
var invWeight = 0; var invWeight = InventoryManager.GetUserInventoryWeight(target);
using (var context = new DatabaseContext()) IItem item = InventoryManager.GetItemById(itemId);
{
List<UserItem> userItems = context.UserItems.ToList().FindAll(i => i.UserId == target.GetUser().Id);
foreach (var uItem in userItems)
{
invWeight += uItem.Amount * InventoryManager.GetItemById(uItem.ItemId).Gewicht;
}
}
if (invWeight + (amount * InventoryManager.GetItemById(itemId).Gewicht) > 40000) if (invWeight + (amount * item.Gewicht) > InventoryManager.MAX_USER_INVENTORY)
{ {
ChatService.SendMessage(player, "~y~" + target.Name + " ~s~hat nicht mehr genug Platz in seinem Inventar."); ChatService.SendMessage(player, "~y~" + target.Name + " ~s~hat nicht mehr genug Platz in seinem Inventar.");
} }
else else
{ {
UserItem item = new UserItem() { ItemId = itemId, UserId = target.GetUser().Id, Amount = amount }; UserItem userItem = new UserItem() { ItemId = itemId, UserId = target.GetUser().Id, Amount = amount };
InventoryManager.AddItemToInventory(target, item.ItemId, item.Amount); InventoryManager.AddItemToInventory(target, userItem.ItemId, userItem.Amount);
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast " + target.Name + " ~g~" + amount + "~s~ mal das Item gegeben."); ChatService.SendMessage(player, $"~b~[ADMIN]~s~ Du hast ~y~{target.Name}~y~ ~y~{amount}~s~ mal das Item ~y~{item.Name}~s~ gegeben.");
} }
} }
@@ -2340,7 +2333,7 @@ namespace ReallifeGamemode.Server.Commands
} }
[Command("inventory", "~m~Benutzung: ~s~/inventory [Spieler]")] [Command("inventory", "~m~Benutzung: ~s~/inventory [Spieler]")]
public void CmdAdminGiveItem(Player player, string targetname) public void CmdAdminInventory(Player player, string targetname)
{ {
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
{ {
@@ -3398,6 +3391,19 @@ namespace ReallifeGamemode.Server.Commands
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen."); ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
} }
[Command("reloadhanf", "~m~Benutzung: ~s~/reloadhanf")]
public void CmdAdminReloadHanf(Player player)
{
if (!player.GetUser().IsAdmin(AdminLevel.HEADADMIN))
{
ChatService.NotAuthorized(player);
return;
}
HanfManager.UpdateHanfWorldData(new DatabaseContext());
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Hanfpflanzen wurden erfolgreich neugeladen.");
}
//[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)] //[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
//public void CmdAdminHouse(Player player, string option1 = null, string option2 = null) //public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
//{ //{

View File

@@ -47,6 +47,14 @@ namespace ReallifeGamemode.Server.Events
return; return;
} }
if(player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant"))
{
var currentModel = player.GetData<int>("HoldingCannabisPlant");
player.AddAttachment("CannabisPlantInHand" + currentModel, true);
player.ResetData("IsCarryingPlant");
}
using var dbContext = new DatabaseContext(); using var dbContext = new DatabaseContext();
User user = player.GetUser(dbContext); User user = player.GetUser(dbContext);

View File

@@ -41,6 +41,14 @@ namespace ReallifeGamemode.Server.Events
return; return;
} }
if (player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant"))
{
var currentModel = player.GetData<int>("HoldingCannabisPlant");
player.AddAttachment("CannabisPlantInHand" + currentModel, true);
player.ResetData("IsCarryingPlant");
}
var logEntry = new LoginLogoutLogEntry() var logEntry = new LoginLogoutLogEntry()
{ {
LoginLogout = false, LoginLogout = false,

View File

@@ -23,7 +23,7 @@ namespace ReallifeGamemode.Server.Events
if (vehicle.HasMarkerBehind()) if (vehicle.HasMarkerBehind())
vehicle.RemoveMarkerBehind(); vehicle.RemoveMarkerBehind();
if(vehicle != null && !string.IsNullOrEmpty(client.Name)) if (vehicle != null && !string.IsNullOrEmpty(client.Name))
{ {
if (!VehicleManager.lastDriversInVehicle.ContainsKey(vehicle)) if (!VehicleManager.lastDriversInVehicle.ContainsKey(vehicle))
{ {
@@ -39,13 +39,10 @@ namespace ReallifeGamemode.Server.Events
if ((vehicle.Class != 16 && vehicle.Class != 15) && u.DriverLicenseVehicle == false) if ((vehicle.Class != 16 && vehicle.Class != 15) && u.DriverLicenseVehicle == false)
{ {
client.SendNotification("Du besitzt keinen Führerschein!"); client.SendNotification("Du besitzt keinen Führerschein!");
return;
} }
else if ((vehicle.Class == 16 && u.FlyingLicensePlane == false) || (vehicle.Class == 15 && u.FlyingLicensePlane == false)) //planes = 16 helicopter = 15
if ((vehicle.Class == 16 && u.FlyingLicensePlane == false) || (vehicle.Class == 15 && u.FlyingLicensePlane == false)) //planes = 16 helicopter = 15
{ {
client.SendNotification("Du besitzt keinen Flugschein!"); client.SendNotification("Du besitzt keinen Flugschein!");
return;
} }
} }

View File

@@ -21,6 +21,8 @@ using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.WeaponDeal; using ReallifeGamemode.Server.WeaponDeal;
using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Inventory.Items;
using Microsoft.EntityFrameworkCore;
using ReallifeGamemode.Server.Wanted; using ReallifeGamemode.Server.Wanted;
/** /**
@@ -217,9 +219,61 @@ namespace ReallifeGamemode.Server.Events
[RemoteEvent("keyPress:E")] [RemoteEvent("keyPress:E")]
public void KeyPressE(Player player) public void KeyPressE(Player player)
{ {
if (!player.IsLoggedIn() || player.GetData<bool>("isDead") || player.IsInVehicle) return; if (!player.IsLoggedIn() || player.GetData<bool>("isDead")) return;
var user = player.GetUser(); var user = player.GetUser();
if (player.IsInVehicle
&& player.VehicleSeat == 0
&& player.Vehicle.Model == (uint)VehicleHash.Riot
&& (user.FactionId == 1 || user.FactionId == 3)
&& player.Position.DistanceTo(HanfManager.ASSERVATENKAMMER_POSITION) <= 3
/*&& player.IsDuty()*/)
{
using var dbContext = new DatabaseContext();
GTANetworkAPI.Vehicle veh = player.Vehicle;
ServerVehicle serverVehicle = veh.GetServerVehicle(dbContext);
List<VehicleItem> items = InventoryManager.GetVehicleItems(veh);
if (items.Count() == 0)
{
player.SendNotification("Der Riot ist leer");
return;
}
IIllegalItem cannabisItem = InventoryManager.GetItem<Cannabis>();
IIllegalItem cannabisSeedItem = InventoryManager.GetItem<CannabisSeeds>();
VehicleItem vehicleCannabisItem = items.Where(i => i.ItemId == cannabisItem.Id).FirstOrDefault();
VehicleItem vehicleCannabisSeedItem = items.Where(i => i.ItemId == cannabisSeedItem.Id).FirstOrDefault();
int cannabisAmount = vehicleCannabisItem?.Amount ?? 0;
int cannabisSeedAmount = vehicleCannabisSeedItem?.Amount ?? 0;
InventoryManager.RemoveVehicleItem(serverVehicle, vehicleCannabisItem, cannabisAmount, player);
InventoryManager.RemoveVehicleItem(serverVehicle, vehicleCannabisSeedItem, cannabisSeedAmount, player);
var price = cannabisSeedAmount * cannabisSeedItem.PriceForConfiscation + cannabisAmount * cannabisItem.PriceForConfiscation;
logger.LogInformation("Player {0} unloaded the riot truck with {1} cannabis and {2} cannabis seed and the faction got {3}", player.Name, cannabisAmount, cannabisSeedAmount, price);
var factions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3);
foreach (var faction in factions)
{
faction.BankAccount.Balance += price;
}
player.SendNotification("~g~Der Riot wurde erfolgreich entladen");
dbContext.SaveChanges();
return;
}
if (player.IsInVehicle)
{
return;
}
if (player.HasData("nearATM")) if (player.HasData("nearATM"))
{ {
ATMManager.ShowAtmUi(player, player.GetData<int>("nearATM")); ATMManager.ShowAtmUi(player, player.GetData<int>("nearATM"));
@@ -243,6 +297,9 @@ namespace ReallifeGamemode.Server.Events
AmmunationPoint nearestAmmunationPoint = PositionManager.AmmunationPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); AmmunationPoint nearestAmmunationPoint = PositionManager.AmmunationPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
RentcarPoint nearestRentcarPoint = PositionManager.rentcarPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); RentcarPoint nearestRentcarPoint = PositionManager.rentcarPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
JailPoint nearestjailPoint = PositionManager.jailPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); JailPoint nearestjailPoint = PositionManager.jailPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
bool isNearCannabisSeedBuyPoint = HanfManager.IsPlayerNearSeedBuyPoint(player);
bool isNearJointManufacturerPoint = HanfManager.IsPlayerNearJointManufacturer(player);
bool isNearCannabisSellPoint = HanfManager.IsPlayerNearCannabisSellPoint(player);
if (user?.FactionId != null) if (user?.FactionId != null)
{ {
@@ -761,6 +818,51 @@ namespace ReallifeGamemode.Server.Events
return; return;
} }
} }
if (isNearCannabisSeedBuyPoint)
{
HanfManager.ShowPlayerBuySeedMenu(player);
return;
}
if (isNearJointManufacturerPoint)
{
HanfManager.BuildJointsFromCannabis(player);
return;
}
if (isNearCannabisSellPoint)
{
HanfManager.PlayerSellCannabis(player);
return;
}
if (player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant") && (user.FactionId == 3 || user.FactionId == 1) && player.IsDuty())
{
using var dbContext = new DatabaseContext();
FactionVehicle riot = dbContext.FactionVehicles.Where(f => f.Model == VehicleHash.Riot).ToList().Where(f => f.GetOwners().Contains(3)).FirstOrDefault();
if (riot == null)
{
return;
}
GTANetworkAPI.Vehicle riotVehicle = VehicleManager.GetVehicleFromServerVehicle(riot);
if (riotVehicle.Position.DistanceTo(player.Position) > 3)
{
return;
}
var currentModel = player.GetData<int>("HoldingCannabisPlant");
player.AddAttachment("CannabisPlantInHand" + currentModel, true);
player.ResetData("IsCarryingPlant");
var cannabisItem = InventoryManager.GetItem<Cannabis>();
var cannabisSeedsItem = InventoryManager.GetItem<CannabisSeeds>();
int itemIdToGive = currentModel == 3 ? cannabisItem.Id : cannabisSeedsItem.Id;
int amountToGive = currentModel == 3 ? new Random().Next(4, 10) + 1 : 1;
InventoryManager.AddItemToVehicleInventory(riotVehicle, itemIdToGive, amountToGive);
}
} }
[RemoteEvent("keyPress:I")] [RemoteEvent("keyPress:I")]
@@ -769,7 +871,7 @@ namespace ReallifeGamemode.Server.Events
if (!player.IsLoggedIn() || player.GetData<bool>("isDead")) return; if (!player.IsLoggedIn() || player.GetData<bool>("isDead")) return;
if (player.GetData<bool>("isDead")) return; if (player.GetData<bool>("isDead")) return;
player.TriggerEvent("inventoryShow"); player.ToggleInventory();
InventoryManager.SetBackpackItems(player); InventoryManager.SetBackpackItems(player);
} }

View File

@@ -115,6 +115,8 @@ namespace ReallifeGamemode.Server.Events
ChatService.BroadcastGroup(msg, user.Group); ChatService.BroadcastGroup(msg, user.Group);
} }
HanfManager.UpdateHanfForPlayer(player);
string message = string.Empty; string message = string.Empty;
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName)) if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))

View File

@@ -7,6 +7,7 @@ using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using System; using System;
using ReallifeGamemode.Database.Entities.Logs; using ReallifeGamemode.Database.Entities.Logs;
using ReallifeGamemode.Server.Managers;
/** /**
* @overview Life of German Reallife - Event Register (Register.cs) * @overview Life of German Reallife - Event Register (Register.cs)
@@ -29,7 +30,7 @@ namespace ReallifeGamemode.Server.Events
player.TriggerEvent("SERVER:Login_Error", "Das Passwort muss aus mindestens 6 Zeichen bestehen."); player.TriggerEvent("SERVER:Login_Error", "Das Passwort muss aus mindestens 6 Zeichen bestehen.");
return; return;
} }
if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count()!= 0) if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() != 0)
{ {
player.TriggerEvent("SERVER:Login_Error", "Es ist schon ein Konto mit dieser Socialclub-ID registriert."); player.TriggerEvent("SERVER:Login_Error", "Es ist schon ein Konto mit dieser Socialclub-ID registriert.");
return; return;
@@ -79,10 +80,12 @@ namespace ReallifeGamemode.Server.Events
currentPlayerCreatorDimension++; currentPlayerCreatorDimension++;
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension); NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension"); player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
player.TriggerEvent("toggleCreator",false); player.TriggerEvent("toggleCreator", false);
player.SafeTeleport(new Vector3(402.8664, -996.4108, -99.00027)); player.SafeTeleport(new Vector3(402.8664, -996.4108, -99.00027));
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ); //player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
HanfManager.UpdateHanfForPlayer(player);
if (GlobalHelper.CountdownUntil > DateTime.Now) if (GlobalHelper.CountdownUntil > DateTime.Now)
{ {
player.TriggerEvent("countdown", (GlobalHelper.CountdownUntil - DateTime.Now).TotalSeconds, GlobalHelper.CountdownText); player.TriggerEvent("countdown", (GlobalHelper.CountdownUntil - DateTime.Now).TotalSeconds, GlobalHelper.CountdownText);

View File

@@ -1,17 +1,21 @@
using System; using System;
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.WeaponDeal; using ReallifeGamemode.Server.WeaponDeal;
using ReallifeGamemode.Server.Log;
namespace ReallifeGamemode.Server.Events namespace ReallifeGamemode.Server.Events
{ {
public class Vehicle : Script public class Vehicle : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<Vehicle>();
[RemoteEvent("VehicleMenu_ToggleEngine")] [RemoteEvent("VehicleMenu_ToggleEngine")]
public void VehicleMenuToggleEngineEvent(Player player) public void VehicleMenuToggleEngineEvent(Player player)
{ {
@@ -271,6 +275,8 @@ namespace ReallifeGamemode.Server.Events
sV.PositionZ = pos.Z; sV.PositionZ = pos.Z;
sV.Heading = v.Heading; sV.Heading = v.Heading;
logger.LogInformation("Player {0} parked the car {1} at x:{2}, y:{3}, z:{4}", player.Name, sV.Id, pos.X, pos.Y, pos.Z);
player.SendNotification("~g~Das Fahrzeug wurde geparkt."); player.SendNotification("~g~Das Fahrzeug wurde geparkt.");

View File

@@ -477,5 +477,17 @@ namespace ReallifeGamemode.Server.Extensions
if (player.GetUser().Wanteds > 0) if (player.GetUser().Wanteds > 0)
PositionManager.cuffPoints.Add(player); PositionManager.cuffPoints.Add(player);
} }
public static void ToggleInventory(this Player player, InventoryToggleOption option = InventoryToggleOption.TOGGLE)
{
if(option == InventoryToggleOption.TOGGLE)
{
player.TriggerEvent("inventoryShow");
}
else
{
player.TriggerEvent("inventoryShow", option == InventoryToggleOption.SHOW);
}
}
} }
} }

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ReallifeGamemode.Server.Inventory.Interfaces
{
interface IIllegalItem : IItem
{
int PriceForConfiscation { get; }
}
}

View File

@@ -14,5 +14,7 @@ namespace ReallifeGamemode.Server.Inventory.Interfaces
int Gewicht { get; } int Gewicht { get; }
string Einheit { get; } string Einheit { get; }
int Price { get; } int Price { get; }
bool Legal { get; }
} }
} }

View File

@@ -1,4 +1,6 @@
using ReallifeGamemode.Database.Entities; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
/** /**
* @overview Life of German Reallife - Inventory Interfaces UsableItem (IUsableItem.cs) * @overview Life of German Reallife - Inventory Interfaces UsableItem (IUsableItem.cs)
@@ -10,6 +12,7 @@ namespace ReallifeGamemode.Server.Inventory.Interfaces
{ {
public interface IUsableItem : IItem, IDroppableItem //marker Interface public interface IUsableItem : IItem, IDroppableItem //marker Interface
{ {
bool Use(UserItem uItem); bool RemoveWhenUsed { get; }
bool Use(Player player, User user, DatabaseContext databaseContext);
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
@@ -20,10 +21,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Price => 50; public override int Price => 50;
public override float Cooldown => 60000; public override float Cooldown => 60000;
public override void Consume(UserItem uItem) public override void Consume(Player player, User user, DatabaseContext databaseContext)
{ {
Player player = uItem.GetUser().Player;
int amountToAdd = HpAmount; int amountToAdd = HpAmount;
if (player.Health + amountToAdd > 100) if (player.Health + amountToAdd > 100)
{ {
@@ -32,7 +31,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
player.SafeSetHealth(player.Health + amountToAdd); player.SafeSetHealth(player.Health + amountToAdd);
player.SendNotification("Du hast einen ~y~" + Name + " ~s~gegessen.", false); player.SendNotification("Du hast einen ~y~" + Name + " ~s~gegessen.", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
} }
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
@@ -21,10 +22,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override float Cooldown => 60000; public override float Cooldown => 60000;
public override void Consume(UserItem uItem) public override void Consume(Player player, User user, DatabaseContext databaseContext)
{ {
Player player = uItem.GetUser().Player;
int amountToAdd = HpAmount; int amountToAdd = HpAmount;
if (player.Health + amountToAdd > 100) if (player.Health + amountToAdd > 100)
{ {
@@ -33,7 +32,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
player.SafeSetHealth(player.Health + amountToAdd); player.SafeSetHealth(player.Health + amountToAdd);
player.SendNotification("Du hast ~y~" + Name + " ~s~gegessen.", false); player.SendNotification("Du hast ~y~" + Name + " ~s~gegessen.", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
} }
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
@@ -21,10 +22,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override float Cooldown => 180000; public override float Cooldown => 180000;
public override void Consume(UserItem uItem) public override void Consume(Player player, User user, DatabaseContext databaseContext)
{ {
Player player = uItem.GetUser().Player;
int amountToAdd = HpAmount; int amountToAdd = HpAmount;
if (player.Health + amountToAdd > 100) if (player.Health + amountToAdd > 100)
{ {
@@ -33,7 +32,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
player.SafeSetHealth(player.Health + amountToAdd); player.SafeSetHealth(player.Health + amountToAdd);
player.SendNotification("Du hast ein ~y~" + Name + " ~s~gegessen.", false); player.SendNotification("Du hast ein ~y~" + Name + " ~s~gegessen.", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
} }
} }
} }

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using ReallifeGamemode.Server.Inventory.Interfaces;
namespace ReallifeGamemode.Server.Inventory.Items
{
public abstract class BaseItem : IItem
{
public abstract int Id { get; }
public abstract string Name { get; }
public abstract string Description { get; }
public abstract int Gewicht { get; }
public abstract string Einheit { get; }
public abstract int Price { get; }
public virtual bool Legal => true;
}
}

View File

@@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
namespace ReallifeGamemode.Server.Inventory.Items namespace ReallifeGamemode.Server.Inventory.Items
{ {
@@ -18,7 +20,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override float Cooldown => 1000; public override float Cooldown => 1000;
public override void Consume(UserItem uItem) public override void Consume(Player player, User user, DatabaseContext databaseContext)
{ {
//nothing //nothing
} }

View File

@@ -9,13 +9,13 @@ using ReallifeGamemode.Server.Inventory.Interfaces;
namespace ReallifeGamemode.Server.Inventory.Items namespace ReallifeGamemode.Server.Inventory.Items
{ {
public class Cannabis : ConsumableItem public class Cannabis : DropItem, IIllegalItem
{ {
public override int Id => 108; public override int Id => 108;
public override string Name => "Grünes Gift"; public override string Name => "Cannabis";
public override string Description => "puff puff and pass"; public override string Description => "kein brokkoli";
public override int Gewicht => 2; public override int Gewicht => 2;
@@ -25,13 +25,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Price => 0; public override int Price => 0;
public override int HpAmount => -5; public override bool Legal => false;
public override float Cooldown => 20000; public int PriceForConfiscation { get; } = 5;
public override void Consume(UserItem uItem)
{
//nothing
}
} }
} }

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Managers;
namespace ReallifeGamemode.Server.Inventory.Items
{
public class CannabisSeeds : UseItem, IIllegalItem
{
public override int Id { get; } = 109;
public override string Name { get; } = "Cannabis Samen";
public override string Description { get; } = "vierhundertzwanzig lodere es";
public override int Gewicht { get; } = 10;
public override string Einheit { get; } = "g";
public override int Price { get; } = 0;
public override bool Legal => false;
public override uint Object { get; }
public override bool RemoveWhenUsed { get; } = false;
public int PriceForConfiscation { get; } = 10;
public override bool Use(Player player, User user, DatabaseContext databaseContext)
{
if (!player.IsInVehicle)
{
HanfManager.StartCannabisPlanting(player);
}
return true;
}
}
}

View File

@@ -1,5 +1,6 @@
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
@@ -23,10 +24,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Price => 100; public override int Price => 100;
public override float Cooldown => 120000; public override float Cooldown => 120000;
public override void Consume(UserItem uItem) public override void Consume(Player player, User user, DatabaseContext databaseContext)
{ {
Player player = uItem.GetUser().Player;
int amountToAdd = HpAmount; int amountToAdd = HpAmount;
if (player.Health + amountToAdd > 100) if (player.Health + amountToAdd > 100)
{ {
@@ -35,7 +34,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
player.SafeSetHealth(player.Health + amountToAdd); player.SafeSetHealth(player.Health + amountToAdd);
player.SendNotification("Du hast einen ~y~" + Name + " ~s~gegessen.", false); player.SendNotification("Du hast einen ~y~" + Name + " ~s~gegessen.", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
} }
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
@@ -21,10 +22,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override float Cooldown => 30000; public override float Cooldown => 30000;
public override void Consume(UserItem uItem) public override void Consume(Player player, User user, DatabaseContext databaseContext)
{ {
Player player = uItem.GetUser().Player;
int amountToAdd = HpAmount; int amountToAdd = HpAmount;
if (player.Health + amountToAdd > 100) if (player.Health + amountToAdd > 100)
{ {
@@ -33,7 +32,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
player.SafeSetHealth(player.Health + amountToAdd); player.SafeSetHealth(player.Health + amountToAdd);
player.SendNotification("Du hast ~y~" + Name + " ~s~gegessen.", false); player.SendNotification("Du hast ~y~" + Name + " ~s~gegessen.", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
} }
} }
} }

View File

@@ -1,4 +1,6 @@
using ReallifeGamemode.Database.Entities; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
/** /**
* @overview Life of German Reallife - Inventory Items Chickenburger (Chickenburger.cs) * @overview Life of German Reallife - Inventory Items Chickenburger (Chickenburger.cs)
@@ -21,7 +23,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override float Cooldown => 20000; public override float Cooldown => 20000;
public override void Consume(UserItem uItem) public override void Consume(Player player, User user, DatabaseContext databaseContext)
{ {
//nothing //nothing
} }

View File

@@ -1,6 +1,7 @@
using System; using System;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Inventory.Interfaces; using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
@@ -8,38 +9,38 @@ using ReallifeGamemode.Server.Util;
namespace ReallifeGamemode.Server.Inventory.Items namespace ReallifeGamemode.Server.Inventory.Items
{ {
public abstract class ConsumableItem : IUsableItem public abstract class ConsumableItem : UseItem
{ {
public abstract int HpAmount { get; } public abstract int HpAmount { get; }
public abstract int Id { get; } public override int Id { get; }
public abstract string Name { get; } public override string Name { get; }
public abstract string Description { get; } public override string Description { get; }
public abstract int Gewicht { get; } public override int Gewicht { get; }
public abstract string Einheit { get; } public override string Einheit { get; }
public abstract uint Object { get; } public override int Price { get; }
public abstract int Price { get; }
public abstract float Cooldown { get; } public abstract float Cooldown { get; }
public abstract override uint Object { get; }
public override bool RemoveWhenUsed => true;
public abstract void Consume(UserItem uItem); public abstract void Consume(Player player, User user, DatabaseContext databaseContext);
public bool Use(UserItem uItem) public override bool Use(Player player, User user, DatabaseContext databaseContext)
{ {
User user = uItem.GetUser();
if (user.Player == null || !user.Player.IsLoggedIn()) if (user.Player == null || !user.Player.IsLoggedIn())
return false; return false;
if (!HasCooldownElapsed(user)) if (!HasCooldownElapsed(user) && Cooldown > 0)
{ {
DateTime time = InventoryManager.itemCooldown[user.Id]; DateTime time = InventoryManager.itemCooldown[user.Id];
int timeUntillNextUse = (int)(time - DateTime.Now).TotalSeconds; int timeUntillNextUse = (int)(time - DateTime.Now).TotalSeconds;
uItem.GetUser().Player.TriggerEvent("Error", $"Versuche es nach {timeUntillNextUse} Sekunden erneut."); user.Player.TriggerEvent("Error", $"Versuche es nach {timeUntillNextUse} Sekunden erneut.");
return false; return false;
} }
DateTime cooldown = DateTime.Now.AddMilliseconds(Cooldown); DateTime cooldown = DateTime.Now.AddMilliseconds(Cooldown);
InventoryManager.itemCooldown.Add(user.Id, cooldown); InventoryManager.itemCooldown.Add(user.Id, cooldown);
Consume(uItem); Consume(player, user, databaseContext);
return true; return true;
} }

View File

@@ -6,15 +6,15 @@ using ReallifeGamemode.Server.Managers;
namespace ReallifeGamemode.Server.Inventory.Items namespace ReallifeGamemode.Server.Inventory.Items
{ {
public abstract class DropItem : IDroppableItem public abstract class DropItem : BaseItem, IDroppableItem
{ {
public abstract int Id { get; } public override int Id { get; }
public abstract string Name { get; } public override string Name { get; }
public abstract string Description { get; } public override string Description { get; }
public abstract int Gewicht { get; } public override int Gewicht { get; }
public abstract string Einheit { get; } public override string Einheit { get; }
public abstract uint Object { get; } public abstract uint Object { get; }
public abstract int Price { get; } public override int Price { get; }
public void Drop(UserItem uItem, Player player, int amount) public void Drop(UserItem uItem, Player player, int amount)
{ {

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Util;
namespace ReallifeGamemode.Server.Inventory.Items
{
public class Joint : UseItem, IIllegalItem
{
private static Dictionary<int, DateTime> lastJointUse = new Dictionary<int, DateTime>();
private static readonly TimeSpan _jointCooldown = TimeSpan.FromMinutes(10);
public override int Id { get; } = 110;
public override string Name { get; } = "Joint";
public override string Description { get; } = "stay high bis zum tod";
public override int Gewicht { get; } = 20;
public override string Einheit { get; } = "g";
public override int Price { get; } = 0;
public override uint Object { get; }
public override bool Legal => false;
public override bool RemoveWhenUsed => true;
public int PriceForConfiscation { get; } = 25;
public override bool Use(Player player, User user, DatabaseContext databaseContext)
{
if (!CanUserUseJoint(user))
{
player.TriggerEvent("Error", $"Versuche es nach {-1 * (int)((DateTime.Now - lastJointUse[user.Id]) - _jointCooldown).TotalSeconds} Sekunden erneut.");
return false;
}
player.SyncAnimation("jointUse");
player.ToggleInventory(InventoryToggleOption.HIDE);
int armorToSet = Math.Min(player.Armor + 25, 100);
player.SafeSetArmor(armorToSet);
lastJointUse[user.Id] = DateTime.Now;
return true;
}
private bool CanUserUseJoint(User user)
{
if(!lastJointUse.ContainsKey(user.Id))
{
return true;
}
return DateTime.Now - lastJointUse[user.Id] > _jointCooldown;
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
@@ -21,10 +22,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override float Cooldown => 300000; public override float Cooldown => 300000;
public override void Consume(UserItem uItem) public override void Consume(Player player, User user, DatabaseContext databaseContext)
{ {
Player player = uItem.GetUser().Player;
int amountToAdd = HpAmount; int amountToAdd = HpAmount;
if (player.Health + amountToAdd > 100) if (player.Health + amountToAdd > 100)
{ {
@@ -33,7 +32,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
player.SafeSetHealth(player.Health + amountToAdd); player.SafeSetHealth(player.Health + amountToAdd);
player.SendNotification("Du hast ein ~y~" + Name + " ~s~gegessen.", false); player.SendNotification("Du hast ein ~y~" + Name + " ~s~gegessen.", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
} }
} }
} }

View File

@@ -19,15 +19,10 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override uint Object => 875075437; public override uint Object => 875075437;
public override int Price => 2500; public override int Price => 2500;
public override bool Use(UserItem uItem) public override bool RemoveWhenUsed { get; } = true;
public override bool Use(Player player, User user, DatabaseContext databaseContext)
{ {
Player player = uItem.GetUser().Player;
if (uItem.ItemId != 201)
{
return false;
}
Vehicle veh = null; Vehicle veh = null;
var nearestVeh = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).FirstOrDefault(); var nearestVeh = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).FirstOrDefault();
@@ -39,19 +34,19 @@ namespace ReallifeGamemode.Server.Inventory.Items
return false; return false;
} }
if(player.IsInVehicle) if (player.IsInVehicle)
{ {
player.SendNotification("Du musst aus deinem Fahrzeug aussteigen!"); player.SendNotification("Du musst aus deinem Fahrzeug aussteigen!");
return false; return false;
} }
if(veh.Controller == null) if (veh.Controller == null)
{ {
player.SendNotification("Du kannst dieses Fahrzeug nicht reparieren, weil Jemand bereits im Fahrzeug sitzt"); player.SendNotification("Du kannst dieses Fahrzeug nicht reparieren, weil Jemand bereits im Fahrzeug sitzt");
return false; return false;
} }
if((VehicleHash)veh.Model == WeaponDealManager.WEAPON_DEAL_GANG_VEHICLE_HASH || (VehicleHash)veh.Model == WeaponDealManager.WEAPON_DEAL_STAATSFRAK_VEHICLE_HASH) if ((VehicleHash)veh.Model == WeaponDealManager.WEAPON_DEAL_GANG_VEHICLE_HASH || (VehicleHash)veh.Model == WeaponDealManager.WEAPON_DEAL_STAATSFRAK_VEHICLE_HASH)
{ {
player.SendNotification("Du kannst den Waffentransporter nicht reparieren!"); player.SendNotification("Du kannst den Waffentransporter nicht reparieren!");
return false; return false;
@@ -60,8 +55,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
Vector3 position = veh.Position; Vector3 position = veh.Position;
player.SendNotification("Du hast ~g~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~verwendet", false); player.SendNotification("Du hast ~g~" + Name + " ~s~verwendet", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
ServerVehicle serverVehicle = veh.GetServerVehicle(dbContext); ServerVehicle serverVehicle = veh.GetServerVehicle(dbContext);
serverVehicle.Spawn(veh).Position = position; serverVehicle.Spawn(veh).Position = position;
Vehicle newVeh = serverVehicle.Spawn(veh); Vehicle newVeh = serverVehicle.Spawn(veh);

View File

@@ -19,40 +19,24 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override uint Object => 875075437; public override uint Object => 875075437;
public override int Price => 500; public override int Price => 500;
public override bool RemoveWhenUsed => true;
public override bool Use(UserItem uItem) public override bool Use(Player player, User user, DatabaseContext databaseContext)
{
Player player = uItem.GetUser().Player;
if (uItem.ItemId != 200)
{ {
return false; Random random = new Random();
} int randomNumber = random.Next(1, 2);
Random random = new Random(); if (randomNumber == 1)
int randomNumber = random.Next(1, 4);
if (randomNumber == 1)
{
using (var dbContext = new DatabaseContext())
{ {
User winner = player.GetUser(dbContext); user.Handmoney += 1000;
winner.Handmoney += 1000;
//player.TriggerEvent("SERVER:SET_HANDMONEY", winner.Handmoney); //player.TriggerEvent("SERVER:SET_HANDMONEY", winner.Handmoney);
dbContext.SaveChanges();
}
player.SendNotification("Glückwunsch du hast ~g~$~w~1000 gewonnen!"); player.SendNotification("Glückwunsch du hast ~g~$~w~1000 gewonnen!");
} }
else else
{ {
player.SendNotification("Leider kein Gewinn, viel Glück beim nächsten mal."); player.SendNotification("Leider kein Gewinn, viel Glück beim nächsten mal.");
}
player.SendNotification("Du hast ein ~g~" + Name + " ~s~verwendet.", false);
return true;
} }
player.SendNotification("Du hast ~g~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~verwendet.", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
return true;
} }
}
} }

View File

@@ -10,17 +10,17 @@ using ReallifeGamemode.Server.Managers;
namespace ReallifeGamemode.Server.Inventory.Items namespace ReallifeGamemode.Server.Inventory.Items
{ {
public abstract class UseItem : IUsableItem public abstract class UseItem : BaseItem, IUsableItem
{ {
public abstract int Id { get; } public override int Id { get; }
public abstract string Name { get; } public override string Name { get; }
public abstract string Description { get; } public override string Description { get; }
public abstract int Gewicht { get; } public override int Gewicht { get; }
public abstract string Einheit { get; } public override string Einheit { get; }
public override int Price { get; }
public abstract uint Object { get; } public abstract uint Object { get; }
public abstract int Price { get; } public abstract bool RemoveWhenUsed { get; }
public abstract bool Use(UserItem uItem);
public abstract bool Use(Player player, User user, DatabaseContext databaseContext);
} }
} }

View File

@@ -6,15 +6,15 @@ using ReallifeGamemode.Server.WeaponDeal;
namespace ReallifeGamemode.Server.Inventory.Items namespace ReallifeGamemode.Server.Inventory.Items
{ {
public abstract class WeaponDealItem : IWeaponDealItem public abstract class WeaponDealItem : BaseItem, IWeaponDealItem
{ {
public abstract int Id { get; } public override int Id { get; }
public abstract string Name { get; } public override string Name { get; }
public abstract string Description { get; } public override string Description { get; }
public abstract int Gewicht { get; } public override int Gewicht { get; }
public abstract string Einheit { get; } public override string Einheit { get; }
public override int Price { get; }
public abstract uint Object { get; } public abstract uint Object { get; }
public abstract int Price { get; }
public bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh) public bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh)
{ {

View File

@@ -147,6 +147,7 @@ namespace ReallifeGamemode.Server
PositionManager.LoadPositionManager(); PositionManager.LoadPositionManager();
LoadManager.LoadLoadManager(); LoadManager.LoadLoadManager();
Rentcar.Setup(); Rentcar.Setup();
HanfManager.Load();
World.WeatherSync.Load(); World.WeatherSync.Load();

View File

@@ -0,0 +1,619 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using GTANetworkAPI;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Inventory.Items;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util;
namespace ReallifeGamemode.Server.Managers
{
public class HanfManager : BaseScript
{
/// <summary>
/// Punkte zum Samen kaufen
/// </summary>
private readonly static List<Vector3> _seedsBuyPoints = new List<Vector3>();
private readonly static List<Vector3> _cannabisSellPoints = new List<Vector3>();
/// <summary>
/// Aktueller Samen-Preis
/// </summary>
public static int SEED_PRICE = 0;
private const int SEED_PRICE_MIN = 40;
private const int SEED_PRICE_MAX = 75;
/// <summary>
/// Aktueller Hanf-Verkaufspreis
/// </summary>
public static int CANNABIS_PRICE = 0;
private const int CANNABIS_PRICE_MIN = 50;
private const int CANNABIS_PRICE_MAX = 125;
/// <summary>
/// Wie viele Samen ein Spieler pro Tag maximal kaufen darf
/// </summary>
private const int MAX_SEEDS_PER_DAY = 50;
/// <summary>
/// Wie viele Joints man aus einem Cannabis bekommt
/// </summary>
public static int CANNABIS_TO_JOINT_RATIO = 3;
/// <summary>
/// Flag, ob der Verarbeiter aktuell benutzt wird
/// </summary>
private static bool _manufacturerCurrentlyUsed = false;
/// <summary>
/// Marihuana -> Joint
/// </summary>
private readonly static Vector3 _jointManufacturerPoint = new Vector3(-127.726105, 1921.5142, 197.31104);
/// <summary>
/// Animations-ID des Verarbeitens
/// </summary>
private const string _manufacturerAnim = "manufacturJoint";
/// <summary>
/// Data-Key, ob der Spieler grade eine Pflanze anpflanzt
/// </summary>
private const string PLAYER_CURRENTLY_PLANTING_DATA_KEY = "isPlantingCannabis";
/// <summary>
/// Ab welcher Zeit Pflanzen verwelken
/// </summary>
private static readonly TimeSpan MAX_PLANT_TIME = TimeSpan.FromHours(6);
private static readonly TimeSpan MIN_PLANT_TIME_TO_HARVEST = TimeSpan.FromHours(4);
/// <summary>
/// Timer der den Status des Verarbeiters zurücksetzt
/// </summary>
private static Timer _manufacturerDoneTimer = new Timer(TimeSpan.FromSeconds(10).TotalMilliseconds);
/// <summary>
/// Zufallsgenerator für weibliche Pflanze und erhaltenes Cannabis
/// </summary>
private static Random _random = new Random();
private static List<CannabisData> _currentCannabisData = new List<CannabisData>();
public static readonly Vector3 ASSERVATENKAMMER_POSITION = new Vector3(-5.45, -670.03, 32.33);
static HanfManager()
{
_manufacturerDoneTimer.Elapsed += ManufacturerDoneTimerCallback;
}
/// <summary>
/// Ladefunktion zum
/// </summary>
public static void Load()
{
var priceRandom = new Random();
SEED_PRICE = priceRandom.Next(SEED_PRICE_MIN, SEED_PRICE_MAX + 1);
CANNABIS_PRICE = priceRandom.Next(CANNABIS_PRICE_MIN, CANNABIS_PRICE_MAX + 1);
logger.LogInformation("Generated hanf prices: seed = {0}, cannabis = {1}", SEED_PRICE, CANNABIS_PRICE);
_seedsBuyPoints.Add(new Vector3(-30.21876, -585.3222, 17.917326));
_seedsBuyPoints.Add(new Vector3(-680.89386, -634.6783, 25.29923));
_seedsBuyPoints.Add(new Vector3(-1310.743, -608.9064, 29.382874));
_seedsBuyPoints.Add(new Vector3(-758.6156, -1595.2686, 6.302392));
_seedsBuyPoints.Add(new Vector3(-441.0504, 1595.4435, 358.4195));
ColShape colShape = null;
foreach (Vector3 buyPoint in _seedsBuyPoints)
{
colShape = NAPI.ColShape.CreateSphereColShape(buyPoint, 10.0f);
colShape.OnEntityEnterColShape += OnSeedBuyRangeColShapeEnter;
}
_cannabisSellPoints.Add(new Vector3(2220.04, 5614.24, 54.72));
_cannabisSellPoints.Add(new Vector3(201.77, 2442.06, 60.45));
_cannabisSellPoints.Add(new Vector3(155.87, -3103.26, 7.03));
foreach (Vector3 sellPoint in _cannabisSellPoints)
{
colShape = NAPI.ColShape.CreateSphereColShape(sellPoint, 10.0f);
colShape.OnEntityEnterColShape += OnCannabisSellRangeColShapeEnter;
}
NAPI.Marker.CreateMarker(GTANetworkAPI.MarkerType.VerticalCylinder, ASSERVATENKAMMER_POSITION.Subtract(new Vector3(0, 0, 3.0)), new Vector3(), new Vector3(), 3.0f, Colors.White);
NAPI.TextLabel.CreateTextLabel("Asservatenkammer~n~Drücke ~y~E, um den ~y~Riot~s~ zu entladen", ASSERVATENKAMMER_POSITION, 10.0f, 10.0f, 0, Colors.White);
using var dbContext = new DatabaseContext();
HarvestRottenPlants(dbContext);
UpdateHanfWorldData(dbContext);
Timer updateHanfDataTimer = new Timer(TimeSpan.FromMinutes(1).TotalMilliseconds);
updateHanfDataTimer.Elapsed += UpdateHanfDataTimer_Elapsed;
updateHanfDataTimer.Start();
}
private static void OnCannabisSellRangeColShapeEnter(ColShape colShape, Player player)
{
if (!player.IsLoggedIn())
{
return;
}
var user = player.GetUser();
if (user?.Faction?.StateOwned == true)
{
return;
}
ChatService.SendMessage(player, $"Fremder sagt: Pssst.. Hier kannst du dein Brokkoli loswerden.");
}
private static void HarvestRottenPlants(DatabaseContext dbContext)
{
var rottenPlants = dbContext.CannabisPlants.Where(p => EF.Functions.DateDiffHour(p.PlantDate, DateTime.Now) > MAX_PLANT_TIME.TotalHours);
foreach (var plant in rottenPlants)
{
plant.Harvested = true;
}
dbContext.SaveChanges();
}
private static void UpdateHanfDataTimer_Elapsed(object sender, ElapsedEventArgs e)
{
using var dbContext = new DatabaseContext();
UpdateHanfWorldData(dbContext);
}
private static void OnSeedBuyRangeColShapeEnter(ColShape colShape, Player player)
{
if (!player.IsLoggedIn())
{
return;
}
var user = player.GetUser();
if (user?.Faction?.StateOwned == true)
{
return;
}
ChatService.SendMessage(player, $"Fremder sagt: Pssst.. Willst du Samen kaufen?");
}
internal static bool IsPlayerNearSeedBuyPoint(Player player)
{
return _seedsBuyPoints.Any(p => player.Position.DistanceTo(p) <= 2.5f);
}
internal static bool IsPlayerNearJointManufacturer(Player player)
{
return _jointManufacturerPoint.DistanceTo(player.Position) <= 2.5f;
}
internal static void StartCannabisPlanting(Player player)
{
player.ToggleInventory(InventoryToggleOption.HIDE);
if (!player.IsAlive())
{
return;
}
var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext);
if (user.Faction?.StateOwned ?? false)
{
player.SendNotification("~r~Du darfst keine Hanfsamen einpflanzen");
return;
}
if (player.HasData(PLAYER_CURRENTLY_PLANTING_DATA_KEY) && player.GetData<bool>(PLAYER_CURRENTLY_PLANTING_DATA_KEY))
{
player.SendNotification("~r~Du pflanzt aktuell schon einen Hanfsamen ein");
return;
}
player.SetData(PLAYER_CURRENTLY_PLANTING_DATA_KEY, true);
player.TriggerEvent("SERVER:Hanf_StartPlanting");
}
[RemoteEvent("CLIENT:Hanf_PlantHanf")]
public void HanfManagerPlantHanf(Player player, float x, float y, float z)
{
player.ResetData(PLAYER_CURRENTLY_PLANTING_DATA_KEY);
IItem cannabisSeedItem = InventoryManager.GetItem<CannabisSeeds>();
UserItem userCannabisSeedsItem = InventoryManager.UserHasThisItem(player, cannabisSeedItem.Id);
if (userCannabisSeedsItem == null)
{
player.SendNotification("~r~Du hast keine Samen mehr");
return;
}
logger.LogInformation("Player {0} planted a cannabis plant at x: {1}, y: {2}, z: {3}", player.Name, x, y, z);
using var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext);
InventoryManager.RemoveUserItem(user, userCannabisSeedsItem, 1);
CannabisPlant newPlant = new CannabisPlant()
{
X = x,
Y = y,
Z = z,
PlantedBy = user,
PlantDate = DateTime.Now,
};
dbContext.CannabisPlants.Add(newPlant);
dbContext.SaveChanges();
UpdateHanfWorldData(dbContext);
}
public static void UpdateHanfWorldData(DatabaseContext dbContext)
{
var activePlants = dbContext.CannabisPlants.Where(p => !p.Harvested).Select(p => new CannabisData()
{
Id = p.Id,
Time = p.PlantDate,
X = p.X,
Y = p.Y,
Z = p.Z
}).ToList();
_currentCannabisData = activePlants;
NAPI.Pools.GetAllPlayers().ForEach(p =>
{
UpdateHanfForPlayer(p, activePlants);
});
}
public async static void UpdateHanfForPlayer(Player player, List<CannabisData> cannabisData = null)
{
cannabisData ??= _currentCannabisData;
await NAPI.Task.WaitForMainThread();
player.TriggerEvent("SERVER:Hanf_UpdateHanfData", JsonConvert.SerializeObject(cannabisData));
}
[RemoteEvent("CLIENT:Hanf_BuySeeds")]
public void HanfManagerBuySeeds(Player player, int amount)
{
if (!player.IsLoggedIn())
{
return;
}
using var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext);
if (amount > GetAmountOfCannabisSeedsPlayerCanBuyToday(user))
{
player.SendNotification("~r~Du kannst heute nicht mehr so viele Samen kaufen");
return;
}
IItem seedItem = InventoryManager.GetItem<CannabisSeeds>();
var newAmount = seedItem.Gewicht * amount;
if (!InventoryManager.CanPlayerHoldMoreWeight(player, newAmount))
{
player.TriggerEvent("~r~So viele Samen passen nicht mehr in deine Hosentasche");
return;
}
var price = amount * SEED_PRICE;
if (user.Handmoney < price)
{
player.SendNotification("~r~Du hast nicht genug Geld dafür");
return;
}
logger.LogInformation("Player {0} bought {1} cannabis seeds for {2} dollars (price per seed: {3})", player.Name, amount, price, SEED_PRICE); // <-- WICHTIG LOGS
if (user.LastTimeBoughtCannabisSeeds == null || user.LastTimeBoughtCannabisSeeds.Value.Date != DateTime.Now.Date)
{
user.CannabisSeedsBoughtToday = amount;
}
else
{
user.CannabisSeedsBoughtToday += amount;
}
user.LastTimeBoughtCannabisSeeds = DateTime.Now;
user.Handmoney -= price;
dbContext.SaveChanges();
InventoryManager.AddItemToInventory(player, seedItem.Id, amount);
player.SendNotification($"Du hast {amount} Hanfsamen gekauft");
}
[RemoteEvent("CLIENT:Hanf_HarvestHanf")]
public async void HanfManagerHarvestHanf(Player player, long hanfId)
{
if (!player.IsLoggedIn())
{
return;
}
using var dbContext = new DatabaseContext();
User user = player.GetUser(dbContext);
CannabisPlant plant = dbContext.CannabisPlants.Include(p => p.PlantedBy).Where(p => p.Id == hanfId).FirstOrDefault();
if (plant == null)
{
logger.LogError("Player {0} tried to harvest cannabis plant {1} but it was not found in database", player.Name, hanfId);
return;
}
if (plant.Harvested)
{
return;
}
if (player.IsAdminDuty() && player.IsTSupport() && user.IsAdmin(AdminLevel.ADMIN))
{
player.SendNotification($"Du hast die Hanf-Pflanze von ~y~{plant.PlantedBy.Name}~s~ entfernt");
plant.Harvested = true;
dbContext.SaveChanges();
UpdateHanfWorldData(dbContext);
return;
}
if (user.Faction?.StateOwned == true)
{
if (!((user.FactionId == 1 || user.FactionId == 3) && player.IsDuty()))
{
player.SendNotification("~r~Du kannst kein Hanf ernten");
return;
}
}
//player.SyncAnimation(new[] { "harvestPlantEnter", "harvestPlant", "harvestPlantExit" }.ToList());
//player.SyncAnimation("harvestPlant");
//player.AddAttachment("shovel", false);
if (user.FactionId != 3 && user.FactionId != 1) // Zivi / Gangmember erntet ab
{
player.SyncAnimation("harvestPlant");
plant.Harvested = true;
bool isPlantRotten = DateTime.Now - plant.PlantDate > MAX_PLANT_TIME;
if (isPlantRotten)
{
player.SendNotification("~r~Die Pflanze ist leider verrottet");
}
else
{
bool isPlantReadyToHarvest = DateTime.Now - plant.PlantDate > MIN_PLANT_TIME_TO_HARVEST;
if (!isPlantReadyToHarvest) // Wenn die Pflanze noch nicht ausgewachsen ist
{
bool getSeedBack = _random.Next(0, 2) == 1; // 50% Chance
if (getSeedBack)
{
IItem cannabisSeedItem = InventoryManager.GetItem<CannabisSeeds>();
InventoryManager.AddItemToInventory(player, cannabisSeedItem.Id, 1);
player.SendNotification("~g~Du konntest den Samen wieder ausgraben");
}
else
{
player.SendNotification("~r~Du konntest den Samen leider nicht wieder ausgraben");
}
}
else
{
bool isFemalePlant = _random.Next(0, 10) + 1 <= 8; // 80% Chance dass es eine weibliche Pflanze ist
if (isFemalePlant)
{
int cannabisAmount = _random.Next(4, 10) + 1; // zwischen 5 und 10g Cannabis
IItem cannabisItem = InventoryManager.GetItem<Cannabis>();
var newWeight = cannabisAmount * cannabisItem.Gewicht;
if (!InventoryManager.CanPlayerHoldMoreWeight(player, newWeight))
{
int restWeightPlayerCanHold = InventoryManager.MAX_USER_INVENTORY - InventoryManager.GetUserInventoryWeight(player);
cannabisAmount = restWeightPlayerCanHold / cannabisItem.Gewicht;
player.SendNotification("~o~Warnung:~s~ Du hast nicht das komplette Cannabis der Pflanze erhalten, da dein Inventar voll ist");
}
player.SendNotification("~g~" + cannabisAmount + "g Cannabis geerntet");
InventoryManager.AddItemToInventory(player, cannabisItem.Id, cannabisAmount);
}
else
{
player.SendNotification("~r~Du hast die falschen Samen eingesät und keinen Ertrag aus dieser Pflanze erhalten");
}
}
}
}
else // FIB / LSPD erntet ab
{
if (!(player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant")))
{
player.SetData("IsCarryingPlant", true);
player.SendNotification($"Du hast eine Pflanze von ~y~{plant.PlantedBy.Name}~s~ ausgegraben");
player.SyncAnimation("harvestPlant");
plant.Harvested = true;
var modelToGet = await player.TriggerProcedure("SERVER:Hanf_GetModelToGivePlayer", plant.Id);
player.SetData("HoldingCannabisPlant", modelToGet);
player.AddAttachment("CannabisPlantInHand" + modelToGet, false);
}
}
dbContext.SaveChanges();
UpdateHanfWorldData(dbContext);
}
internal static bool IsPlayerNearCannabisSellPoint(Player player)
{
return _cannabisSellPoints.Any(p => p.DistanceTo(player.Position) <= 3);
}
internal static void BuildJointsFromCannabis(Player player)
{
if (player.HasAnimation(_manufacturerAnim) || _manufacturerCurrentlyUsed)
{
return;
}
using var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext);
var userItems = InventoryManager.GetUserItems(player, dbContext);
IItem cannabisItem = InventoryManager.GetItem<Cannabis>();
IItem jointItem = InventoryManager.GetItem<Joint>();
var addWeight = jointItem.Gewicht * CANNABIS_TO_JOINT_RATIO - cannabisItem.Gewicht;
if (!InventoryManager.CanPlayerHoldMoreWeight(player, addWeight))
{
player.SendNotification("~r~Für die Verarbeitung hast du nicht genug Platz im Rucksack");
return;
}
UserItem userCannabisItem = userItems.Where(i => i.ItemId == cannabisItem.Id).FirstOrDefault();
if (userCannabisItem == null)
{
player.SendNotification("~r~Du hast kein Cannabis dabei");
return;
}
_manufacturerCurrentlyUsed = true;
_manufacturerDoneTimer.Start();
player.SyncAnimation(_manufacturerAnim);
InventoryManager.RemoveUserItem(user, userCannabisItem, 1);
InventoryManager.AddItemToInventory(player, jointItem.Id, CANNABIS_TO_JOINT_RATIO);
player.SendNotification($"Du hast 1 Cannabis in {CANNABIS_TO_JOINT_RATIO} Joints verarbeitet");
NAPI.ClientEvent.TriggerClientEventInRange(player.Position, 100.0f, "SERVER:Hanf_PlayManufacturerAnim", _manufacturerAnim);
}
private static void ManufacturerDoneTimerCallback(object sender, EventArgs args)
{
_manufacturerDoneTimer.Stop();
_manufacturerCurrentlyUsed = false;
}
[RemoteEvent("CLIENT:Hanf_FinishDiggingAnimation")]
public void HanfManagerFinishDiggingAnimation(Player player)
{
player.AddAttachment("shovel", true);
}
private static int GetAmountOfCannabisSeedsPlayerCanBuyToday(User user)
{
if (user.LastTimeBoughtCannabisSeeds == null)
{
return MAX_SEEDS_PER_DAY;
}
if (user.LastTimeBoughtCannabisSeeds.Value.Date != DateTime.Now.Date)
{
return MAX_SEEDS_PER_DAY;
}
return MAX_SEEDS_PER_DAY - user.CannabisSeedsBoughtToday;
}
internal static void ShowPlayerBuySeedMenu(Player player)
{
var user = player.GetUser();
if (user.Faction?.StateOwned == true)
{
return;
}
var seedsUserCanBuy = GetAmountOfCannabisSeedsPlayerCanBuyToday(user);
if (seedsUserCanBuy == 0)
{
player.SendNotification("~r~Du kannst heute keine Samen mehr kaufen");
return;
}
player.TriggerEvent("SERVER:Hanf_BuySeed", seedsUserCanBuy, SEED_PRICE);
}
internal static void PlayerSellCannabis(Player player)
{
if (!player.IsLoggedIn())
{
return;
}
using var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext);
if (user.Faction?.StateOwned == true)
{
return;
}
List<UserItem> items = InventoryManager.GetUserItems(player, dbContext);
IItem cannabisItem = InventoryManager.GetItem<Cannabis>();
var cannabisAmount = items.Where(i => i.ItemId == cannabisItem.Id).FirstOrDefault()?.Amount ?? 0;
if (cannabisAmount == 0)
{
player.SendNotification("~r~Du hast kein Cannabis dabei");
return;
}
player.TriggerEvent("SERVER:Hanf_SellCannabisMenu", cannabisAmount, CANNABIS_PRICE);
}
[RemoteEvent("CLIENT:Hanf_SellCannabis")]
public void HanfManagerSellCannabis(Player player, int amount)
{
if (!player.IsLoggedIn())
{
return;
}
using var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext);
List<UserItem> items = InventoryManager.GetUserItems(player, dbContext);
IItem cannabisItem = InventoryManager.GetItem<Cannabis>();
var cannabisUserItem = items.Where(i => i.ItemId == cannabisItem.Id).FirstOrDefault();
var cannabisAmount = cannabisUserItem?.Amount ?? 0;
if (cannabisAmount < amount)
{
player.SendNotification("~r~Du hast nicht so viel Cannabis dabei");
return;
}
var price = amount * CANNABIS_PRICE;
user.Handmoney += price;
InventoryManager.RemoveUserItem(user, cannabisUserItem, amount);
logger.LogInformation("Player {0} sold {1} cannabis to the server for {2} dollars", player.Name, amount, price);
player.SendNotification($"Du hast ~g~{amount} Hanfblüten~s~ für ~g~{price.ToMoneyString()}~s~ verkauft");
}
}
}

View File

@@ -18,6 +18,7 @@ using ReallifeGamemode.Server.Core.API;
using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Factions.Medic;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Inventory.Interfaces;
/** /**
* @overview Life of German Reallife - Managers Interaction (InteractionManager.cs) * @overview Life of German Reallife - Managers Interaction (InteractionManager.cs)
@@ -758,6 +759,150 @@ namespace ReallifeGamemode.Server.Managers
} }
} }
[RemoteEvent("CLIENT:InteractionMenu_LSPD_FriskUser")]
public void InteractionMenuLspdFriskUser(Player player, string name)
{
if (!player.IsLoggedIn())
{
return;
}
Player target = PlayerService.GetPlayerByNameOrId(name);
if (!target.IsLoggedIn())
{
ChatService.PlayerNotFound(player);
return;
}
using var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext);
if ((user.FactionId != 1 && user.FactionId != 3) || !player.IsDuty())
{
return;
}
if (player.Position.DistanceTo(target.Position) > 5)
{
player.SendNotification("~r~Der Spieler ist nicht in deiner Nähe");
return;
}
var targetUser = target.GetUser(dbContext);
var targetItems = InventoryManager.GetUserItems(target, dbContext);
List<string> illItemsList = new List<string>();
bool illegalItemsFound = false;
var price = 0;
foreach (var targetItem in targetItems)
{
IItem item = InventoryManager.GetItemById(targetItem.ItemId);
if (!item.Legal)
{
illItemsList.Add($"{targetItem.Amount}x {item.Name}");
InventoryManager.RemoveUserItem(targetUser, targetItem, targetItem.Amount);
illegalItemsFound = true;
price += ((IIllegalItem)item).PriceForConfiscation * targetItem.Amount;
logger.LogInformation("Player {0} confiscated the illegal item {1} ({2}, amount: {3}) from player {4}", player.Name, item.Name, item.Id, targetItem.Amount, target.Name);
}
}
if (!illegalItemsFound)
{
player.SendNotification("~g~Der Spieler hat keine illegalen Gegenstände dabei");
return;
}
logger.LogInformation("executive factions got {0} dollars from the confiscation", price);
var factions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3);
foreach (var faction in factions)
{
faction.BankAccount.Balance += price;
}
dbContext.SaveChanges();
string illItemsStr = "~y~" + string.Join("~s~,~y~ ", illItemsList) + "~s~";
ChatService.SendMessage(player, $"Du hast ~y~{target.Name}~s~ folgende Gegenstände abgenommen: {illItemsStr}");
ChatService.SendMessage(target, $"~y~{player.Name}~s~ hat die folgende Gegenstände abgenommen: {illItemsStr}");
}
[RemoteEvent("CLIENT:InteractionMenu_LSPD_FriskVehicle")]
public void InteractionMenuLspdFriskVehicle(Player player)
{
if (!player.IsLoggedIn())
{
return;
}
using var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext);
if ((user.FactionId != 1 && user.FactionId != 3) || !player.IsDuty())
{
return;
}
var vehicle = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).OrderBy(v => v.Position.DistanceTo(player.Position)).FirstOrDefault();
if (vehicle == null)
{
player.SendNotification("~r~Es befindet sich kein Fahrzeug in deiner Nähe");
return;
}
ServerVehicle serverVehicle = vehicle.GetServerVehicle(dbContext);
if (serverVehicle == null)
{
player.SendNotification("~r~Dieses Fahrzeug kann nicht durchsucht werden");
return;
}
if (VehicleStreaming.GetLockState(vehicle) || serverVehicle.Locked)
{
player.SendNotification("~r~Dieses Fahrzeug ist abgeschlossen");
return;
}
var targetItems = InventoryManager.GetVehicleItems(vehicle);
List<string> illItemsList = new List<string>();
bool illegalItemsFound = false;
var price = 0;
foreach (var targetItem in targetItems)
{
IItem item = InventoryManager.GetItemById(targetItem.ItemId);
if (!item.Legal)
{
illItemsList.Add($"{targetItem.Amount}x {item.Name}");
InventoryManager.RemoveVehicleItem(serverVehicle, targetItem, targetItem.Amount, null);
illegalItemsFound = true;
price += ((IIllegalItem)item).PriceForConfiscation * targetItem.Amount;
logger.LogInformation("Player {0} confiscated the illegal item {1} ({2}, amount: {3}) from vehicle {4}", player.Name, item.Name, item.Id, targetItem.Amount, serverVehicle.Id);
}
}
if (!illegalItemsFound)
{
player.SendNotification("~g~Im Kofferraum sind keine illegalen Gegenstände");
return;
}
logger.LogInformation("executive factions got {0} dollars from the confiscation", price);
var factions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3);
foreach (var faction in factions)
{
faction.BankAccount.Balance += price;
}
dbContext.SaveChanges();
string illItemsStr = "~y~" + string.Join("~s~,~y~ ", illItemsList) + "~s~";
ChatService.SendInRange(player.Position, 20, $"{player.Name} hat aus dem Kofferraum folgende Gegenstände beschlagnahmt: {illItemsStr}");
}
[RemoteEvent("CLIENT:InteractionMenu_Pay")] [RemoteEvent("CLIENT:InteractionMenu_Pay")]
public void InteractionMenu_Pay(Player player, string jsonNameOrId, string stringAmount) public void InteractionMenu_Pay(Player player, string jsonNameOrId, string stringAmount)
{ {

View File

@@ -27,7 +27,7 @@ namespace ReallifeGamemode.Server.Managers
{ {
public class InventoryManager : Script public class InventoryManager : Script
{ {
private const int MAX_USER_INVENTORY = 40000; public const int MAX_USER_INVENTORY = 40000;
private static readonly ILogger logger = LogManager.GetLogger<InventoryManager>(); private static readonly ILogger logger = LogManager.GetLogger<InventoryManager>();
public static List<IItem> itemList; public static List<IItem> itemList;
@@ -47,7 +47,7 @@ namespace ReallifeGamemode.Server.Managers
public int Amount; public int Amount;
public int ItemId; public int ItemId;
public int Weight; public int Weight;
public Vehicle vehicle; public ushort vehicle;
} }
public static void SetBackpackItems(Player player) public static void SetBackpackItems(Player player)
@@ -75,14 +75,25 @@ namespace ReallifeGamemode.Server.Managers
player.SetSharedData("backpackItems", JsonConvert.SerializeObject(backpackItems[player].ToArray())); player.SetSharedData("backpackItems", JsonConvert.SerializeObject(backpackItems[player].ToArray()));
} }
internal static T GetItem<T>() where T : IItem
{
return (T)itemList.Where(i => i.GetType() == typeof(T)).First();
}
[RemoteEvent("CLIENT:getVehicleInventory")] [RemoteEvent("CLIENT:getVehicleInventory")]
public static void SetVehicleItems(Player player) public static void SetVehicleItems(Player player)
{ {
if (player.IsInVehicle) if (player.IsInVehicle)
{ {
player.TriggerEvent("Error", "Du kannst deinen Kofferraum gerade nicht öffnen."); player.TriggerEvent("Error", "Du kannst deinen Kofferraum gerade nicht öffnen.");
return;
} }
Vehicle veh = NAPI.Pools.GetAllVehicles().ToList().Where(v => v.Position.DistanceTo(player.Position) <= 4).FirstOrDefault();
Vehicle veh = NAPI.Pools.GetAllVehicles()
.ToList()
.Where(v => v.Position.DistanceTo(player.Position) <= 4)
.OrderBy(v => v.Position.DistanceTo(player.Position))
.FirstOrDefault();
if (veh == null) if (veh == null)
{ {
player.TriggerEvent("Error", "Kein Fahrzeug in der Nähe!"); player.TriggerEvent("Error", "Kein Fahrzeug in der Nähe!");
@@ -122,7 +133,7 @@ namespace ReallifeGamemode.Server.Managers
Amount = i.Amount, Amount = i.Amount,
ItemId = i.ItemId, ItemId = i.ItemId,
Weight = GetVehicleInventoryWeight(veh), Weight = GetVehicleInventoryWeight(veh),
vehicle = veh, vehicle = veh.Handle.Value,
}; };
vehicleItems[player].Add(newItem); vehicleItems[player].Add(newItem);
} }
@@ -130,6 +141,11 @@ namespace ReallifeGamemode.Server.Managers
player.SetSharedData("vehicleItems", JsonConvert.SerializeObject(vehicleItems[player].ToArray())); player.SetSharedData("vehicleItems", JsonConvert.SerializeObject(vehicleItems[player].ToArray()));
} }
public static bool CanPlayerHoldMoreWeight(Player player, int moreWeight)
{
return GetUserInventoryWeight(player) + moreWeight <= MAX_USER_INVENTORY;
}
public static void LoadItems() public static void LoadItems()
{ {
itemList = new List<IItem>(); itemList = new List<IItem>();
@@ -175,18 +191,18 @@ namespace ReallifeGamemode.Server.Managers
if (userItem.Amount == 0) if (userItem.Amount == 0)
{ {
dbContext.Remove(userItem); dbContext.Remove(userItem);
dbContext.SaveChanges();
} }
Player player = user.Player;
List<UserItem> itemList = GetUserItems(player);
if (itemList == null) return;
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
} }
public static void RemoveVehicleItem(ServerVehicle sVeh, VehicleItem item, int amount, Player player) public static void RemoveVehicleItem(ServerVehicle sVeh, VehicleItem item, int amount, Player player)
{ {
if (item == null)
{
return;
}
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
var vehicleItem = dbContext.VehicleItems.FirstOrDefault(i => i.Id == item.Id); var vehicleItem = dbContext.VehicleItems.FirstOrDefault(i => i.Id == item.Id);
@@ -212,16 +228,29 @@ namespace ReallifeGamemode.Server.Managers
return new DatabaseContext().VehicleItems.ToList().FindAll(i => i.GetVehicle().GetVehicle() == vehicle); return new DatabaseContext().VehicleItems.ToList().FindAll(i => i.GetVehicle().GetVehicle() == vehicle);
} }
public static List<UserItem> GetUserItems(Player player) public static List<UserItem> GetUserItems(Player player, DatabaseContext dbContext = null)
{ {
var user = player.GetUser(); if (dbContext == null)
using (var context = new DatabaseContext())
{ {
return context.UserItems.ToList().FindAll(i => i.UserId == user.Id); using (dbContext = new DatabaseContext())
{
return GetUserItemsInternal(player, dbContext);
}
}
else
{
return GetUserItemsInternal(player, dbContext);
} }
} }
private static List<UserItem> GetUserItemsInternal(Player player, DatabaseContext dbContext)
{
var user = player.GetUser(dbContext);
return dbContext.UserItems.ToList().FindAll(i => i.UserId == user.Id);
}
public static int GetUserInventoryWeight(Player player) public static int GetUserInventoryWeight(Player player)
{ {
var user = player.GetUser(); var user = player.GetUser();
@@ -270,7 +299,7 @@ namespace ReallifeGamemode.Server.Managers
} }
} }
public static void GetUserItemsAsAdmin(Player player, User user) public static void GetUserItemsAsAdmin(Player admin, User user)
{ {
var inventoryWeight = 0; var inventoryWeight = 0;
@@ -292,7 +321,7 @@ namespace ReallifeGamemode.Server.Managers
items[userItems.IndexOf(item)][4] = item.Slot.ToString(); items[userItems.IndexOf(item)][4] = item.Slot.ToString();
items[userItems.IndexOf(item)][5] = item.Id.ToString(); items[userItems.IndexOf(item)][5] = item.Id.ToString();
} }
player.TriggerEvent("showInventoryToAdmin", user.Name, inventoryWeight, items); admin.TriggerEvent("showInventoryToAdmin", user.Name, inventoryWeight, items);
} }
} }
@@ -304,20 +333,29 @@ namespace ReallifeGamemode.Server.Managers
using (var context = new DatabaseContext()) using (var context = new DatabaseContext())
{ {
User user = player.GetUser(context);
if (!vehicleItems.ContainsKey(player)) if (!vehicleItems.ContainsKey(player))
vehicleItems.Add(player, new List<InventoryItem>()); vehicleItems.Add(player, new List<InventoryItem>());
Vehicle veh = null; Vehicle veh = null;
if (vehicleItems[player].Count != 0) if (vehicleItems[player].Count != 0)
veh = vehicleItems[player].FirstOrDefault().vehicle; veh = new NetHandle(vehicleItems[player].FirstOrDefault().vehicle, EntityType.Vehicle).Entity<Vehicle>();
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context); ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
VehicleItem vehItem = context.VehicleItems.Where(v => v.VehicleId == serverVehicle.Id && v.ItemId == itemID).FirstOrDefault(); VehicleItem vehItem = context.VehicleItems.Where(v => v.VehicleId == serverVehicle.Id && v.ItemId == itemID).FirstOrDefault();
if (vehItem == null) if (vehItem == null)
{ {
player.TriggerEvent("Error", "Transfer nicht möglich."); player.TriggerEvent("Error", "Transfer nicht möglich.");
return; return;
} }
if (serverVehicle is FactionVehicle factionVehicle)
{
IItem item = GetItemById(itemID);
if (factionVehicle.Model == VehicleHash.Riot && user.Faction?.StateOwned == true)
{
player.TriggerEvent("Error", "Transfer nicht möglich.");
return;
}
}
RemoveVehicleItem(serverVehicle, vehItem, itemAmount, player); RemoveVehicleItem(serverVehicle, vehItem, itemAmount, player);
SetVehicleItems(player); SetVehicleItems(player);
@@ -510,10 +548,10 @@ namespace ReallifeGamemode.Server.Managers
int itemId = JsonConvert.DeserializeObject<int>(jsonItemId); int itemId = JsonConvert.DeserializeObject<int>(jsonItemId);
string type = JsonConvert.DeserializeObject<string>(jsonType); string type = JsonConvert.DeserializeObject<string>(jsonType);
User user = player.GetUser();
using (var context = new DatabaseContext()) using (var context = new DatabaseContext())
{ {
User user = player.GetUser(context);
UserItem fItem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault(); UserItem fItem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
IItem iItem = GetItemById(fItem.ItemId); IItem iItem = GetItemById(fItem.ItemId);
@@ -534,10 +572,15 @@ namespace ReallifeGamemode.Server.Managers
if (iItem is IUsableItem usableItemObj) if (iItem is IUsableItem usableItemObj)
{ {
if (usableItemObj.Use(fItem)) logger.LogInformation("Player {0} used the item {1} ({2})", player.Name, iItem.Name, iItem.Id);
if (usableItemObj.Use(player, user, context))
{ {
SetBackpackItems(player); if (usableItemObj.RemoveWhenUsed)
player.TriggerEvent("aproveUse", 1, iItem.Name); {
RemoveUserItem(user, fItem, 1);
SetBackpackItems(player);
player.TriggerEvent("aproveUse", 1, iItem.Name);
}
} }
} }
else player.TriggerEvent("Error", "Du kannst dieses Item nicht benutzen."); else player.TriggerEvent("Error", "Du kannst dieses Item nicht benutzen.");
@@ -559,6 +602,7 @@ namespace ReallifeGamemode.Server.Managers
if (iItem is IDroppableItem usableItemObj2) if (iItem is IDroppableItem usableItemObj2)
{ {
logger.LogInformation("Player {0} dropped the item {1} ({2})", player.Name, iItem.Name, iItem.Id);
Vector3 dropPosition = PlayerExtension.GetPositionFromPlayer(player, 0.6f, 0); Vector3 dropPosition = PlayerExtension.GetPositionFromPlayer(player, 0.6f, 0);
//new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f); //new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f);
Random r = new Random(); Random r = new Random();
@@ -617,7 +661,6 @@ namespace ReallifeGamemode.Server.Managers
if (GetUserInventoryWeight(client) + shopItem.Gewicht > MAX_USER_INVENTORY) if (GetUserInventoryWeight(client) + shopItem.Gewicht > MAX_USER_INVENTORY)
{ {
return; return;
} }

View File

@@ -68,7 +68,8 @@ namespace ReallifeGamemode.Server.Managers
{ {
WeponDealPed, WeponDealPed,
DepartmentPed, DepartmentPed,
PrisonPed PrisonPed,
} }
public class PedData public class PedData

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ReallifeGamemode.Server.Util
{
public class CannabisData
{
public long Id { get; set; }
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
public DateTime Time { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
namespace ReallifeGamemode.Server.Util
{
public static class Colors
{
public static Color White = new Color(255, 255, 255);
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ReallifeGamemode.Server.Util
{
public enum InventoryToggleOption
{
TOGGLE, SHOW, HIDE
}
}