Miese Corona Zeiten push für Lenhardt
This commit is contained in:
@@ -19,19 +19,16 @@ cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
|
||||
export default function elevatorList(globalData: IGlobalData) {
|
||||
|
||||
var elevatorMenu: NativeUI.Menu;
|
||||
|
||||
var stages;
|
||||
|
||||
var stage = "";
|
||||
|
||||
|
||||
//Weapon Menu
|
||||
|
||||
mp.events.add('showElevatorMenu', (stagesArr) => {
|
||||
if (!globalData.InMenu) {
|
||||
|
||||
globalData.InMenu = true;
|
||||
|
||||
stages = JSON.parse(stagesArr);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
export default function RefuseCollector() {
|
||||
|
||||
var State = false;
|
||||
var Traegt = false;
|
||||
var HintenVoll = false;
|
||||
var MuellSack = null;
|
||||
|
||||
var BlipTonneHinten = null;
|
||||
var CheckpointTonneHinten = null;
|
||||
var ShapeTonneHinten = null;
|
||||
@@ -17,8 +16,6 @@
|
||||
var BlipTonne = [];
|
||||
var ShapeTonne = [];
|
||||
|
||||
|
||||
|
||||
mp.events.add('SERVER:MuellmannStatusTrue', () => {
|
||||
State = true;
|
||||
});
|
||||
@@ -28,14 +25,13 @@
|
||||
});
|
||||
|
||||
mp.events.add('SERVER:MuellmannBCSErstellen', (jsonPosArr, veh) => {
|
||||
|
||||
let posArr = JSON.parse(jsonPosArr);
|
||||
vehicle = veh;
|
||||
for (var i = 0; i < posArr.length; i++) {
|
||||
let pos = new mp.Vector3(posArr[i].x, posArr[i].y, posArr[i].z - 1)
|
||||
BlipTonne.push(mp.blips.new(1, pos, { name: 'Müllmann', color: 45, shortRange: false }));
|
||||
BlipTonne[i].setFlashes(true);
|
||||
ShapeTonne.push(mp.colshapes.newSphere(posArr[i].x, posArr[i].y, posArr[i].z +0.5, 1.75));
|
||||
BlipTonne[i].setFlashTimer(2000);
|
||||
ShapeTonne.push(mp.colshapes.newSphere(posArr[i].x, posArr[i].y, posArr[i].z + 0.5, 1.75));
|
||||
}
|
||||
|
||||
BlipTonneBase = mp.blips.new(1, new mp.Vector3(-535.1912, -1713.742, 19.23861 - 1), { name: 'Müllmann', color: 5, shortRange: false });
|
||||
@@ -43,7 +39,6 @@
|
||||
ShapeTonneBase = mp.colshapes.newSphere(-535.1912, -1713.742, 19.23861 - 1, 10);
|
||||
});
|
||||
mp.events.add('SERVER:MuellmannBCSEntfernen', () => {
|
||||
|
||||
for (var i = 0; i < BlipTonne.length; i++) {
|
||||
if (BlipTonne[i] == null) continue;
|
||||
BlipTonne[i].destroy();
|
||||
@@ -79,10 +74,8 @@
|
||||
BlipTonne[i] = null;
|
||||
ShapeTonne[i].destroy();
|
||||
ShapeTonne[i] = null;
|
||||
MuellSack = mp.objects.new(3619689535, mp.players.local.position, { rotation: new mp.Vector3(0.0, 0.0, 0.0), alpha: 255, dimension: 0 });
|
||||
MuellSack.attachTo(mp.players.local.handle, mp.players.local.getBoneIndex(6286), 0.08, 0.0, -0.03, 270.0, 0.0, 25.0, true, true, false, false, 0, true);
|
||||
|
||||
interval = setInterval(function () { createMarker(); }, 250);
|
||||
interval = setInterval(function () { createMarker(); }, 2);
|
||||
}
|
||||
else {
|
||||
mp.gui.chat.push("Der Müllwagen ist bereits voll! Fahre zur Base und lade ab!");
|
||||
@@ -96,7 +89,6 @@
|
||||
}
|
||||
if (Shape == ShapeTonneHinten) {
|
||||
if (Traegt) {
|
||||
|
||||
Traegt = false;
|
||||
mp.events.callRemote('CLIENT:MuellmannAddSack');
|
||||
|
||||
@@ -108,10 +100,7 @@
|
||||
CheckpointTonneHinten = null;
|
||||
if (ShapeTonneHinten) ShapeTonneHinten.destroy();
|
||||
ShapeTonneHinten = null;
|
||||
MuellSack.destroy();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if (Shape == ShapeTonneBase) {
|
||||
BlipTonneBase.setRoute(false);
|
||||
@@ -134,11 +123,31 @@
|
||||
HintenVoll = true;
|
||||
});
|
||||
|
||||
|
||||
function createMarker() {
|
||||
if (vehicle != null) {
|
||||
var boneIndex = vehicle.getBoneIndexByName("platelight");
|
||||
let pos = vehicle.getWorldPositionOfBone(boneIndex);
|
||||
var boneIndex2 = vehicle.getBoneIndexByName("platelight");
|
||||
var boneIndex1 = vehicle.getBoneIndexByName("chassis_dummy");
|
||||
|
||||
let posPlate = vehicle.getWorldPositionOfBone(boneIndex2);
|
||||
let posCentre = vehicle.getWorldPositionOfBone(boneIndex1);
|
||||
|
||||
let plateVec = new mp.Vector3(posPlate.x, posPlate.y, posPlate.z);
|
||||
let lightVec = new mp.Vector3(posCentre.x, posCentre.y, posCentre.z);
|
||||
|
||||
let posPL = lightVec.subtract(plateVec);
|
||||
|
||||
let temp = new mp.Vector3(posPL.x * -1, posPL.y * -1, posPL.z * -1)
|
||||
|
||||
let length = Math.sqrt((temp.x * temp.x) + (temp.y * temp.y) + (temp.z * temp.z));
|
||||
|
||||
let x = temp.x / length;
|
||||
let y = temp.y / length;
|
||||
let z = temp.z / length;
|
||||
|
||||
temp = new mp.Vector3(x, y, z - 1);
|
||||
|
||||
let pos = plateVec.add(temp);
|
||||
|
||||
if (BlipTonneHinten) BlipTonneHinten.destroy();
|
||||
BlipTonneHinten = null;
|
||||
if (CheckpointTonneHinten) CheckpointTonneHinten.destroy();
|
||||
@@ -147,10 +156,7 @@
|
||||
ShapeTonneHinten = null;
|
||||
BlipTonneHinten = mp.blips.new(318, pos, { name: 'Müllmann', color: 24, shortRange: false });
|
||||
CheckpointTonneHinten = mp.markers.new(1, pos, 1, { direction: new mp.Vector3(-235.5747, -1685.475, 32.7207), color: [0, 255, 0, 255], visible: true, dimension: 0 });
|
||||
ShapeTonneHinten = mp.colshapes.newSphere(pos.x, pos.y, pos.z - 1, 2);
|
||||
|
||||
|
||||
ShapeTonneHinten = mp.colshapes.newSphere(pos.x, pos.y, pos.z, 2);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -22,8 +22,6 @@ body {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.main2 {
|
||||
z-index: 2;
|
||||
background: #0c0c0cc4;
|
||||
@@ -557,53 +555,48 @@ t#tf_nameorid {
|
||||
}
|
||||
|
||||
#tf_zahl {
|
||||
background-color: #313131; /* blau */
|
||||
background-color: #313131;
|
||||
border: none;
|
||||
height: 30px;
|
||||
width: 124px;
|
||||
height: 1vw;
|
||||
width: 4.3vw;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
font-size: 0.5vw;
|
||||
position: relative;
|
||||
left: 42%;
|
||||
top: 40%;
|
||||
left: 7.8vw;
|
||||
top: 1.2vw;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#tf_cancle {
|
||||
background-color: #ff0000;
|
||||
border: none;
|
||||
height: 32px;
|
||||
width: 124px;
|
||||
height: 1vw;
|
||||
width: 3vw;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
font-color: white;
|
||||
font-size: 0.5vw;
|
||||
position: relative;
|
||||
left: 33.7%;
|
||||
top: 44%;
|
||||
left: 12.5vw;
|
||||
top: -0.2vw;
|
||||
color: #ffffff;
|
||||
opacity: 0.5;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
#tf_submitZahl {
|
||||
background-color: #008CBA; /* blau */
|
||||
background-color: #008CBA;
|
||||
border: none;
|
||||
height: 32px;
|
||||
width: 124px;
|
||||
height: 1.5vw;
|
||||
width: 8vw;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
font-color: white;
|
||||
font-size: 0.5vw;
|
||||
position: relative;
|
||||
left: 42%;
|
||||
top: 40%;
|
||||
left: -1.8vw;
|
||||
top: 6vw;
|
||||
color: #ffffff;
|
||||
opacity: 0.5;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
@@ -614,15 +607,15 @@ t#tf_nameorid {
|
||||
#tf_zahl4 {
|
||||
background-color: #313131;
|
||||
border: none;
|
||||
height: 1.5vw;
|
||||
width: 5vw;
|
||||
height: 1vw;
|
||||
width: 4.3vw;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 0.6vw;
|
||||
font-size: 0.5vw;
|
||||
position: relative;
|
||||
left: 19vw;
|
||||
top: 13vw;
|
||||
left: 7.7vw;
|
||||
top: 1vw;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
@@ -635,12 +628,10 @@ t#tf_nameorid {
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 0.5vw;
|
||||
font-color: white;
|
||||
position: relative;
|
||||
left: 17.8vw;
|
||||
top: 9.4vw;
|
||||
left: 12.5vw;
|
||||
top: -0.3vw;
|
||||
color: #ffffff;
|
||||
opacity: 0.5;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
@@ -657,12 +648,10 @@ t#tf_nameorid {
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 0.5vw;
|
||||
font-color: white;
|
||||
position: relative;
|
||||
left: 21vw;
|
||||
top: 13vw;
|
||||
left: -5.4vw;
|
||||
top: 6vw;
|
||||
color: #ffffff;
|
||||
opacity: 0.5;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
@@ -692,7 +681,6 @@ t#tf_nameorid {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
#tf_acceptTrade {
|
||||
background-color: #009b03;
|
||||
border: none;
|
||||
@@ -731,11 +719,13 @@ t#tf_nameorid {
|
||||
color: #ffffff;
|
||||
opacity: 0.5;
|
||||
transition: 0.3s;
|
||||
}i
|
||||
}
|
||||
|
||||
#tf_cancle3:hover {
|
||||
opacity: 1
|
||||
}
|
||||
i
|
||||
|
||||
#tf_cancle3:hover {
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
#tf_cancle:hover {
|
||||
opacity: 1
|
||||
@@ -784,7 +774,7 @@ t#tf_nameorid {
|
||||
|
||||
.BoxBlue {
|
||||
background-color: #1b1b1b;
|
||||
height: 11.1vw;
|
||||
height: 8.9vw;
|
||||
width: 20.2vw;
|
||||
position: relative;
|
||||
margin-top: 11vw;
|
||||
@@ -801,7 +791,7 @@ t#tf_nameorid {
|
||||
display: inline-block;
|
||||
font-size: 0.5vw;
|
||||
position: relative;
|
||||
left: 5.45vw;
|
||||
left: 12.45vw;
|
||||
top: 0vw;
|
||||
color: #ffffff;
|
||||
}
|
||||
@@ -837,8 +827,8 @@ t#tf_nameorid {
|
||||
display: inline-block;
|
||||
font-size: 0.6vw;
|
||||
position: relative;
|
||||
left: 10.8vw;
|
||||
top: 5.45vw;
|
||||
left: -1.7vw;
|
||||
top: 6.45vw;
|
||||
color: #ffffff;
|
||||
opacity: 0.5;
|
||||
transition: 0.3s;
|
||||
@@ -858,8 +848,8 @@ t#tf_nameorid {
|
||||
display: inline-block;
|
||||
font-size: 0.5vw;
|
||||
position: relative;
|
||||
left: 7.5vw;
|
||||
top: 4.4vw;
|
||||
left: 7.8vw;
|
||||
top: 1.4vw;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
@@ -871,15 +861,15 @@ select.select_box2 {
|
||||
.blueIcon1 {
|
||||
position: relative;
|
||||
height: 3vw;
|
||||
margin-bottom: -3.1vw;
|
||||
margin-left: 13.4vw;
|
||||
margin-bottom: -3.6vw;
|
||||
margin-left: 8.5vw;
|
||||
}
|
||||
|
||||
.blueIcon2 {
|
||||
position: relative;
|
||||
height: 3vw;
|
||||
margin-bottom: 0.9vw;
|
||||
margin-left: 3.4vw;
|
||||
margin-bottom: -4.6vw;
|
||||
margin-left: 0.7vw;
|
||||
}
|
||||
|
||||
.blue3 {
|
||||
@@ -901,7 +891,6 @@ select.select_box2 {
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
|
||||
#tf_nameorid {
|
||||
background-color: #313131;
|
||||
border: none;
|
||||
@@ -917,7 +906,6 @@ select.select_box2 {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
|
||||
.alert_green {
|
||||
z-index: 2;
|
||||
background: rgba(85, 255, 0, 0.90);
|
||||
|
||||
@@ -11,40 +11,48 @@
|
||||
<body>
|
||||
|
||||
<div class="alerts" id='alertbox'>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="sidebar">
|
||||
<ul>
|
||||
<li name="side1" class="sidebaritem1" onclick="switchSite('backpackClass')"><img class="sideicon1" src="img/backpack/backpack.svg"><p class="bartext">Rucksack</p></li>
|
||||
<li name="side2" class="sidebaritem2" onclick="getVehicle()"><img class="sideicon2" src="img/backpack/car.svg"><p class="bartext">Fahrzeug</p></li>
|
||||
<li name="side3" class="sidebaritem3" onclick="switchSite('tradeClass')"><img class="sideicon4" src="img/backpack/trading.svg"><p class="bartext">Handel</p></li>
|
||||
<li name="side1" class="sidebaritem1" onclick="switchSite('backpackClass')">
|
||||
<img class="sideicon1" src="img/backpack/backpack.svg"><p class="bartext">Rucksack</p>
|
||||
</li>
|
||||
<li name="side2" class="sidebaritem2" onclick="getVehicle()">
|
||||
<img class="sideicon2" src="img/backpack/car.svg"><p class="bartext">Fahrzeug</p>
|
||||
</li>
|
||||
<!-- <li name="side3" class="sidebaritem3" onclick="switchSite('tradeClass')"><img class="sideicon4" src="img/backpack/trading.svg"><p class="bartext">Handel</p></li>
|
||||
<li name="side4" class="sidebaritem4 hidden" onclick="switchSite('handelClass')"><img class="sideicon4" src="img/backpack/trading.svg"><p class="bartext">Handeln</p></li>
|
||||
<li name="side5" class="sidebaritem5 hidden" onclick="getTrade()"><img class="sideicon4" src="img/backpack/save-money.svg"><p class="bartext">Anfrage</p></li>
|
||||
<li name="side6" class="sidebaritem6 hidden" onclick="switchSite('backClass')"><img class="sideicon4" src="img/backpack/back.svg"><p class="bartext">Zurück</p></li>
|
||||
<li name="side5" class="sidebaritem5 hidden" onclick="getTrade()"><img class="sideicon4" src="img/backpack/save-money.svg"><p class="bartext">Anfrage</p></li> -->
|
||||
<li name="side6" class="sidebaritem6 hidden" onclick="switchSite('backClass')">
|
||||
<img class="sideicon4" src="img/backpack/back.svg"><p class="bartext">Zurück</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div name="backpackClass" class="backpack">
|
||||
<div class="main">
|
||||
<div class="Betrag" style="display:none;">
|
||||
<input type="text" id="tf_zahl" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
|
||||
<button id='tf_submitZahl' onclick="">Bestätigen</button>
|
||||
<button id='tf_cancle' onclick="">Schließen</button>
|
||||
</div>
|
||||
<div class="Betrag2" style="display:none;">
|
||||
<div class="Betrag" style="display: none;">
|
||||
<div class="BoxBlue">
|
||||
<input type="text" id="tf_zahl2" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
|
||||
<button id="tf_submitZahlToHandel" onclick="">Zum handeln transferieren</button>
|
||||
<button id="tf_cancle2" onclick="">Schließen</button>
|
||||
<button id="tf_submitZahlToVehicle" onclick="">Zum Fahrzeug transferieren</button>
|
||||
<img class="blueIcon1" src="img/backpack/car.svg">
|
||||
<img class="blueIcon2" src="img/backpack/trading.svg">
|
||||
<input type="text" id="tf_zahl" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
|
||||
<button id="tf_cancle" onclick="">Schließen</button>
|
||||
<button id="tf_submitZahl" onclick="">Bestätigen</button>
|
||||
<img class="blueIcon1" src="img/backpack/trash2.svg"></img>
|
||||
</div>
|
||||
</div>
|
||||
<div class="title"><div class="titlecount"><span id="count1">0</span> / 40 Kilogramm</div><div class="titletext">Rucksack</div></div>
|
||||
<div class="Betrag2" style="display: none;">
|
||||
<div class="BoxBlue">
|
||||
<input type="text" id="tf_zahl2" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
|
||||
|
||||
<button id="tf_cancle2" onclick="">Schließen</button>
|
||||
<button id="tf_submitZahlToVehicle" onclick="">Zum Fahrzeug transferieren</button>
|
||||
<img class="blueIcon1" src="img/backpack/car.svg"></img>
|
||||
</div>
|
||||
</div>
|
||||
<div class="title">
|
||||
<div class="titlecount"><span id="count1">0</span> / 40 Kilogramm</div>
|
||||
<div class="titletext">Rucksack</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
<ul id="List0"></ul>
|
||||
</div>
|
||||
@@ -53,91 +61,60 @@
|
||||
|
||||
<div name="vehClass" class="veh hidden">
|
||||
<div class="main">
|
||||
<div class="title"><div class="titlecount"><span id="count2">0</span> / 250 Kilogramm</div><div class="titletext">Fahrzeug</div></div>
|
||||
<div class="Betrag4" style="display:none;">
|
||||
<input type="text" id="tf_zahl4" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
|
||||
<button id='tf_submitZahl4' onclick="">Zum Rucksack transferieren</button>
|
||||
<button id='tf_cancle4' onclick="">Schließen</button>
|
||||
<div class="title">
|
||||
<div class="titlecount"><span id="count2">0</span> / 250 Kilogramm</div>
|
||||
<div class="titletext">Fahrzeug</div>
|
||||
</div>
|
||||
<div class="Betrag4" style="display: none;">
|
||||
<div class="BoxBlue">
|
||||
|
||||
<img class="blueIcon1" src="img/backpack/backpack.svg">
|
||||
<button id="tf_cancle4" onclick="">Schließen</button><input type="text" id="tf_zahl4" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
|
||||
<button id="tf_submitZahl4" onclick="">Zum Rucksack transferieren</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
<ul id="List4"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div name="handelClass" class="handel hidden">
|
||||
<div class="main">
|
||||
<div class="Betrag3" style="display:none;">
|
||||
<input type="text" id="tf_zahl3" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
|
||||
<button id='tf_submitZahl3' onclick="">Bestätigen</button>
|
||||
<button id='tf_cancle3' onclick="">Schließen</button>
|
||||
</div>
|
||||
|
||||
<input type="text" id="tf_nameorid" name="fname" placeholder="Name oder ID eingeben">
|
||||
<button id='tf_submitTrade' onclick="">Senden</button>
|
||||
|
||||
<div class="title"><div class="titlecount"><span id="count3">0</span> Kilogramm</div><div class="titletext">Handeln</div></div>
|
||||
<div class="items">
|
||||
<ul id="List4"></ul>
|
||||
<ul id="List2"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div name="handelClass" class="handel hidden">
|
||||
<div class="main">
|
||||
<div class="Betrag3" style="display:none;">
|
||||
<input type="text" id="tf_zahl3" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
|
||||
<button id='tf_submitZahl3' onclick="">Bestätigen</button>
|
||||
<button id='tf_cancle3' onclick="">Schließen</button>
|
||||
<div name="anfrageClass" class="something hidden">
|
||||
<div class="main">
|
||||
<button id='tf_acceptTrade' onclick="">Annehmen</button>
|
||||
<div class="title"><div class="titlecount"><span id="count4">0</span> Kilogramm</div><div class="titletext">Anfrage</div></div>
|
||||
<div class="items">
|
||||
<ul id="List3"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<input type="text" id="tf_nameorid" name="fname" placeholder="Name oder ID eingeben">
|
||||
<button id='tf_submitTrade' onclick="">Senden</button>
|
||||
<div id="invisible" style="display: none"></div>
|
||||
|
||||
<div class="title"><div class="titlecount"><span id="count3">0</span> Kilogramm</div><div class="titletext">Handeln</div></div>
|
||||
<div class="items">
|
||||
<ul id="List2"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div name="anfrageClass" class="something hidden">
|
||||
<div class="main">
|
||||
<button id='tf_acceptTrade' onclick="">Annehmen</button>
|
||||
<div class="title"><div class="titlecount"><span id="count4">0</span> Kilogramm</div><div class="titletext">Anfrage</div></div>
|
||||
<div class="items">
|
||||
<ul id="List3"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="invisible" style="display:none"></div>
|
||||
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../js/jquery-3.3.1.min.js"></script>
|
||||
<script>
|
||||
var lastClass = "backpackClass";
|
||||
|
||||
var val = 0;
|
||||
var val = 0;
|
||||
|
||||
function changeTradeStatus(value) {
|
||||
val = JSON.parse(value);
|
||||
}
|
||||
|
||||
function getTrade() {
|
||||
if (val == 1) {
|
||||
switchSite('anfrageClass');
|
||||
}
|
||||
}
|
||||
|
||||
function getVehicle() {
|
||||
if (vehInv.length > 0) {
|
||||
switchSite('vehClass');
|
||||
} else {
|
||||
mp.trigger("Error", "Kofferraum leer oder kein Fahrzeug in der Nähe.")
|
||||
}
|
||||
}
|
||||
|
||||
$("#tf_acceptTrade").unbind('click').click(function () {
|
||||
if (anfrageInv.length > 0) {
|
||||
mp.trigger("CEF:acceptTrade");
|
||||
}
|
||||
});
|
||||
|
||||
$("#tf_submitTrade").unbind('click').click(function () {
|
||||
if (handelInv.length > 0) {
|
||||
var handelItemID = [];
|
||||
var handelItemAmount = [];
|
||||
for (i = 0; i < handelInv.length; i++) {
|
||||
handelItemID.push(handelInv[i].ID);
|
||||
handelItemAmount.push(handelInv[i].Amount);
|
||||
}
|
||||
mp.trigger("CEF:tradeItem", 0, JSON.stringify(String($('#tf_nameorid').val())), JSON.stringify(handelItemID), JSON.stringify(handelItemAmount))
|
||||
}
|
||||
});
|
||||
$("#tf_cancle4").unbind('click').click(function () {
|
||||
$(".Betrag4").hide();
|
||||
});
|
||||
@@ -151,20 +128,6 @@
|
||||
$(".Betrag2").hide();
|
||||
});
|
||||
|
||||
function setAnfrage(jsonIdArr, jsonAmountArr, jsonNameArr, jsonWeight) {
|
||||
var parsedIdArr = JSON.parse(jsonIdArr);
|
||||
var parsedAmountArr = JSON.parse(jsonAmountArr);
|
||||
var parsedNameArr = JSON.parse(jsonNameArr);
|
||||
var parsedWeight = JSON.parse(jsonWeight);
|
||||
for (var i = 0; i < parsedNameArr.length; i++) {
|
||||
var num = parsedAmountArr[i];
|
||||
var newItem = { Name: parsedNameArr[i], ID: parsedIdArr[i], Amount: num, Category: 3 };
|
||||
anfrageInv[i] = newItem;
|
||||
}
|
||||
$('#count4').html(parsedWeight / 1000);
|
||||
drawAnfrage();
|
||||
}
|
||||
|
||||
function switchSite(site) {
|
||||
if (site != lastClass) {
|
||||
if (site == "tradeClass") {
|
||||
@@ -203,111 +166,8 @@
|
||||
|
||||
$(document).ready(function () {
|
||||
mp.trigger('CEF:InventoryLoaded');
|
||||
mp.trigger('CEF:getNearVehicles');
|
||||
});
|
||||
|
||||
|
||||
function setItems(jsonName, jsonID, jsonAmount, nearPlayers) {
|
||||
var parsedName = JSON.parse(jsonName);
|
||||
var parsedID = JSON.parse(jsonID);
|
||||
var parsedAmount = JSON.parse(jsonAmount);
|
||||
for (var i = 0; i < parsedName.length; i++) {
|
||||
var num = parsedAmount[i];
|
||||
var newItem = { Name: parsedName[i], ID: parsedID[i], Amount: num, Category: 0 };
|
||||
rucksackInv[i] = newItem;
|
||||
}
|
||||
jsonInv = JSON.stringify(rucksackInv);
|
||||
ReceiveClientInformation(jsonInv);
|
||||
|
||||
var parsedPlayers = JSON.parse(nearPlayers);
|
||||
Players = parsedPlayers;
|
||||
for (var x = 0; x < parsedPlayers.length; x++) {
|
||||
$('.dropdown-content').append("<a value=" + x + ">" + parsedPlayers[x] + "</a>");
|
||||
}
|
||||
}
|
||||
var Players = [];
|
||||
function setWeight(jsonWeight) {
|
||||
var parsedWeight = JSON.parse(jsonWeight);
|
||||
$('#count1').html(parsedWeight / 1000);
|
||||
}
|
||||
|
||||
function setVehiclesInv(jsonVehInv) {
|
||||
var parsedVehInv = JSON.parse(jsonVehInv);
|
||||
vehInvItem.push(parsedVehInv);
|
||||
var vehicle = vehInvItem[0];
|
||||
for (i = 0; i < vehicle.ivehName.length; i++) {
|
||||
var newItem = { Name: vehicle.ivehName[i], ID: vehicle.ivehId[i], Amount: vehicle.ivehAmount[i], Category: 1 };
|
||||
vehInv.push(newItem);
|
||||
|
||||
}
|
||||
Origin.push(0);
|
||||
Origin.push(vehicle.ID);
|
||||
var jsonVehInv = JSON.stringify(vehInv);
|
||||
$('#count2').html(vehInvItem[0].currentWeight / 1000);
|
||||
RecieveVehicleInfo(jsonVehInv);
|
||||
}
|
||||
|
||||
|
||||
function RecieveVehicleInfo(json) {
|
||||
var parsed = JSON.parse(json);
|
||||
|
||||
for (var i = 0; i < parsed.length; i++) {
|
||||
var item = parsed[i];
|
||||
console.log(item);
|
||||
var quantity = parsed[i].Amount;
|
||||
var list = document.getElementById("List4");
|
||||
|
||||
var pictureElement = document.createElement("img");
|
||||
pictureElement.setAttribute("class", "sideicon15");
|
||||
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
|
||||
|
||||
var redButton = document.createElement("div");
|
||||
var redButtonImg = document.createElement("img");
|
||||
redButton.setAttribute("class", "red");
|
||||
redButton.setAttribute("onclick", "onAction(1," + item.ID + "," + item.Amount + ","+ i +");");
|
||||
redButtonImg.setAttribute("src", "img/backpack/trash.svg");
|
||||
redButtonImg.setAttribute("class", "redImg");
|
||||
redButton.appendChild(redButtonImg);
|
||||
|
||||
|
||||
var blueButton = document.createElement("div");
|
||||
var blueButtonImg = document.createElement("img");
|
||||
blueButton.setAttribute("class", "blue2");
|
||||
blueButton.setAttribute("onclick", "onAction(4," + item.ID + "," + item.Amount + ","+ i +");");
|
||||
blueButtonImg.setAttribute("src", "img/backpack/paper-plane.svg");
|
||||
blueButtonImg.setAttribute("class", "blueImg");
|
||||
blueButton.appendChild(blueButtonImg);
|
||||
|
||||
var listLength = list.length;
|
||||
|
||||
var row = 1;
|
||||
|
||||
if (listLength > 3) {
|
||||
row = 2;
|
||||
}
|
||||
if (listLength > 7) {
|
||||
row = 3;
|
||||
}
|
||||
if (listLength > 11) {
|
||||
row = 4;
|
||||
}
|
||||
if (listLength > 15) {
|
||||
row = 5;
|
||||
}
|
||||
if (listLength > 19) {
|
||||
row = 6;
|
||||
}
|
||||
|
||||
var Litem = document.createElement("li");
|
||||
Litem.setAttribute("class", "item" + row);
|
||||
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
|
||||
Litem.appendChild(pictureElement);
|
||||
Litem.appendChild(redButton);
|
||||
Litem.appendChild(blueButton);
|
||||
list.appendChild(Litem);
|
||||
}
|
||||
}
|
||||
|
||||
var rucksackInv = [];
|
||||
var handelInv = [];
|
||||
var vehInv = [];
|
||||
@@ -316,81 +176,43 @@
|
||||
|
||||
var vehInvItem = [];
|
||||
|
||||
function ReceiveClientInformation(json) {
|
||||
var parsed = JSON.parse(json);
|
||||
rucksackInv = parsed;
|
||||
for (var i = 0; i < parsed.length; i++) {
|
||||
var item = parsed[i];
|
||||
item.Category = 0;
|
||||
console.log(item);
|
||||
var quantity = parsed[i].Amount;
|
||||
var list = document.getElementById("List" + item.Category);
|
||||
|
||||
var pictureElement = document.createElement("img");
|
||||
pictureElement.setAttribute("class", "sideicon15");
|
||||
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
|
||||
|
||||
var redButton = document.createElement("div");
|
||||
var redButtonImg = document.createElement("img");
|
||||
redButton.setAttribute("class", "red");
|
||||
redButton.setAttribute("onclick", "onAction(1," + item.ID + "," + item.Amount + "," + i + ");");
|
||||
redButtonImg.setAttribute("src", "img/backpack/trash.svg");
|
||||
redButtonImg.setAttribute("class", "redImg");
|
||||
redButton.appendChild(redButtonImg);
|
||||
|
||||
var greenButton = document.createElement("div");
|
||||
var greenButtonImg = document.createElement("img");
|
||||
greenButton.setAttribute("class", "green");
|
||||
greenButton.setAttribute("onclick", "onAction(0," + item.ID + "," + item.Amount + "," + i + ");");
|
||||
greenButtonImg.setAttribute("src", "img/backpack/use.svg");
|
||||
greenButtonImg.setAttribute("class", "greenImg");
|
||||
greenButton.appendChild(greenButtonImg);
|
||||
|
||||
var blueButton = document.createElement("div");
|
||||
var blueButtonImg = document.createElement("img");
|
||||
blueButton.setAttribute("class", "blue");
|
||||
blueButton.setAttribute("onclick", "onAction(2," + item.ID + "," + item.Amount + ", " + i + ");");
|
||||
blueButtonImg.setAttribute("src", "img/backpack/paper-plane.svg");
|
||||
blueButtonImg.setAttribute("class", "blueImg");
|
||||
blueButton.appendChild(blueButtonImg);
|
||||
|
||||
var listLength = list.length;
|
||||
|
||||
var row = 1;
|
||||
|
||||
if (listLength > 3) {
|
||||
row = 2;
|
||||
}
|
||||
if (listLength > 7) {
|
||||
row = 3;
|
||||
}
|
||||
if (listLength > 11) {
|
||||
row = 4;
|
||||
}
|
||||
if (listLength > 15) {
|
||||
row = 5;
|
||||
}
|
||||
if (listLength > 19) {
|
||||
row = 6;
|
||||
}
|
||||
|
||||
var Litem = document.createElement("li");
|
||||
Litem.setAttribute("class", "item" + row);
|
||||
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
|
||||
Litem.appendChild(pictureElement);
|
||||
Litem.appendChild(redButton);
|
||||
Litem.appendChild(greenButton);
|
||||
Litem.appendChild(blueButton);
|
||||
list.appendChild(Litem);
|
||||
function setBackpackItems(jsonItemArr) {
|
||||
console.log(jsonItemArr);
|
||||
var parsedItemArr = JSON.parse(jsonItemArr)
|
||||
rucksackInv = [];
|
||||
for (var i = 0; i < parsedItemArr.length; i++) {
|
||||
var item = parsedItemArr[i];
|
||||
var newItem = { Name: item.Name, ID: item.ItemId, Amount: item.Amount, Category: 0 };
|
||||
rucksackInv.push(newItem);
|
||||
$('#count1').html(item.Weight / 1000);
|
||||
}
|
||||
drawRucksack();
|
||||
}
|
||||
|
||||
function getVehicle() {
|
||||
mp.trigger("CEF:callVehicleInventory");
|
||||
}
|
||||
|
||||
function setVehicleItems(jsonItemArr) {
|
||||
var parsedItemArr = JSON.parse(jsonItemArr)
|
||||
vehInv = [];
|
||||
for (var i = 0; i < parsedItemArr.length; i++) {
|
||||
var item = parsedItemArr[i];
|
||||
var newItem = { Name: item.Name, ID: item.ItemId, Amount: item.Amount, Category: 0 };
|
||||
vehInv.push(newItem);
|
||||
$('#count2').html(item.Weight / 1000);
|
||||
}
|
||||
|
||||
switchSite('vehClass');
|
||||
drawVehicle();
|
||||
}
|
||||
|
||||
var clnc = 1;
|
||||
|
||||
function alertGreen(JsonAmount, JsonName) {
|
||||
var amount = JSON.parse(JsonAmount);
|
||||
var amount = JSON.parse(JsonAmount);
|
||||
var name = JSON.parse(JsonName);
|
||||
|
||||
|
||||
var list = document.getElementById("alertbox");
|
||||
var Litem = document.createElement("div");
|
||||
Litem.setAttribute("class", "alert_green");
|
||||
@@ -401,13 +223,13 @@
|
||||
$(Litem).fadeOut(500, function () {
|
||||
$(Litem).remove();
|
||||
});
|
||||
}, 5000);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
function alertRed(JsonAmount, JsonName) {
|
||||
var amount = JSON.parse(JsonAmount);
|
||||
var amount = JSON.parse(JsonAmount);
|
||||
var name = JSON.parse(JsonName);
|
||||
|
||||
|
||||
var list = document.getElementById("alertbox");
|
||||
var Litem = document.createElement("div");
|
||||
Litem.setAttribute("class", "alert_red");
|
||||
@@ -423,7 +245,7 @@
|
||||
|
||||
function alertError(jsonString) {
|
||||
var string = JSON.parse(jsonString);
|
||||
|
||||
|
||||
var list = document.getElementById("alertbox");
|
||||
var Litem = document.createElement("div");
|
||||
Litem.setAttribute("class", "alert_red");
|
||||
@@ -445,21 +267,21 @@
|
||||
var list = document.getElementById("alertbox");
|
||||
var Litem = document.createElement("div");
|
||||
Litem.setAttribute("class", "alert_blue");
|
||||
Litem.appendChild(document.createTextNode("Du hast " + amount + "x " + name + " ins "+transferInv+" transferiert."));
|
||||
Litem.appendChild(document.createTextNode("Du hast " + amount + "x " + name + " ins " + transferInv + " transferiert."));
|
||||
$(Litem).hide().appendTo(list).fadeIn(500);
|
||||
$(Litem).fadeIn(500);
|
||||
setTimeout(function () {
|
||||
$(Litem).fadeOut(500, function () {
|
||||
$(Litem).remove();
|
||||
});
|
||||
}, 5000);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
function removeItems(JsonId, JsonAmount) {
|
||||
|
||||
|
||||
var amount = JSON.parse(JsonAmount);
|
||||
var id = JSON.parse(JsonId);
|
||||
console.log("start : " + amount +" " + id);
|
||||
console.log("start : " + amount + " " + id);
|
||||
for (var i = 0; i < rucksackInv.length; i++) {
|
||||
console.log(i);
|
||||
if (rucksackInv[i].ID == id) {
|
||||
@@ -471,14 +293,13 @@
|
||||
|
||||
rucksackInv.splice(i, 1);
|
||||
}
|
||||
|
||||
|
||||
drawRucksack();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onAction(action, id, ammount, i) {
|
||||
$(".Betrag").hide();
|
||||
|
||||
@@ -494,11 +315,9 @@
|
||||
if ($('#tf_zahl').val() < ammount && ammount > 0) {
|
||||
mp.trigger("CEF:useItem", JSON.stringify("drop"), JSON.stringify($('#tf_zahl').val()), JSON.stringify(rucksackInv[i].ID))
|
||||
} else if ($('#tf_zahl').val() >= ammount) {
|
||||
mp.trigger("CEF:useItem", JSON.stringify("drop"), JSON.stringify(ammount), JSON.stringify(rucksackInv[i].ID))
|
||||
mp.trigger("CEF:useItem", JSON.stringify("drop"), JSON.stringify(ammount), JSON.stringify(rucksackInv[i].ID))
|
||||
}
|
||||
$(".Betrag").hide();
|
||||
drawRucksack();
|
||||
drawVehicle();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
});
|
||||
@@ -507,209 +326,33 @@
|
||||
{
|
||||
$(".Betrag2").show();
|
||||
var Copy = Object.assign({}, rucksackInv[i]);
|
||||
$("#tf_submitZahlToHandel").unbind('click').click(function () {
|
||||
var y = parseInt($('#tf_zahl2').val(), 10);
|
||||
if ($('#tf_zahl2').val() < ammount && ammount > 0) {
|
||||
|
||||
for (x = 0; x < handelInv.length; x++) {
|
||||
if (handelInv[x].ID == Copy.ID) {
|
||||
handelInv[x].Amount += y;
|
||||
rucksackInv[i].Amount -= y;
|
||||
$(".Betrag2").hide();
|
||||
drawHandel();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
}
|
||||
handelInv.push(Copy);
|
||||
handelInv[handelInv.length - 1].Amount = y;
|
||||
handelInv[handelInv.length - 1].Category = 2;
|
||||
rucksackInv[i].Amount -= y;
|
||||
} else if ($('#tf_zahl2').val() >= ammount) {
|
||||
for (x = 0; x < handelInv.length; x++) {
|
||||
if (handelInv[x].ID == Copy.ID) {
|
||||
handelInv[x].Amount += y;
|
||||
rucksackInv.splice(i, 1);
|
||||
$(".Betrag2").hide();
|
||||
drawHandel();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
}
|
||||
handelInv.push(Copy);
|
||||
handelInv[handelInv.length - 1].Category = 2;
|
||||
rucksackInv.splice(i, 1);
|
||||
}
|
||||
$(".Betrag2").hide();
|
||||
drawHandel();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
});
|
||||
$("#tf_submitZahlToVehicle").unbind('click').click(function () {
|
||||
if (Origin.length < 2) {
|
||||
$(".Betrag2").hide();
|
||||
drawVehicle();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
Origin[0] = 0;
|
||||
var y = parseInt($('#tf_zahl2').val(), 10);
|
||||
if ($('#tf_zahl2').val() < ammount && ammount > 0) {
|
||||
|
||||
for (x = 0; x < vehInv.length; x++) {
|
||||
if (vehInv[x].ID == Copy.ID) {
|
||||
vehInv[x].Amount += y;
|
||||
rucksackInv[i].Amount -= y;
|
||||
$(".Betrag2").hide();
|
||||
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(rucksackInv[i].ID), JSON.stringify(rucksackInv[i].Amount), JSON.stringify(y));
|
||||
drawVehicle();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vehInv.push(Copy);
|
||||
vehInv[vehInv.length - 1].Amount = y;
|
||||
vehInv[vehInv.length - 1].Category = 2;
|
||||
rucksackInv[i].Amount -= y;
|
||||
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(rucksackInv[i].ID), JSON.stringify(rucksackInv[i].Amount), JSON.stringify(y));
|
||||
mp.trigger("CEF:backpackToVehicle", JSON.stringify(rucksackInv[i].ID), JSON.stringify(y));
|
||||
} else if ($('#tf_zahl2').val() >= ammount) {
|
||||
for (x = 0; x < vehInv.length; x++) {
|
||||
if (vehInv[x].ID == Copy.ID) {
|
||||
vehInv[x].Amount += y;
|
||||
rucksackInv.splice(i, 1);
|
||||
$(".Betrag2").hide();
|
||||
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(0), JSON.stringify(ammount));
|
||||
drawVehicle();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vehInv.push(Copy);
|
||||
vehInv[vehInv.length - 1].Category = 2;
|
||||
rucksackInv.splice(i, 1);
|
||||
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(0), JSON.stringify(ammount));
|
||||
mp.trigger("CEF:backpackToVehicle", JSON.stringify(rucksackInv[i].ID), JSON.stringify(ammount));
|
||||
}
|
||||
$(".Betrag2").hide();
|
||||
drawVehicle();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
});
|
||||
}
|
||||
if (action == 3) {
|
||||
$(".Betrag3").show();
|
||||
var Copy = Object.assign({}, handelInv[i]);
|
||||
$("#tf_submitZahl3").unbind('click').click(function () {
|
||||
var y = parseInt($('#tf_zahl3').val(), 10);
|
||||
if ($('#tf_zahl3').val() < ammount && ammount > 0) {
|
||||
|
||||
for (x = 0; x < rucksackInv.length; x++) {
|
||||
if (rucksackInv[x].ID == Copy.ID) {
|
||||
rucksackInv[x].Amount += y;
|
||||
handelInv[i].Amount -= y;
|
||||
$(".Betrag3").hide();
|
||||
drawHandel();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
}
|
||||
rucksackInv.push(Copy);
|
||||
rucksackInv[rucksackInv.length - 1].Amount = y;
|
||||
rucksackInv[rucksackInv.length - 1].Category = 0;
|
||||
handelInv[i].Amount -= y;
|
||||
} else if ($('#tf_zahl3').val() >= ammount) {
|
||||
for (x = 0; x < rucksackInv.length; x++) {
|
||||
if (rucksackInv[x].ID == Copy.ID) {
|
||||
rucksackInv[x].Amount += ammount;
|
||||
handelInv.splice(i, 1);
|
||||
$(".Betrag3").hide();
|
||||
drawHandel();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
}
|
||||
rucksackInv.push(Copy);
|
||||
rucksackInv[rucksackInv.length - 1].Category = 0;
|
||||
handelInv.splice(i, 1);
|
||||
}
|
||||
$(".Betrag3").hide();
|
||||
drawHandel();
|
||||
drawRucksack();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
});
|
||||
}
|
||||
if (action == 4) {
|
||||
$(".Betrag4").show();
|
||||
var Copy = Object.assign({}, vehInv[i]);
|
||||
$("#tf_submitZahl4").unbind('click').click(function () {
|
||||
Origin[0] = 1;
|
||||
var y = parseInt($('#tf_zahl4').val(), 10);
|
||||
if ($('#tf_zahl4').val() < ammount && ammount > 0) {
|
||||
|
||||
for (x = 0; x < rucksackInv.length; x++) {
|
||||
if (rucksackInv[x].ID == Copy.ID) {
|
||||
rucksackInv[x].Amount += y;
|
||||
vehInv[i].Amount -= y;
|
||||
$(".Betrag2").hide();
|
||||
mp.trigger("CEF:saveVehicleTransfer",1, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(vehInv[i].Amount), JSON.stringify(y));
|
||||
drawRucksack();
|
||||
drawVehicle();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(rucksackInv);
|
||||
rucksackInv.push(Copy);
|
||||
rucksackInv[rucksackInv.length - 1].Amount = y;
|
||||
rucksackInv[rucksackInv.length - 1].Category = 2;
|
||||
vehInv[i].Amount -= y;
|
||||
console.log(rucksackInv);
|
||||
mp.trigger("CEF:saveVehicleTransfer",1, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(vehInv[i].Amount), JSON.stringify(y));
|
||||
mp.trigger("CEF:vehicleToBackpack", JSON.stringify(vehInv[i].ID), JSON.stringify(y));
|
||||
} else if ($('#tf_zahl4').val() >= ammount) {
|
||||
for (x = 0; x < rucksackInv.length; x++) {
|
||||
if (rucksackInv[x].ID == Copy.ID) {
|
||||
rucksackInv[x].Amount += ammount;
|
||||
vehInv.splice(i, 1);
|
||||
$(".Betrag2").hide();
|
||||
mp.trigger("CEF:saveVehicleTransfer",1, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(0), JSON.stringify(ammount));
|
||||
drawRucksack();
|
||||
drawVehicle();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rucksackInv.push(Copy);
|
||||
rucksackInv[rucksackInv.length - 1].Amount = ammount;
|
||||
rucksackInv[rucksackInv.length - 1].Category = 2;
|
||||
vehInv.splice(i, 1);
|
||||
mp.trigger("CEF:saveVehicleTransfer",1, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(0), JSON.stringify(ammount));
|
||||
mp.trigger("CEF:vehicleToBackpack", JSON.stringify(vehInv[i].ID), JSON.stringify(ammount));
|
||||
}
|
||||
$(".Betrag4").hide();
|
||||
|
||||
drawRucksack();
|
||||
drawVehicle();
|
||||
|
||||
$(".Betrag4").hide();
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
});
|
||||
@@ -736,7 +379,6 @@
|
||||
pictureElement.setAttribute("class", "sideicon15");
|
||||
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
|
||||
|
||||
|
||||
var blueButton = document.createElement("div");
|
||||
var blueButtonImg = document.createElement("img");
|
||||
blueButton.setAttribute("class", "blue3");
|
||||
@@ -878,16 +520,15 @@
|
||||
var redButton = document.createElement("div");
|
||||
var redButtonImg = document.createElement("img");
|
||||
redButton.setAttribute("class", "red");
|
||||
redButton.setAttribute("onclick", "onAction(1," + item.ID + "," + item.Amount + ","+ i +");");
|
||||
redButton.setAttribute("onclick", "onAction(1," + item.ID + "," + item.Amount + "," + i + ");");
|
||||
redButtonImg.setAttribute("src", "img/backpack/trash.svg");
|
||||
redButtonImg.setAttribute("class", "redImg");
|
||||
redButton.appendChild(redButtonImg);
|
||||
|
||||
|
||||
var blueButton = document.createElement("div");
|
||||
var blueButtonImg = document.createElement("img");
|
||||
blueButton.setAttribute("class", "blue2");
|
||||
blueButton.setAttribute("onclick", "onAction(4," + item.ID + "," + item.Amount + ","+ i +");");
|
||||
blueButton.setAttribute("onclick", "onAction(4," + item.ID + "," + item.Amount + "," + i + ");");
|
||||
blueButtonImg.setAttribute("src", "img/backpack/paper-plane.svg");
|
||||
blueButtonImg.setAttribute("class", "blueImg");
|
||||
blueButton.appendChild(blueButtonImg);
|
||||
@@ -943,7 +584,6 @@
|
||||
pictureElement.setAttribute("class", "sideicon15");
|
||||
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
|
||||
|
||||
|
||||
var listLength = list.length;
|
||||
|
||||
var row = 1;
|
||||
@@ -974,8 +614,6 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IEntity, IPlayer, IPlayerPool, IVehicle, IVehiclePool, VehicleSeat, EntityType } from "../../game";
|
||||
import { IEntity, IPlayer, IEntityAttachments, IEntityAttachmentPool, IPlayerPool, IVehicle, IVehiclePool, VehicleSeat, EntityType } from "../../game";
|
||||
import { parseJson } from "../../util";
|
||||
|
||||
class RageEntity implements IEntity {
|
||||
@@ -8,6 +8,10 @@ class RageEntity implements IEntity {
|
||||
return this.entity.id;
|
||||
}
|
||||
|
||||
get remoteId(): any {
|
||||
return this.entity.remoteId;
|
||||
}
|
||||
|
||||
constructor(entity: EntityMp) {
|
||||
this.entity = entity;
|
||||
}
|
||||
@@ -32,6 +36,8 @@ class RageEntity implements IEntity {
|
||||
|
||||
class RagePlayer extends RageEntity implements IPlayer {
|
||||
private player: PlayerMp;
|
||||
public __attachments: any[];
|
||||
public __attachmentObjects: any[];
|
||||
|
||||
get name(): string {
|
||||
return this.player.name;
|
||||
@@ -52,6 +58,78 @@ class RagePlayer extends RageEntity implements IPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
class RageAttachments implements IEntityAttachments {
|
||||
remoteId: any;
|
||||
public __attachments: any[];
|
||||
public __attachmentObjects: any[];
|
||||
|
||||
constructor(entity: IEntity, attachments: any[], attachmentObjects: any[]) {
|
||||
this.remoteId = entity.remoteId;
|
||||
this.__attachments = attachments;
|
||||
this.__attachmentObjects = attachmentObjects;
|
||||
}
|
||||
}
|
||||
|
||||
class RageEntityAttachmentPool implements IEntityAttachmentPool {
|
||||
public attachmentPool: IEntityAttachments[];
|
||||
remove(entity: IEntity) {
|
||||
for (let obj of this.attachmentPool.keys()) {
|
||||
if (entity.remoteId == this.attachmentPool[obj].remoteId) delete this.attachmentPool[obj];
|
||||
}
|
||||
}
|
||||
find(entity: EntityMp): IEntityAttachments {
|
||||
|
||||
for (let i of this.attachmentPool.keys()) {
|
||||
let pool = this.attachmentPool[i];
|
||||
for (let obj of pool.__attachmentObjects) {
|
||||
if (entity == obj) { return pool;}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
set(entity: IEntity, attachments: any[], attachmentObjects: any[]): IEntityAttachments {
|
||||
if (!this.attachmentPool) {
|
||||
let e = new RageAttachments(entity, attachments, attachmentObjects);
|
||||
this.attachmentPool = [];
|
||||
this.attachmentPool.push(e);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
for (let obj of this.attachmentPool.keys()) {
|
||||
if (entity.remoteId == this.attachmentPool[obj].remoteId) { this.remove(entity); }
|
||||
}
|
||||
let e = new RageAttachments(entity, attachments, attachmentObjects);
|
||||
this.attachmentPool.push(e);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
at(remoteId: any): IEntityAttachments {
|
||||
if (!this.attachmentPool) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let obj of this.attachmentPool.keys()) {
|
||||
if (remoteId == this.attachmentPool[obj].remoteId) { return this.attachmentPool[obj]; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
get(entity: IEntity): IEntityAttachments {
|
||||
if (!this.attachmentPool) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let obj of this.attachmentPool.keys()) {
|
||||
if (entity.remoteId == this.attachmentPool[obj].remoteId) { return this.attachmentPool[obj]; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class RagePlayerPool implements IPlayerPool {
|
||||
get local(): IPlayer {
|
||||
return new RagePlayer(mp.players.local);
|
||||
@@ -103,14 +181,14 @@ class RageVehiclePool implements IVehiclePool {
|
||||
fn(new RageVehicle(e));
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export {
|
||||
RageEntity,
|
||||
RagePlayer,
|
||||
RagePlayerPool,
|
||||
RageAttachments,
|
||||
RageEntityAttachmentPool,
|
||||
RageVehicle,
|
||||
RageVehiclePool,
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { IGame, IUi, IEvents, IPlayerPool, IVehiclePool } from "../../game";
|
||||
import { IGame, IUi, IEvents, IPlayerPool, IVehiclePool, IEntityAttachmentPool } from "../../game";
|
||||
import RageEvents from "./events";
|
||||
import RageUi from "./ui";
|
||||
import { RagePlayerPool, RageVehiclePool } from "./entities";
|
||||
import { RagePlayerPool, RageVehiclePool, RageEntityAttachmentPool } from "./entities";
|
||||
|
||||
export default class RageGame implements IGame {
|
||||
players: IPlayerPool = new RagePlayerPool();
|
||||
vehicles: IVehiclePool = new RageVehiclePool();
|
||||
|
||||
attachments: IEntityAttachmentPool = new RageEntityAttachmentPool();
|
||||
events: IEvents = new RageEvents;
|
||||
ui: IUi = new RageUi;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
players: IPlayerPool;
|
||||
vehicles: IVehiclePool;
|
||||
attachments: IEntityAttachmentPool;
|
||||
|
||||
disableDefaultEngineBehaviour(): void;
|
||||
}
|
||||
@@ -41,6 +42,7 @@ interface IBrowser {
|
||||
|
||||
interface IEntity {
|
||||
id: number;
|
||||
remoteId: any;
|
||||
type: EntityType;
|
||||
getSharedData<T>(key: string): T;
|
||||
}
|
||||
@@ -51,6 +53,12 @@ interface IPlayer extends IEntity {
|
||||
vehicle: IVehicle;
|
||||
}
|
||||
|
||||
interface IEntityAttachments {
|
||||
remoteId: any;
|
||||
__attachments: any[];
|
||||
__attachmentObjects: any[];
|
||||
}
|
||||
|
||||
interface IVehicle extends IEntity {
|
||||
isSeatFree(seat: VehicleSeat): boolean;
|
||||
setEngineStatus(status: boolean, instantly: boolean, otherwise: boolean);
|
||||
@@ -67,8 +75,16 @@ interface IPlayerPool extends IEntityPool<IPlayer> {
|
||||
local: IPlayer;
|
||||
}
|
||||
|
||||
interface IVehiclePool extends IEntityPool<IVehicle> {
|
||||
interface IEntityAttachmentPool {
|
||||
attachmentPool: IEntityAttachments[];
|
||||
find(entity: EntityMp): IEntityAttachments;
|
||||
remove(entity: IEntity): void;
|
||||
set(entity: IEntity, attachments: any[], attachmentObjects: any[]): IEntityAttachments;
|
||||
at(handle: any): IEntityAttachments;
|
||||
get(entity: IEntity): IEntityAttachments;
|
||||
}
|
||||
|
||||
interface IVehiclePool extends IEntityPool<IVehicle> {
|
||||
}
|
||||
|
||||
enum EntityType {
|
||||
@@ -122,6 +138,8 @@ export {
|
||||
IBrowser,
|
||||
|
||||
IPlayer,
|
||||
IEntityAttachments,
|
||||
IEntityAttachmentPool,
|
||||
IVehicle,
|
||||
IEntity,
|
||||
IEntityPool,
|
||||
|
||||
@@ -209,6 +209,15 @@ taximeterInput(globalData);
|
||||
import refuseCollector from './Jobs/RefuseCollector';
|
||||
refuseCollector();
|
||||
|
||||
import PedCreator from './Ped/PedCreator';
|
||||
PedCreator();
|
||||
|
||||
import attachmentManager from './util/attachmentMngr';
|
||||
attachmentManager(game);
|
||||
|
||||
import relativeVector from './util/relativevector';
|
||||
relativeVector();
|
||||
|
||||
require('./Gui/policedepartment');
|
||||
|
||||
interface VehicleData {
|
||||
@@ -218,4 +227,6 @@ interface VehicleData {
|
||||
|
||||
export {
|
||||
VehicleData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,44 +1,32 @@
|
||||
|
||||
|
||||
export default function inventory(globalData: IGlobalData): void {
|
||||
|
||||
export default function inventory(globalData: IGlobalData): void {
|
||||
var invBrowser: BrowserMp = null;
|
||||
var itemIdArr;
|
||||
var itemAmountArr;
|
||||
var invWeight;
|
||||
var itemNameArr;
|
||||
var itemArr;
|
||||
var offerItemArr;
|
||||
var tradeItemArr;
|
||||
var vehItemArr;
|
||||
|
||||
var ivehArr;
|
||||
var loaded = false;
|
||||
|
||||
var Players;
|
||||
|
||||
mp.events.add('setVehiclesInventory', (vehInvArr) => {
|
||||
ivehArr = vehInvArr;
|
||||
invBrowser.execute(`setVehiclesInv('${JSON.stringify(ivehArr)}');`);
|
||||
});
|
||||
|
||||
mp.events.add('showVehInventory', () => {
|
||||
invBrowser.execute(`execVehInv();`);
|
||||
});
|
||||
var open = false;
|
||||
mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => {
|
||||
mp.events.add('inventoryShow', () => {
|
||||
if (invBrowser !== null) {
|
||||
invBrowser.destroy()
|
||||
invBrowser = null;
|
||||
globalData.InInput = false;
|
||||
loaded = false;
|
||||
mp.gui.cursor.show(false, false);
|
||||
return;
|
||||
}
|
||||
if (!globalData.InInput) {
|
||||
globalData.InInput = true;
|
||||
mp.gui.cursor.show(true, true);
|
||||
itemArr = [];
|
||||
vehItemArr = [];
|
||||
invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html');
|
||||
Players = playersArr;
|
||||
itemIdArr = iIdArr;
|
||||
itemAmountArr = iAmountArr;
|
||||
itemNameArr = iNameArr;
|
||||
invWeight = iWeight;
|
||||
}
|
||||
}
|
||||
});
|
||||
var offer = 0;
|
||||
|
||||
@@ -55,22 +43,42 @@ export default function inventory(globalData: IGlobalData): void {
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("addTradeItems", (itemId, itemAmount, itemName, weight) => {
|
||||
tradeItemID = JSON.stringify(itemId);
|
||||
tradeItemAmount = JSON.stringify(itemAmount);
|
||||
tradeItemName = JSON.stringify(itemName);
|
||||
tradeItemWeight = JSON.stringify(weight);
|
||||
if (invBrowser != null)
|
||||
invBrowser.execute(`setAnfrage('${tradeItemID}','${tradeItemAmount}','${tradeItemName}','${tradeItemWeight}');`);
|
||||
mp.events.addDataHandler("backpackItems", (entity: EntityMp, jsonItemArr) => {
|
||||
if (entity.handle != mp.players.local.handle) return;
|
||||
itemArr = JSON.parse(jsonItemArr);
|
||||
if (loaded)
|
||||
invBrowser.execute(`setBackpackItems('${JSON.stringify(itemArr)}',true)`);
|
||||
});
|
||||
|
||||
mp.events.add("CEF:saveVehicleTransfer", (val, jsonOrigin, jsonInvID, jsonInvAmount, jsonVehAmount) => {
|
||||
if (val == 0) {
|
||||
mp.events.callRemote('saveInventory', jsonInvID, jsonInvAmount, jsonOrigin, jsonVehAmount);
|
||||
} else if(val == 1){
|
||||
mp.events.callRemote('saveVehicleInventory', jsonInvID, jsonInvAmount, jsonOrigin, jsonVehAmount);
|
||||
|
||||
mp.events.addDataHandler("vehicleItems", (entity: EntityMp, jsonItemArr) => {
|
||||
if (entity != mp.players.local) return;
|
||||
vehItemArr = JSON.parse(jsonItemArr);
|
||||
|
||||
if (loaded)
|
||||
invBrowser.execute(`setVehicleItems('${JSON.stringify(vehItemArr)}')`);
|
||||
});
|
||||
|
||||
mp.events.add("CEF:InventoryLoaded", () => {
|
||||
invBrowser.execute(`setBackpackItems('${JSON.stringify(itemArr)}')`);
|
||||
if (vehItemArr.length != 0) {
|
||||
invBrowser.execute(`setVehicleItems('${JSON.stringify(vehItemArr)}')`);
|
||||
}
|
||||
|
||||
|
||||
//invBrowser.execute(`setTradeItems('${JSON.stringify(tradeItemArr)}')`);
|
||||
//invBrowser.execute(`setOfferItems('${JSON.stringify(offerItemArr)}')`);
|
||||
loaded = true;
|
||||
});
|
||||
|
||||
mp.events.add("CEF:callVehicleInventory", () => {
|
||||
mp.events.callRemote("CLIENT:getVehicleInventory")
|
||||
});
|
||||
|
||||
mp.events.add("CEF:backpackToVehicle", (jsonItemId, jsonAmount) => {
|
||||
mp.events.callRemote('transferToVehicle', jsonItemId, jsonAmount);
|
||||
});
|
||||
|
||||
mp.events.add("CEF:vehicleToBackpack", (jsonItemId, jsonAmount) => {
|
||||
mp.events.callRemote('transferToBackpack', jsonItemId, jsonAmount);
|
||||
});
|
||||
|
||||
mp.events.add("CEF:useItem", (type, amount, id) => {
|
||||
@@ -111,22 +119,6 @@ export default function inventory(globalData: IGlobalData): void {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mp.events.add("CEF:InventoryLoaded", () => {
|
||||
if (offer == 1) {
|
||||
invBrowser.execute(`changeTradeStatus('${JSON.stringify(offer)}')`);
|
||||
invBrowser.execute(`setAnfrage('${tradeItemID}','${tradeItemAmount}','${tradeItemName}','${tradeItemWeight}');`);
|
||||
}
|
||||
|
||||
invBrowser.execute(`setItems('${JSON.stringify(itemNameArr)}','${JSON.stringify(itemIdArr)}','${JSON.stringify(itemAmountArr)}','${JSON.stringify(Players)}');`);
|
||||
invBrowser.execute(`setWeight('${JSON.stringify(invWeight)}');`);
|
||||
});
|
||||
|
||||
|
||||
mp.events.add("CEF:getNearVehicles", () => {
|
||||
mp.events.callRemote('getNearVehicles');
|
||||
});
|
||||
|
||||
|
||||
mp.events.add("CEF:acceptTrade", () => {
|
||||
if (invBrowser !== null) {
|
||||
@@ -135,7 +127,6 @@ export default function inventory(globalData: IGlobalData): void {
|
||||
invBrowser = null;
|
||||
mp.gui.cursor.show(false, false);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("CEF:declineTrade", () => {
|
||||
@@ -169,5 +160,4 @@ export default function inventory(globalData: IGlobalData): void {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
|
||||
export default function gangwarHandle(globalData: IGlobalData) {
|
||||
|
||||
export default function gangwarHandle(globalData: IGlobalData) {
|
||||
function inside(point, vs) {
|
||||
let x = point[0],
|
||||
y = point[1];
|
||||
@@ -35,7 +32,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
};
|
||||
|
||||
var Gangturf = class {
|
||||
|
||||
name: string;
|
||||
id: number;
|
||||
range: number;
|
||||
@@ -70,12 +66,11 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
}
|
||||
|
||||
_setup(name, id, x, y, range, color, rot, owner, edit, vector, value) {
|
||||
|
||||
var self = this;
|
||||
self.name = name;
|
||||
self.id = id;
|
||||
self.range = range;
|
||||
self.setColor(owner);
|
||||
self.setColor(owner);
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
self.rotation = rot;
|
||||
@@ -97,7 +92,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
} else {
|
||||
self.leaderBlipVector = null;
|
||||
}
|
||||
|
||||
|
||||
self.leaderColShape = null;
|
||||
}
|
||||
|
||||
@@ -127,7 +122,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
|
||||
loadArea() {
|
||||
var self = this;
|
||||
|
||||
self.blip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, self.range);
|
||||
|
||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.blip, 5);
|
||||
@@ -137,25 +131,21 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
self._colshape = mp.colshapes.newCircle(self.x, self.y, self.range * 1.5);
|
||||
}
|
||||
render() {
|
||||
|
||||
var self = this;
|
||||
if (self._colshape) {
|
||||
if (self.edit == true) {
|
||||
let vector3 = mp.players.local.getRotation(2);
|
||||
self.rotation = Math.round(vector3.z);
|
||||
//self.blip.setPosition(mp.players.local.position.x, mp.players.local.position.y, 1);
|
||||
|
||||
|
||||
mp.game.invoke(Natives.SET_BLIP_COORDS, self.blip, mp.players.local.position.x, mp.players.local.position.y, 1);
|
||||
self.x = mp.players.local.position.x;
|
||||
self.y = mp.players.local.position.y;
|
||||
}
|
||||
//self.blip.setRotation(self.rotation);
|
||||
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
|
||||
|
||||
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (self._status == "attack" || self.edit == true) {
|
||||
if (self._colshape) {
|
||||
if (mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, 0, self.x, self.y, 0, true) < self.range * 1.5) {
|
||||
@@ -191,7 +181,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
mp.game.graphics.drawLine(bottom_left.x, bottom_left.y, i, top_left.x, top_left.y, i, 255, 0, 0, 255);
|
||||
}
|
||||
} else {
|
||||
|
||||
/*
|
||||
let a = 0;
|
||||
for (var i = z; i < z + 1; i += 0.001) {
|
||||
@@ -202,10 +191,8 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
a += 0.001
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (self.isInsideArea()) {
|
||||
mp.game.graphics.drawText(self.name, [self.x, self.y, mp.players.local.position.z + 20], {
|
||||
@@ -215,7 +202,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
outline: true,
|
||||
centre: true
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,11 +219,9 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
startGangWar() {
|
||||
startGangWar() {
|
||||
var self = this;
|
||||
if (self._status == "normal") {
|
||||
let dist = mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, 0, self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z, false);
|
||||
@@ -263,7 +247,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
if (status == "normal") {
|
||||
self._status = "normal";
|
||||
//self.blip.setFlashes(false);
|
||||
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
|
||||
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
|
||||
return;
|
||||
}
|
||||
if (status == "conquered") {
|
||||
@@ -287,7 +271,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
self.attackBlip = mp.game.ui.addBlipForCoord(self.x, self.y, 0);
|
||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 378);
|
||||
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.attackBlip, false);
|
||||
|
||||
} else if (!bool) {
|
||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 5);
|
||||
}
|
||||
@@ -310,20 +293,18 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
self.setLeaderColShape();
|
||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.leaderBlip, 437);
|
||||
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.leaderBlip, false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setLeaderColShape() {
|
||||
var self = this;
|
||||
let newVector = new mp.Vector3(self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z - 2)
|
||||
|
||||
self.leaderColShape = mp.markers.new(1, newVector, 2, {
|
||||
color: [255, 255, 0, 150],
|
||||
visible: true,
|
||||
dimension: 0
|
||||
});
|
||||
let newVector = new mp.Vector3(self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z - 2)
|
||||
|
||||
self.leaderColShape = mp.markers.new(1, newVector, 2, {
|
||||
color: [255, 255, 0, 150],
|
||||
visible: true,
|
||||
dimension: 0
|
||||
});
|
||||
}
|
||||
|
||||
isTurfArea(shape) {
|
||||
@@ -335,7 +316,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
}
|
||||
|
||||
check() {
|
||||
var self = this
|
||||
var self = this
|
||||
if (self._entered == true) {
|
||||
if (!self.isInsideArea() || (self.isNearGround() == false)) {
|
||||
self._entered = false;
|
||||
@@ -343,7 +324,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enter() {
|
||||
var self = this;
|
||||
self._timerCheck = setInterval(function () {
|
||||
@@ -354,8 +335,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
mp.game.audio.playSoundFrontend(1, "Enter_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds", true);
|
||||
mp.game.graphics.stopScreenEffect("MinigameTransitionIn");
|
||||
mp.game.graphics.startScreenEffect("MinigameTransitionOut", 500, false);
|
||||
|
||||
}
|
||||
}
|
||||
mp.events.callRemote("Gangarea:Enter", JSON.stringify(self.id));
|
||||
}
|
||||
} else if (self._entered == true) {
|
||||
@@ -364,7 +344,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
if (self._status === "attack") {
|
||||
mp.game.audio.playSoundFrontend(1, "Exit_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds", true);
|
||||
mp.game.graphics.startScreenEffect("MinigameTransitionIn", 500, false);
|
||||
}
|
||||
}
|
||||
mp.events.callRemote("Gangarea:Leave", JSON.stringify(self.id));
|
||||
}
|
||||
}
|
||||
@@ -374,7 +354,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
leave() {
|
||||
var self = this;
|
||||
clearInterval(self._timerCheck);
|
||||
|
||||
|
||||
self.check();
|
||||
}
|
||||
isNearGround() {
|
||||
@@ -475,7 +455,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
|
||||
while (mp.game.invoke(Natives.DOES_BLIP_EXIST, last_blip)) {
|
||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, last_blip, -1);
|
||||
mp.game.ui.removeBlip(last_blip);
|
||||
mp.game.ui.removeBlip(last_blip);
|
||||
last_blip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 5);
|
||||
x++;
|
||||
}
|
||||
@@ -499,7 +479,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
mp.gui.chat.push("DEBUG: Attack blips not removed: " + y);
|
||||
mp.gui.chat.push("DEBUG: LeaderBlips blips not removed: " + z);
|
||||
}
|
||||
|
||||
|
||||
mp.events.add('GangAreas:Create', (turfsJSON) => {
|
||||
var turfs = JSON.parse(turfsJSON);
|
||||
if (gangturfs.length > 0) {
|
||||
@@ -512,9 +492,9 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
turf.leaderColShape = null;
|
||||
}
|
||||
if (turf._marker)
|
||||
if (turf.blip != null) {
|
||||
mp.game.ui.removeBlip(turf.blip);
|
||||
}
|
||||
if (turf.blip != null) {
|
||||
mp.game.ui.removeBlip(turf.blip);
|
||||
}
|
||||
if (turf.leaderBlip != null) {
|
||||
mp.game.ui.removeBlip(turf.leaderBlip);
|
||||
}
|
||||
@@ -525,7 +505,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
}
|
||||
clearBlips();
|
||||
if (turfs.length > 0) {
|
||||
|
||||
gangturfs = [];
|
||||
turfs.forEach(function (turf) {
|
||||
if (turf.Id != undefined) {
|
||||
@@ -543,9 +522,8 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
mp.events.add('ADMIN:SetTurf', (name) => {
|
||||
gangturfs[gangturfs.length - 1].edit = false;
|
||||
if (gangturfs[gangturfs.length - 1].id == -1) {
|
||||
|
||||
mp.events.callRemote("SERVER:SetTurf", JSON.stringify(gangturfs[gangturfs.length - 1].x), JSON.stringify(gangturfs[gangturfs.length - 1].y), JSON.stringify(gangturfs[gangturfs.length - 1].rotation), JSON.stringify(gangturfs[gangturfs.length - 1].range), name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('ADMIN:DeleteTurf', () => {
|
||||
@@ -581,13 +559,13 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
|
||||
mp.events.add('CLIENT:Turf_LoadLeaderBlip', () => {
|
||||
gangturfs.forEach(function (turf) {
|
||||
turf.setLeaderBlip(false);
|
||||
turf.setLeaderBlip(false);
|
||||
});
|
||||
});
|
||||
|
||||
mp.events.add('ADMIN:Turf_CreateLeaderBlip', () => {
|
||||
gangturfs.forEach(function (turf) {
|
||||
if (turf._entered == true) {
|
||||
if (turf._entered == true) {
|
||||
turf.setLeaderBlip(true);
|
||||
}
|
||||
});
|
||||
@@ -596,7 +574,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
|
||||
mp.events.add('CLIENT:StartGangwar', () => {
|
||||
gangturfs.forEach(function (turf) {
|
||||
if (turf._entered == true) {
|
||||
turf.startGangWar();
|
||||
turf.startGangWar();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,5 +21,6 @@ namespace ReallifeGamemode.Database.Entities.Saves
|
||||
public float Heading { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public int Type { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,6 +775,8 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
|
||||
b.Property<float>("PositionZ");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Peds");
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
class AirplaneDealerBusiness : CarDealerBusinessBase
|
||||
internal class AirplaneDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
|
||||
public override int Id => 7;
|
||||
|
||||
public override string Name => "Flugzeug Shop";
|
||||
@@ -22,7 +18,6 @@ namespace ReallifeGamemode.Server.Business
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string BankAccountName => Name;
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
class BeachDealerBusiness : CarDealerBusinessBase
|
||||
internal class BeachDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
|
||||
public override int Id => 9;
|
||||
|
||||
public override string Name => "Beach Shop";
|
||||
@@ -22,7 +18,6 @@ namespace ReallifeGamemode.Server.Business
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public class BikeDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
public override int Id => 8;
|
||||
|
||||
public override string Name => "Motorrad Shop";
|
||||
|
||||
public override Vector3 Position => new Vector3(1180.997, -394.9542, 68.01635);
|
||||
|
||||
public override Vector3 CarSpawnPositon => new Vector3(1148.25, -369.0642, 67.06199);
|
||||
|
||||
public override float CarSpawnHeading => 356.6f;
|
||||
|
||||
public override int? BlipSprite => 226;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override int Id => 8;
|
||||
|
||||
public override string Name => "Motorrad Shop";
|
||||
|
||||
public override Vector3 Position => new Vector3(1180.997, -394.9542, 68.01635);
|
||||
|
||||
public override Vector3 CarSpawnPositon => new Vector3(1148.25, -369.0642, 67.06199);
|
||||
|
||||
public override float CarSpawnHeading => 356.6f;
|
||||
|
||||
public override int? BlipSprite => 226;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public class BoatDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
public override int Id => 5;
|
||||
|
||||
public override string Name => "Boot Shop";
|
||||
|
||||
public override Vector3 Position => new Vector3(-712.2401, -1298.818, 5.101922);
|
||||
|
||||
public override Vector3 CarSpawnPositon => new Vector3(-792.5602, -1433.158, 1.333062);
|
||||
|
||||
public override float CarSpawnHeading => 356.6f;
|
||||
|
||||
public override int? BlipSprite => 410;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override int Id => 5;
|
||||
|
||||
public override string Name => "Boot Shop";
|
||||
|
||||
public override Vector3 Position => new Vector3(-712.2401, -1298.818, 5.101922);
|
||||
|
||||
public override Vector3 CarSpawnPositon => new Vector3(-792.5602, -1433.158, 1.333062);
|
||||
|
||||
public override float CarSpawnHeading => 356.6f;
|
||||
|
||||
public override int? BlipSprite => 410;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,198 +1,197 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public abstract class BusinessBase : BankAccountHolder<BusinessBankAccount>, IBankAccountOwner
|
||||
{
|
||||
private TextLabel _informationLabel;
|
||||
private ColShape _colShape;
|
||||
private Blip _blip;
|
||||
private Marker _marker;
|
||||
|
||||
public virtual int? BlipSprite { get; } = null;
|
||||
|
||||
public abstract int Id { get; }
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract Vector3 Position { get; }
|
||||
|
||||
public override BusinessBankAccount BankAccount
|
||||
{
|
||||
get
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
private TextLabel _informationLabel;
|
||||
private ColShape _colShape;
|
||||
private Blip _blip;
|
||||
private Marker _marker;
|
||||
|
||||
public virtual int? BlipSprite { get; } = null;
|
||||
|
||||
public abstract int Id { get; }
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract Vector3 Position { get; }
|
||||
|
||||
public override BusinessBankAccount BankAccount
|
||||
{
|
||||
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||
get
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override int? BankAccountId
|
||||
{
|
||||
get
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
public override int? BankAccountId
|
||||
{
|
||||
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).Select(b => b.Id).FirstOrDefault();
|
||||
get
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).Select(b => b.Id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
public override string BankAccountName => Name;
|
||||
|
||||
public override string BankAccountName => Name;
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||
_marker = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255));
|
||||
|
||||
if (BlipSprite != null)
|
||||
{
|
||||
_blip = NAPI.Blip.CreateBlip(BlipSprite.Value, Position, 1f, 4, Name, shortRange: true);
|
||||
}
|
||||
|
||||
_colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f);
|
||||
_colShape.OnEntityEnterColShape += EntityEnterBusinessColShape;
|
||||
_colShape.OnEntityExitColShape += EntityExitBusinessColShape;
|
||||
|
||||
if (GetBankAccount() == null)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
public void Setup()
|
||||
{
|
||||
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||
_marker = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255));
|
||||
|
||||
dbContext.BusinessBankAccounts.Add(new BusinessBankAccount()
|
||||
{
|
||||
BusinessId = Id,
|
||||
Balance = 0
|
||||
});
|
||||
dbContext.SaveChanges();
|
||||
if (BlipSprite != null)
|
||||
{
|
||||
_blip = NAPI.Blip.CreateBlip(BlipSprite.Value, Position, 1f, 4, Name, shortRange: true);
|
||||
}
|
||||
|
||||
_colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f);
|
||||
_colShape.OnEntityEnterColShape += EntityEnterBusinessColShape;
|
||||
_colShape.OnEntityExitColShape += EntityExitBusinessColShape;
|
||||
|
||||
if (GetBankAccount() == null)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
dbContext.BusinessBankAccounts.Add(new BusinessBankAccount()
|
||||
{
|
||||
BusinessId = Id,
|
||||
Balance = 0
|
||||
});
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
BusinessData data = GetData();
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
data = new BusinessData()
|
||||
{
|
||||
BusinessId = this.Id,
|
||||
Price = -1
|
||||
};
|
||||
|
||||
dbContext.BusinessData.Add(data);
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BusinessData data = GetData();
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
private void EntityExitBusinessColShape(ColShape colShape, Player client)
|
||||
{
|
||||
data = new BusinessData()
|
||||
{
|
||||
BusinessId = this.Id,
|
||||
Price = -1
|
||||
};
|
||||
|
||||
dbContext.BusinessData.Add(data);
|
||||
|
||||
dbContext.SaveChanges();
|
||||
client.TriggerEvent("SERVER:Business_RemoveHelp", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EntityExitBusinessColShape(ColShape colShape, Player client)
|
||||
{
|
||||
client.TriggerEvent("SERVER:Business_RemoveHelp", true);
|
||||
}
|
||||
|
||||
public BusinessData GetData(DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
public BusinessData GetData(DatabaseContext dbContext = null)
|
||||
{
|
||||
return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
private void EntityEnterBusinessColShape(ColShape colShape, Player client)
|
||||
{
|
||||
if (client.IsInVehicle || !client.IsLoggedIn()) return;
|
||||
|
||||
SendBusinessDataToPlayer(client);
|
||||
client.TriggerEvent("SERVER:Business_ShowMenuHelp");
|
||||
}
|
||||
|
||||
public void SendBusinessDataToPlayer(Player player)
|
||||
{
|
||||
User owner = GetOwner();
|
||||
|
||||
int state = -1; // Keine Beziehung
|
||||
|
||||
if (owner == null) // Kein Besitzer
|
||||
{
|
||||
state = 0;
|
||||
}
|
||||
else if (owner.Id == player.GetUser()?.Id) // Besitzer
|
||||
{
|
||||
state = 1;
|
||||
}
|
||||
|
||||
var business = new
|
||||
{
|
||||
this.Name,
|
||||
Price = this.GetData().Price.ToMoneyString(),
|
||||
Balance = this.GetBankAccount().Balance.ToMoneyString()
|
||||
};
|
||||
|
||||
player.TriggerEvent("SERVER:Business_SetData", JsonConvert.SerializeObject(business), state);
|
||||
}
|
||||
|
||||
public void Update(int? money = null)
|
||||
{
|
||||
if (money == null) money = GetBankAccount()?.Balance ?? 0;
|
||||
User owner = GetOwner();
|
||||
string infoText = Name;
|
||||
if (owner == null) infoText += "\n~g~Zum Verkauf\n~s~Preis: ~y~" + this.GetData().Price.ToMoneyString();
|
||||
else infoText += $"\nBesitzer: ~g~{owner.Name}\n~s~Kasse: ~y~{money.ToMoneyString()}";
|
||||
_informationLabel.Text = infoText;
|
||||
}
|
||||
|
||||
public User GetOwner(DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
private void EntityEnterBusinessColShape(ColShape colShape, Player client)
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
if (client.IsInVehicle || !client.IsLoggedIn()) return;
|
||||
|
||||
public abstract void Load();
|
||||
}
|
||||
SendBusinessDataToPlayer(client);
|
||||
client.TriggerEvent("SERVER:Business_ShowMenuHelp");
|
||||
}
|
||||
|
||||
public void SendBusinessDataToPlayer(Player player)
|
||||
{
|
||||
User owner = GetOwner();
|
||||
|
||||
int state = -1; // Keine Beziehung
|
||||
|
||||
if (owner == null) // Kein Besitzer
|
||||
{
|
||||
state = 0;
|
||||
}
|
||||
else if (owner.Id == player.GetUser()?.Id) // Besitzer
|
||||
{
|
||||
state = 1;
|
||||
}
|
||||
|
||||
var business = new
|
||||
{
|
||||
this.Name,
|
||||
Price = this.GetData().Price.ToMoneyString(),
|
||||
Balance = this.GetBankAccount().Balance.ToMoneyString()
|
||||
};
|
||||
|
||||
player.TriggerEvent("SERVER:Business_SetData", JsonConvert.SerializeObject(business), state);
|
||||
}
|
||||
|
||||
public void Update(int? money = null)
|
||||
{
|
||||
if (money == null) money = GetBankAccount()?.Balance ?? 0;
|
||||
User owner = GetOwner();
|
||||
string infoText = Name;
|
||||
if (owner == null) infoText += "\n~g~Zum Verkauf\n~s~Preis: ~y~" + this.GetData().Price.ToMoneyString();
|
||||
else infoText += $"\nBesitzer: ~g~{owner.Name}\n~s~Kasse: ~y~{money.ToMoneyString()}";
|
||||
_informationLabel.Text = infoText;
|
||||
}
|
||||
|
||||
public User GetOwner(DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Load();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public abstract class CarDealerBusinessBase : BusinessBase
|
||||
{
|
||||
public abstract Vector3 CarSpawnPositon { get; }
|
||||
public abstract float CarSpawnHeading { get; }
|
||||
{
|
||||
public abstract Vector3 CarSpawnPositon { get; }
|
||||
public abstract float CarSpawnHeading { get; }
|
||||
|
||||
public override int? BlipSprite => 225;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
@@ -21,7 +18,6 @@ namespace ReallifeGamemode.Server.Business
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
class LastTrainDealerBusiness : CarDealerBusinessBase
|
||||
internal class LastTrainDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
|
||||
public override int Id => 10;
|
||||
|
||||
public override string Name => "Last Train Carshop";
|
||||
@@ -22,7 +18,6 @@ namespace ReallifeGamemode.Server.Business
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
internal class PremiumDeluxeMotorsportCarDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
public override Vector3 CarSpawnPositon => new Vector3(-59, -1108.1, 26.5);
|
||||
|
||||
public override float CarSpawnHeading => 90;
|
||||
|
||||
public override int Id => 4;
|
||||
|
||||
public override string Name => "Premium Deluxe Motorsport";
|
||||
|
||||
public override Vector3 Position => new Vector3(-31.56, -1113.5, 26.42);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override Vector3 CarSpawnPositon => new Vector3(-59, -1108.1, 26.5);
|
||||
|
||||
public override float CarSpawnHeading => 90;
|
||||
|
||||
public override int Id => 4;
|
||||
|
||||
public override string Name => "Premium Deluxe Motorsport";
|
||||
|
||||
public override Vector3 Position => new Vector3(-31.56, -1113.5, 26.42);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
class SUVDealerBusiness : CarDealerBusinessBase
|
||||
internal class SUVDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
|
||||
public override int Id => 11;
|
||||
|
||||
public override string Name => "SUV Carshop";
|
||||
@@ -22,7 +18,6 @@ namespace ReallifeGamemode.Server.Business
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public class ShopBusiness : BusinessBase
|
||||
{
|
||||
public override int Id => 2;
|
||||
|
||||
public override string Name => "24/7 Business";
|
||||
|
||||
public override Vector3 Position => new Vector3(-443, 1134, 326);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override int Id => 2;
|
||||
|
||||
public override string Name => "24/7 Business";
|
||||
|
||||
public override Vector3 Position => new Vector3(-443, 1134, 326);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public class TelefonBusiness : BusinessBase
|
||||
{
|
||||
public override int Id => 1;
|
||||
|
||||
public override string Name => "Telefon Business";
|
||||
|
||||
public override Vector3 Position => new Vector3(-423, 1130, 326);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override int Id => 1;
|
||||
|
||||
public override string Name => "Telefon Business";
|
||||
|
||||
public override Vector3 Position => new Vector3(-423, 1130, 326);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public class VapidCarDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
public override int Id => 3;
|
||||
|
||||
public override string Name => "Vapid Autohaus";
|
||||
|
||||
public override Vector3 Position => new Vector3(-177, -1156, 23);
|
||||
|
||||
public override Vector3 CarSpawnPositon => new Vector3(-222, -1162, 22.5);
|
||||
|
||||
public override float CarSpawnHeading => 356.6f;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override int Id => 3;
|
||||
|
||||
public override string Name => "Vapid Autohaus";
|
||||
|
||||
public override Vector3 Position => new Vector3(-177, -1156, 23);
|
||||
|
||||
public override Vector3 CarSpawnPositon => new Vector3(-222, -1162, 22.5);
|
||||
|
||||
public override float CarSpawnHeading => 356.6f;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Classes
|
||||
namespace ReallifeGamemode.Server.Classes
|
||||
{
|
||||
public class TempBlip
|
||||
{
|
||||
public byte Color { get; set; }
|
||||
public string Name { get; set; }
|
||||
public byte Transparency { get; set; }
|
||||
public bool ShortRange { get; set; }
|
||||
public uint Sprite { get; set; }
|
||||
public float Scale { get; set; }
|
||||
}
|
||||
{
|
||||
public byte Color { get; set; }
|
||||
public string Name { get; set; }
|
||||
public byte Transparency { get; set; }
|
||||
public bool ShortRange { get; set; }
|
||||
public uint Sprite { get; set; }
|
||||
public float Scale { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Business;
|
||||
using System.Text.RegularExpressions;
|
||||
using ReallifeGamemode.Server.Classes;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Job;
|
||||
using ReallifeGamemode.Server.Finance;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Services;
|
||||
using ReallifeGamemode.Server.Business;
|
||||
using ReallifeGamemode.Server.Classes;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Finance;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Job;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
using ReallifeGamemode.Services;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Admin Commands (Admin.cs)
|
||||
@@ -32,8 +31,8 @@ namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
public class AdminCommands : Script
|
||||
{
|
||||
|
||||
#region Todo
|
||||
|
||||
[Command("eat", "~m~Benutzung: ~s~/eat [Item]")]
|
||||
public void CmdAdminEat(Player player, string item)
|
||||
{
|
||||
@@ -126,8 +125,10 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.SendMessage(player, msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Todo
|
||||
|
||||
#region ahelp
|
||||
|
||||
[Command("ahelp", "~m~Benutzung: ~s~/ahelp")]
|
||||
public void CmdAdminHelp(Player player)
|
||||
{
|
||||
@@ -143,35 +144,39 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case AdminLevel.MAPPING:
|
||||
ChatService.SendMessage(player, "~b~ " + "/team, /tc, /position");
|
||||
break;
|
||||
|
||||
case AdminLevel.ENTWICKLUNG:
|
||||
ChatService.SendMessage(player, "~b~ " + "/team, /tc, /position");
|
||||
break;
|
||||
|
||||
case AdminLevel.SUPPORTER:
|
||||
ChatService.SendMessage(player, "~b~ " + "/tsupport, /showtickets, /rc, /rc quit, /o, /pm, /dimension, /to, /gh, /clearchat, /skick");
|
||||
break;
|
||||
|
||||
case AdminLevel.ADMIN:
|
||||
ChatService.SendMessage(player, "~b~ " + "/a, /countdown, /freeze, /unfreeze, /mark, /gotmark, /gotox, /up, /setdimension, /spec, /warn, /ip, /kick, /ban /unban, /slap, /takeweapon, /tov, /ghv, /factionlist, /businesslist, /joblist");
|
||||
break;
|
||||
|
||||
case AdminLevel.ADMIN2:
|
||||
ChatService.SendMessage(player, "~b~ " + "/sethp, /setarmor, /arevive, /aunjail, /aclear, /clothes, /props");
|
||||
break;
|
||||
|
||||
case AdminLevel.ADMIN3:
|
||||
ChatService.SendMessage(player, "~b~ " + "/adice, /settime, /setweather, /rsetarmor, /rgiveweapon, /giveweapon, /veh, /fv, /vfix, /vdestroy, /vlivery, /vcolor, /vehsmoke, /aneon, /mod, /showtuningmenu, /rvdestroy, /vsethp");
|
||||
break;
|
||||
|
||||
case AdminLevel.HEADADMIN:
|
||||
ChatService.SendMessage(player, "~b~ " + "/aspeed, /set, /setmoney, /givemoney, /sethandmoney, /givehandmoney, /paydaydrop, /setwage, /freekh, /ainvite, /makeleader, /managefactionranks, /setweaponrack, /rmweaponrack, /setweaponrank, /giveitem, /inventory, /save, /remove, /house, /setbusinessbankbalance, /reloaddors, /interior, /editmode, /setbliptemplate, /ipl, /load, /quicksavemode, /createturf, /setturf, /cancleturf, /reloadturfs, /deleteturfs, /setturfpoint");
|
||||
break;
|
||||
|
||||
case AdminLevel.PROJEKTLEITUNG:
|
||||
ChatService.SendMessage(player, "~b~ " + "/makeadmin, /whitelist, /blind");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion ahelp
|
||||
|
||||
#region Mapping / Entwicklung
|
||||
|
||||
@@ -219,9 +224,10 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.SendMessage(player, "Position: X Y Z: " + player.Position + " Richtung: " + player.Heading);
|
||||
}
|
||||
|
||||
#endregion Mapping / Entwicklung
|
||||
|
||||
#endregion
|
||||
#region Support
|
||||
|
||||
[Command("tsupport", "~m~Benutzung: ~s~/tsupport", Alias = "ts")]
|
||||
public void tsup(Player player)
|
||||
{
|
||||
@@ -242,8 +248,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
GlobalHelper.tsupAdmins.Remove(player);
|
||||
ChatService.SendMessage(player, "!{#ee4d2e}** " + "Du befindest dich nicht mehr im T-Support");
|
||||
|
||||
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User targetUser = player.GetUser(dbContext);
|
||||
@@ -252,12 +256,15 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case null:
|
||||
player.SetSharedData("blipColor", 0);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
player.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
player.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
player.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
@@ -281,8 +288,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.Broadcast("~g~[SUPPORT] " + player.Name + " hat sich zum Support angemeldet");
|
||||
|
||||
player.TriggerEvent("toggleADutyMode", true);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -440,7 +445,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Support
|
||||
|
||||
#region ALevel1
|
||||
|
||||
@@ -485,9 +490,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.BroadcastAdmin("!{#1db992}** AC " + player.Name + ":~w~ " + message, AdminLevel.ADMIN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Command("gotolist", "~m~Benutzung: ~s~/gotolist")] //TODO Als Browser anzeigeN??
|
||||
public void CmdAdminGotoList(Player player)
|
||||
{
|
||||
@@ -815,7 +817,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.Entity.SetEntityVelocity(player.Vehicle, new Vector3());
|
||||
}
|
||||
else player.Position = new Vector3(p.X, p.Y, p.Z);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,7 +832,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
else player.Position = new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
[Command("slap", "~m~Benutzung: ~s~/slap [Spieler] (Höhe)")]
|
||||
public void CmdAdminSlap(Player player, string name, int wert = 5)
|
||||
{
|
||||
@@ -963,8 +963,10 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion ALevel1
|
||||
|
||||
#region ALevel2
|
||||
|
||||
[Command("sethp", "~m~Benutzung: ~s~/sethp [Spieler] (Hp)")]
|
||||
public void CmdAdminSetHp(Player player, string name, int hp = 100)
|
||||
{
|
||||
@@ -1130,7 +1132,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("aclear", "~m~Benutzung: ~s~/aclear [Spieler] [Grund]", GreedyArg = true)]
|
||||
public void CmdFactionClear(Player player, string nameOrId, string reason)
|
||||
{
|
||||
|
||||
User user = player.GetUser();
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN2) ?? true)
|
||||
{
|
||||
@@ -1160,12 +1161,15 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case null:
|
||||
target.SetSharedData("blipColor", 0);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
target.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
target.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
target.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
@@ -1176,7 +1180,9 @@ namespace ReallifeGamemode.Server.Commands
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion ALevel2
|
||||
|
||||
#region ALevel3
|
||||
|
||||
[Command("adice", "~m~Benutzung: ~s~/adice [Zahl]")]
|
||||
@@ -1537,7 +1543,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
TimeManager.PauseTimeManager();
|
||||
NAPI.World.SetTime(hour, min, sec);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
[Command("setweather", "~m~Benutzung: ~s~/setweather [Wetter]")]
|
||||
@@ -1600,7 +1605,8 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion ALevel3
|
||||
|
||||
#region ALevel1337
|
||||
[Command("wepmod", "~m~Benutzung: ~s~/wepmod [Variable]")]
|
||||
public void CmdWeaponModifier(Player player, float modifier)
|
||||
@@ -1618,7 +1624,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
public void CmdAdminGotocp(Player admin)
|
||||
{
|
||||
admin.TriggerEvent("getCP");
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("sendCP")]
|
||||
@@ -1725,7 +1730,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
else
|
||||
{
|
||||
UserItem item = new UserItem() { ItemId = itemId, UserId = target.GetUser().Id, Amount = amount };
|
||||
InventoryManager.AddItemToInventory(target, item);
|
||||
InventoryManager.AddItemToInventory(target, item.ItemId, item.Amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1771,7 +1776,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
player.SendNotification("Edit-Mode ~r~deaktiviert");
|
||||
player.TriggerEvent("toggleEditMode", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Command("setbliptemplate", "~m~Benutzung: ~s~/setbliptemplate [byte COLOR] [byte ALPHA] [bool SHORTRANGE] [uint SPRITE] [float SCALE] [string NAME]", GreedyArg = true)]
|
||||
@@ -1911,16 +1915,18 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case null:
|
||||
target.SetSharedData("blipColor", 0);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
target.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
target.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
target.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
@@ -1969,16 +1975,18 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case null:
|
||||
target.SetSharedData("blipColor", 0);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
target.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
target.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
target.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
@@ -1999,6 +2007,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case "blip":
|
||||
player.TriggerEvent("saveBlip");
|
||||
break;
|
||||
|
||||
case "goto":
|
||||
if (option1 == null)
|
||||
{
|
||||
@@ -2020,10 +2029,10 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.SendMessage(player, "Einen Goto-Punkt mit dieser Bezeichnung gibt es schon!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "vehicle":
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
@@ -2036,6 +2045,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
else ChatService.SendMessage(player, "~m~Du sitzt in keinem Fahrzeug!");
|
||||
break;
|
||||
|
||||
case "fvehicle":
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
@@ -2074,6 +2084,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
else ChatService.SendMessage(player, "~m~Du sitzt in keinem Fahrzeug!");
|
||||
break;
|
||||
|
||||
case "jvehicle":
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
@@ -2262,6 +2273,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
|
||||
#region loadCommand
|
||||
|
||||
[Command("load", "~m~Benutzung: ~s~/load [Typ = OnlineBunkers, ArcadiusBusinessCentre, MazeBankBuilding, LomBank, MazeBankWest, ClubWareHouse, SpecialLocations, GRHYacht, DHYacht, PYacht, AircraftCarrier, BridgeTC, BridgeTN, NorthYankton, ONeilsFarmB, ONeilsFarm, Morgue")]
|
||||
public void CmdAdminloadlocation(Player player, string typ)
|
||||
{
|
||||
@@ -2288,6 +2300,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("gr_case4_bunkerclosed");
|
||||
ChatService.SendMessage(player, "~y~ Online Bunkers~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "ArcadiusBusinessCentre":
|
||||
NAPI.World.RequestIpl("ex_dt1_02_office_02b");
|
||||
NAPI.World.RequestIpl("ex_dt1_02_office_02c");
|
||||
@@ -2304,6 +2317,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("imp_dt1_02_modgarage");
|
||||
ChatService.SendMessage(player, "~y~ Arcadius Business Centre~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "MazeBankBuilding":
|
||||
NAPI.World.RequestIpl("ex_dt1_11_office_02b");
|
||||
NAPI.World.RequestIpl("ex_dt1_11_office_02c");
|
||||
@@ -2320,6 +2334,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("imp_dt1_11_modgarage");
|
||||
ChatService.SendMessage(player, "~y~ Maze Bank Building~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "LomBank":
|
||||
NAPI.World.RequestIpl("ex_sm_13_office_02b");
|
||||
NAPI.World.RequestIpl("ex_sm_13_office_02c");
|
||||
@@ -2336,6 +2351,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("imp_sm_13_modgarage");
|
||||
ChatService.SendMessage(player, "~y~Lom Bank~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "MazeBankWest":
|
||||
NAPI.World.RequestIpl("ex_sm_15_office_02b");
|
||||
NAPI.World.RequestIpl("ex_sm_15_office_02c");
|
||||
@@ -2352,6 +2368,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("imp_sm_15_modgarage");
|
||||
ChatService.SendMessage(player, "~y~Maze Bank West~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "ClubWareHouse":
|
||||
NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_0_biker_dlc_int_01_milo");
|
||||
NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_1_biker_dlc_int_02_milo");
|
||||
@@ -2367,6 +2384,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("bkr_bi_hw1_13_int");
|
||||
ChatService.SendMessage(player, "~y~Clubs & Warehouses~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "SpecialLocations":
|
||||
NAPI.World.RequestIpl("cargoship");
|
||||
NAPI.World.RequestIpl("sunkcargoship");
|
||||
@@ -2383,6 +2401,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("FIBlobby");
|
||||
ChatService.SendMessage(player, "~y~Special Locations~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "GRHYacht":
|
||||
NAPI.World.RequestIpl("gr_heist_yacht2");
|
||||
NAPI.World.RequestIpl("gr_heist_yacht2_bar");
|
||||
@@ -2392,6 +2411,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("gr_heist_yacht2_lounge");
|
||||
ChatService.SendMessage(player, "~y~Gunrunning heist Yacht~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "DHYacht":
|
||||
NAPI.World.RequestIpl("hei_yacht_heist");
|
||||
NAPI.World.RequestIpl("hei_yacht_heist_enginrm");
|
||||
@@ -2403,11 +2423,13 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("hei_yacht_heist_LODLights");
|
||||
ChatService.SendMessage(player, "~y~Dignity heist Yacht~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "PYacht":
|
||||
NAPI.World.RequestIpl("smboat");
|
||||
NAPI.World.RequestIpl("smboat_lod");
|
||||
ChatService.SendMessage(player, "~y~Party Yacht~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "AircraftCarrier":
|
||||
NAPI.World.RequestIpl("hei_carrier");
|
||||
NAPI.World.RequestIpl("hei_carrier_DistantLights");
|
||||
@@ -2420,16 +2442,19 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("hei_carrier_LODLights");
|
||||
ChatService.SendMessage(player, "~y~Aircraft Carrier~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "BridgeTC":
|
||||
NAPI.World.RequestIpl("canyonriver01_traincrash");
|
||||
NAPI.World.RequestIpl("canyonriver01_traincrash");
|
||||
ChatService.SendMessage(player, "~y~Bridge Train Crash~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "BridgeTN":
|
||||
NAPI.World.RequestIpl("canyonriver01");
|
||||
NAPI.World.RequestIpl("railing_start");
|
||||
ChatService.SendMessage(player, "~y~Bridge Train Normal~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "NorthYankton":
|
||||
NAPI.World.RequestIpl("prologue01");
|
||||
NAPI.World.RequestIpl("prologue01c");
|
||||
@@ -2464,6 +2489,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("prologuerdb");
|
||||
ChatService.SendMessage(player, "~y~North Yankton~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "ONeilsFarmB":
|
||||
NAPI.World.RequestIpl("farmint");
|
||||
NAPI.World.RequestIpl("farm_burnt");
|
||||
@@ -2472,21 +2498,23 @@ namespace ReallifeGamemode.Server.Commands
|
||||
NAPI.World.RequestIpl("des_farmhs_end_occl");
|
||||
ChatService.SendMessage(player, "~y~ONeils Farm Burnt~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "ONeilsFarm":
|
||||
NAPI.World.RequestIpl("farm");
|
||||
NAPI.World.RequestIpl("farm_props");
|
||||
NAPI.World.RequestIpl("farm_int");
|
||||
ChatService.SendMessage(player, "~y~ONeils Farm~s~ erfolgreich geladen!");
|
||||
break;
|
||||
|
||||
case "Morgue":
|
||||
NAPI.World.RequestIpl("coronertrash");
|
||||
NAPI.World.RequestIpl("Coroner_Int_On");
|
||||
ChatService.SendMessage(player, "~y~Morgue~s~ erfolgreich geladen!");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion loadCommand
|
||||
|
||||
//
|
||||
[Command("managefactionranks", "~m~Benutzung: ~s~/managefactionranks [Fraktions-ID]", Alias = "mfr")]
|
||||
@@ -2713,7 +2741,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
|
||||
[Command("reloaddoors", "~m~Benutzung: ~s~/reloaddoors")]
|
||||
@@ -2828,7 +2855,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
dbContext.SaveChanges();
|
||||
ChatService.SendMessage(player, "Waffeneintrag bearbeitet für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
FactionWeapon fw2 = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
|
||||
@@ -2854,7 +2880,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Command("rmweaponrack", "~m~Benutzung: ~s~/rmweaponrack [Fraktion ID] [Waffen Model]")]
|
||||
public void CmdAdminRmWeaponrack(Player player, int factionID, string weaponModel)
|
||||
{
|
||||
@@ -3016,9 +3041,11 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
player.TriggerEvent("ADMIN:Turf_CreateLeaderBlip");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion ALevel1337
|
||||
|
||||
#region ALevel1338
|
||||
|
||||
[Command("whitelist", "~m~Benutzung: ~s~/whitelist [Add / Remove] [Socialclub Name]")]
|
||||
public void CmdAdminWhitelist(Player player, string option, string scName)
|
||||
{
|
||||
@@ -3123,6 +3150,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.SendMessage(target, "~b~[ADMIN]~s~ Du wurdest durch ~y~" + player.Name + " ~s~auf Adminlevel ~y~" + target.GetUser().AdminLevel.GetName() + " ~y~(" + rank + ") ~s~gesetzt.");
|
||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast ~y~" + target.Name + " ~s~auf Adminlevel ~y~" + target.GetUser().AdminLevel.GetName() + " ~y~(" + rank + ") ~s~gesetzt.");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion ALevel1338
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
@@ -6,11 +9,7 @@ using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
using ReallifeGamemode.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Faction Commands (Faction.cs)
|
||||
@@ -20,7 +19,7 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
class FactionCommands : Script
|
||||
internal class FactionCommands : Script
|
||||
{
|
||||
#region Chat Commands
|
||||
|
||||
@@ -74,8 +73,11 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion Chat Commands
|
||||
|
||||
#region Leader Commands
|
||||
|
||||
[Command("giverank", "~m~Benutzung: ~s~/giverank [Name] [Rang]", GreedyArg = true)]
|
||||
public void CmdFactionGiverank(Player player, string name, string rank)
|
||||
{
|
||||
@@ -173,8 +175,8 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Leader Commands
|
||||
|
||||
#endregion
|
||||
#region Sanitäter Commands
|
||||
|
||||
[Command("revive", "~m~Benutzung: ~s~/revive")]
|
||||
@@ -267,8 +269,11 @@ namespace ReallifeGamemode.Server.Commands
|
||||
target.SendNotification("Du wurdest von ~g~" + player.Name + " ~s~geheilt.", false);
|
||||
player.SendNotification("Du hast ~g~" + target.Name + " ~s~geheilt.", false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion Sanitäter Commands
|
||||
|
||||
#region Staatsfraktionen (LSPD / FBI) Commands
|
||||
|
||||
[Command("wanted", "~m~Benutzung: ~s~/wa(nted) [Spieler] [Anzahl] [Grund]", Alias = "wa", GreedyArg = true)]
|
||||
public void CmdFactionWanted(Player player, string nameOrId, int amount, string reason)
|
||||
{
|
||||
@@ -311,7 +316,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("clear", "~m~Benutzung: ~s~/clear [Spieler] [Grund]", GreedyArg = true)]
|
||||
public void CmdFactionClear(Player player, string nameOrId, string reason)
|
||||
{
|
||||
|
||||
User user = player.GetUser();
|
||||
if (user == null || (user.FactionId != 1 && user.FactionId != 3))
|
||||
{
|
||||
@@ -348,9 +352,11 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case 8:
|
||||
target.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
target.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
target.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
@@ -362,11 +368,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
#region Global Fraktions Commands
|
||||
#endregion
|
||||
#endregion Staatsfraktionen (LSPD / FBI) Commands
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Text.RegularExpressions;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
class GroupCommands : Script
|
||||
internal class GroupCommands : Script
|
||||
{
|
||||
#region Chat Commands
|
||||
|
||||
[Command("gc", "~m~Benutzung: ~s~/gc [Nachricht]", GreedyArg = true)]
|
||||
public void CmdGroupG(Player player, string message)
|
||||
{
|
||||
@@ -26,6 +24,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
ChatService.BroadcastGroup(message, group);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion Chat Commands
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database;
|
||||
using System;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Finance;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
class UserCommands : Script
|
||||
internal class UserCommands : Script
|
||||
{
|
||||
[Command("dice", "~m~Benutzung: ~s~/dice")]
|
||||
public void CmdUserDice(Player player)
|
||||
@@ -52,7 +49,6 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("paycheck", "~m~Benutzung: ~s~/paycheck")]
|
||||
public void CmdUserPaycheck(Player client)
|
||||
{
|
||||
|
||||
User user = client.GetUser();
|
||||
if (Economy.Paychecks.ContainsKey(user.Id))
|
||||
{
|
||||
@@ -68,6 +64,5 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK] -------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.DrivingSchool
|
||||
{
|
||||
class DrivingSchool : Script
|
||||
internal class DrivingSchool : Script
|
||||
{
|
||||
private static TextLabel informationLabel;
|
||||
private static Marker marker;
|
||||
@@ -40,6 +36,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
{
|
||||
new Vector3(-813.57, -1290.37, 4.59),
|
||||
}.AsReadOnly();
|
||||
|
||||
private readonly IReadOnlyCollection<Vector3> DrivingRoute = new List<Vector3>
|
||||
{
|
||||
//BEGIN
|
||||
@@ -80,12 +77,12 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
new Vector3(-617.66, -1259.34, 9.82),
|
||||
new Vector3(-758.35, -1285.03, 3.48),
|
||||
}.AsReadOnly();
|
||||
|
||||
private readonly IReadOnlyCollection<Vector3> StopCar = new List<Vector3>
|
||||
{
|
||||
new Vector3(-788.66, -1278.75, 4),
|
||||
}.AsReadOnly();
|
||||
|
||||
|
||||
public static void Setup()
|
||||
{
|
||||
informationLabel = NAPI.TextLabel.CreateTextLabel("Fahrschule\n~y~Auto ~s~- $~g~2500\n~y~Motorrad ~s~- $~g~3500", new Vector3(-813.17, -1354.5, 5.14), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||
@@ -181,7 +178,6 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
user.Position = new Vector3(-813.17, -1354.5, 4.14);
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("drivingSchoolEvent")]
|
||||
public void DrivingSchoolEvent(Player user, int checkpoint)
|
||||
{
|
||||
@@ -189,7 +185,6 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
{
|
||||
user.TriggerEvent("renderTextOnScreen", "Sollten Sie aus dem Fahrzeug aussteigen fallen Sie durch.");
|
||||
}
|
||||
|
||||
else if (checkpoint == 9)
|
||||
{
|
||||
user.TriggerEvent("renderTextOnScreen", "Fahre zwischen den Laternen Slalom.");
|
||||
@@ -205,8 +200,6 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[RemoteEvent("startBikeSchool")]
|
||||
public void StartBikeSchool(Player client)
|
||||
{
|
||||
@@ -233,7 +226,6 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
client.TriggerEvent("waitPlayerEntersVehicle");
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("bikeSchoolEventEnd")]
|
||||
public void bikeSchoolEventEnd(Player user, int checkpoint)
|
||||
{
|
||||
@@ -258,7 +250,6 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
user.Position = new Vector3(-813.17, -1354.5, 4.14);
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("bikeSchoolEvent")]
|
||||
public void bikeSchoolEvent(Player user, int checkpoint)
|
||||
{
|
||||
@@ -272,6 +263,5 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
CheckPointHandle.StartCheckPointRoute(user, StopBike, 5000, 1, 7, "bikeSchoolEventEnd");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.DrivingSchool
|
||||
{
|
||||
public class Licenses
|
||||
{
|
||||
[JsonProperty("drivingLicenseCar")]
|
||||
public bool CarLicense { get; set; }
|
||||
|
||||
[JsonProperty("drivingLicenseBike")]
|
||||
public bool BikeLicense { get; set; }
|
||||
|
||||
[JsonProperty("flightLicensePlane")]
|
||||
public bool PlaneLicense { get; set; }
|
||||
|
||||
[JsonProperty("weaponLicense")]
|
||||
public bool WeaponLicense { get; set; }
|
||||
|
||||
|
||||
public Licenses(bool CarLicense, bool BikeLicense, bool PlaneLicense, bool weaponLicense)
|
||||
{
|
||||
this.CarLicense = CarLicense;
|
||||
this.BikeLicense = BikeLicense;
|
||||
this.PlaneLicense = PlaneLicense;
|
||||
this.WeaponLicense = weaponLicense;
|
||||
}
|
||||
[JsonProperty("drivingLicenseCar")]
|
||||
public bool CarLicense { get; set; }
|
||||
|
||||
}
|
||||
[JsonProperty("drivingLicenseBike")]
|
||||
public bool BikeLicense { get; set; }
|
||||
|
||||
[JsonProperty("flightLicensePlane")]
|
||||
public bool PlaneLicense { get; set; }
|
||||
|
||||
[JsonProperty("weaponLicense")]
|
||||
public bool WeaponLicense { get; set; }
|
||||
|
||||
public Licenses(bool CarLicense, bool BikeLicense, bool PlaneLicense, bool weaponLicense)
|
||||
{
|
||||
this.CarLicense = CarLicense;
|
||||
this.BikeLicense = BikeLicense;
|
||||
this.PlaneLicense = PlaneLicense;
|
||||
this.WeaponLicense = weaponLicense;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.DrivingSchool
|
||||
{
|
||||
class PlaneSchool : Script
|
||||
internal class PlaneSchool : Script
|
||||
{
|
||||
private static TextLabel informationLabel1;
|
||||
private static Marker marker1;
|
||||
@@ -38,16 +34,13 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
new Vector3(-869.77, -1424.05, 133),
|
||||
}.AsReadOnly();
|
||||
|
||||
|
||||
private readonly IReadOnlyCollection<Vector3> planeRouteEnd = new List<Vector3>
|
||||
{
|
||||
new Vector3(-1164.29, -2351.52, 14.88),
|
||||
}.AsReadOnly();
|
||||
|
||||
|
||||
public static void Setup()
|
||||
{
|
||||
|
||||
informationLabel1 = NAPI.TextLabel.CreateTextLabel("Flugschule\n~y~Flugschein ~s~- $~g~5000", new Vector3(-1083.96, -2476.96, 14.07), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||
marker1 = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, new Vector3(-1083.96, -2476.96, 13.07), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255));
|
||||
|
||||
@@ -56,6 +49,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
_colShape1.OnEntityExitColShape += EntityExitBusinessColShape;
|
||||
NAPI.Blip.CreateBlip(90, new Vector3(-1083.96, -2476.96, 14.07), 1.0f, 4, "Flugschule", shortRange: true);
|
||||
}
|
||||
|
||||
private static void EntityEnterBusinessColShape(ColShape colShape, Player client)
|
||||
{
|
||||
if (client.IsInVehicle || !client.IsLoggedIn()) return;
|
||||
@@ -132,6 +126,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
user.ResetData("ActiveSchool");
|
||||
user.Position = new Vector3(-1083.96, -2476.96, 13.07);
|
||||
}
|
||||
|
||||
[RemoteEvent("planeSchoolEvent")]
|
||||
public void planeSchoolEvent(Player user, int checkpoint)
|
||||
{
|
||||
@@ -177,11 +172,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
user.TriggerEvent("renderTextOnScreen", "Setze zum landeflug an. Drücke 'G' um ihr Fahrwerk auszufahren.");
|
||||
CheckPointHandle.StartCheckPointRoute(user, planeRouteEnd, 5000, 6, 12, "planeSchoolEventEnd");
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Text.RegularExpressions;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Chat : Script
|
||||
{
|
||||
[ServerEvent(Event.ChatMessage)]
|
||||
public void ChatEvent(Player player, string message)
|
||||
{
|
||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
if (serverMsg.Trim().Length == 0) return;
|
||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
|
||||
{
|
||||
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");//
|
||||
});
|
||||
[ServerEvent(Event.ChatMessage)]
|
||||
public void ChatEvent(Player player, string message)
|
||||
{
|
||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
if (serverMsg.Trim().Length == 0) return;
|
||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
|
||||
{
|
||||
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -16,7 +13,7 @@ using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Connect : Script
|
||||
internal class Connect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Player player)
|
||||
@@ -24,7 +21,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SetData("isLoggedIn", false);
|
||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
@@ -41,12 +37,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (IsPlayerBanned(player)) return;
|
||||
player.TriggerEvent("SERVER:Login_ShowBrowser");
|
||||
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID: " + player.Handle.Value + "] (" + player.Address + ")";
|
||||
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
||||
|
||||
}
|
||||
|
||||
private bool IsPlayerBanned(Player player)
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Inventory;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
/**
|
||||
@@ -19,54 +22,53 @@ using ReallifeGamemode.Server.Wanted;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Death : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Player player, Player killer, uint reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) player.Kick();
|
||||
player.SetData("isDead", true);
|
||||
|
||||
//TODO: Zum Full Release entfernen
|
||||
ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
float killerPosY;
|
||||
float killerPosZ;
|
||||
float killerHeading;
|
||||
|
||||
if (killer == null || killer.IsNull)
|
||||
{
|
||||
killerId = null;
|
||||
killerPosX = -1;
|
||||
killerPosY = -1;
|
||||
killerPosZ = -1;
|
||||
killerHeading = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
killerId = killer.GetUser().Id;
|
||||
killerPosX = killer.Position.X;
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
if (player.HasData("inGangWar") && killer.HasData("inGangWar"))
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Player player, Player killer, uint reason)
|
||||
{
|
||||
Gangwar.Gangwar.GangwarKill(killer, player);
|
||||
}
|
||||
if (!player.IsLoggedIn()) player.Kick();
|
||||
player.SetData("isDead", true);
|
||||
|
||||
if (player != killer)
|
||||
{
|
||||
Autowanted.Check_AutoWanted(killer, player);
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + Managers.WeaponManager.GetCauseOfDeathByHash(reason) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
}
|
||||
}
|
||||
//TODO: Zum Full Release entfernen
|
||||
ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
float killerPosY;
|
||||
float killerPosZ;
|
||||
float killerHeading;
|
||||
|
||||
if (killer == null || killer.IsNull)
|
||||
{
|
||||
killerId = null;
|
||||
killerPosX = -1;
|
||||
killerPosY = -1;
|
||||
killerPosZ = -1;
|
||||
killerHeading = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
killerId = killer.GetUser().Id;
|
||||
killerPosX = killer.Position.X;
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
if (player.HasData("inGangWar") && killer.HasData("inGangWar"))
|
||||
{
|
||||
Gangwar.Gangwar.GangwarKill(killer, player);
|
||||
}
|
||||
|
||||
if (player != killer)
|
||||
{
|
||||
Autowanted.Check_AutoWanted(killer, player);
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + Managers.WeaponManager.GetCauseOfDeathByHash(reason) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
}
|
||||
}
|
||||
|
||||
User user = player.GetUser();
|
||||
if (user.JailTime <= 0)
|
||||
{
|
||||
|
||||
//MEDIC AUFTRAG
|
||||
MedicTask reviveTask = new MedicTask()
|
||||
{
|
||||
@@ -81,49 +83,75 @@ namespace ReallifeGamemode.Server.Events
|
||||
};
|
||||
Medic.AddTaskToList(reviveTask);
|
||||
|
||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
}
|
||||
|
||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||
|
||||
player.ClearAttachments();
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
List<UserItem> fItem = userDeath.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
foreach (var item in fItem)
|
||||
{
|
||||
IItem iItem = InventoryManager.GetItemById(item.ItemId);
|
||||
if (iItem is IWeaponDealItem obj)
|
||||
{
|
||||
int amount = item.Amount;
|
||||
|
||||
Vector3 dropPosition = PlayerExtension.GetPositionFromPlayer(player, 0.6f, 0);
|
||||
//new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f);
|
||||
Random r = new Random();
|
||||
GTANetworkAPI.Object grndObject;
|
||||
Vector3 textPos = dropPosition;
|
||||
|
||||
dropPosition.Z -= 1.05f;
|
||||
grndObject = NAPI.Object.CreateObject(3666746839, dropPosition, new Vector3(0, 0, r.Next(0, 360)), 255, 0);
|
||||
|
||||
GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition };
|
||||
TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", textPos, 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
|
||||
GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl);
|
||||
|
||||
userDeath.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
var dead = new Database.Entities.Logs.Death
|
||||
{
|
||||
VictimId = player.GetUser().Id,
|
||||
KillerId = killerId,
|
||||
KillerPositionX = killerPosX,
|
||||
KillerPositionY = killerPosY,
|
||||
KillerPositionZ = killerPosZ,
|
||||
KillerHeading = killerHeading,
|
||||
VictimPositionX = player.Position.X,
|
||||
VictimPositionY = player.Position.Y,
|
||||
VictimPositionZ = player.Position.Z,
|
||||
VictimHeading = player.Heading,
|
||||
CauseOfDeath = reason.ToString()
|
||||
};
|
||||
userDeath.DeathLogs.Add(dead);
|
||||
userDeath.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
//JailTime.cs
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
|
||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||
public void RespawnPlayerAtHospital(Player player)
|
||||
{
|
||||
var dead = new Database.Entities.Logs.Death
|
||||
{
|
||||
VictimId = player.GetUser().Id,
|
||||
KillerId = killerId,
|
||||
KillerPositionX = killerPosX,
|
||||
KillerPositionY = killerPosY,
|
||||
KillerPositionZ = killerPosZ,
|
||||
KillerHeading = killerHeading,
|
||||
VictimPositionX = player.Position.X,
|
||||
VictimPositionY = player.Position.Y,
|
||||
VictimPositionZ = player.Position.Z,
|
||||
VictimHeading = player.Heading,
|
||||
CauseOfDeath = reason.ToString()
|
||||
};
|
||||
userDeath.DeathLogs.Add(dead);
|
||||
userDeath.SaveChanges();
|
||||
player.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
}
|
||||
}
|
||||
|
||||
//JailTime.cs
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||
public void RespawnPlayerAtHospital(Player player)
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Job;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -21,50 +16,50 @@ using ReallifeGamemode.Server.Types;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Disconnect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Player player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Player player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
|
||||
if (GlobalHelper.DutyAdmins.Contains(player))
|
||||
{
|
||||
GlobalHelper.DutyAdmins.Remove(player);
|
||||
}
|
||||
if (GlobalHelper.DutyAdmins.Contains(player))
|
||||
{
|
||||
GlobalHelper.DutyAdmins.Remove(player);
|
||||
}
|
||||
|
||||
if (player.GetUser().IsAdmin(AdminLevel.MAPPING))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + player.Name + " hat den Server verlassen", AdminLevel.MAPPING);
|
||||
}
|
||||
if (player.GetUser().IsAdmin(AdminLevel.MAPPING))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + player.Name + " hat den Server verlassen", AdminLevel.MAPPING);
|
||||
}
|
||||
|
||||
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||
if (job != null) job.StopJob(player, true);
|
||||
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||
if (job != null) job.StopJob(player, true);
|
||||
|
||||
using (var saveUser = new DatabaseContext())
|
||||
{
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
using (var saveUser = new DatabaseContext())
|
||||
{
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
user.PositionZ = pos.Z;
|
||||
saveUser.SaveChanges();
|
||||
user.Dead = player.HasData("isDead") ? (bool)player.GetData<bool>("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
user.PositionZ = pos.Z;
|
||||
saveUser.SaveChanges();
|
||||
user.Dead = player.HasData("isDead") ? (bool)player.GetData<bool>("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
@@ -19,16 +17,16 @@ namespace ReallifeGamemode.Server.Events
|
||||
return;
|
||||
}
|
||||
|
||||
if (vehicle.HasMarkerBehind())
|
||||
vehicle.RemoveMarkerBehind();
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
User u = client.GetUser();
|
||||
if (u.FactionId != null && (!veh.GetOwners().Contains(u.FactionId.Value)) && (veh.Model == VehicleHash.Burrito3) && vehicle.HasData("weaponDeal") && vehicle.GetData<bool>("weaponDeal") == true)
|
||||
if (u.FactionId != null && (veh.GetOwners().Contains(u.FactionId.Value)) && (veh.Model == VehicleHash.Burrito3) && vehicle.HasData("weaponDeal") && vehicle.GetData<bool>("weaponDeal") == true)
|
||||
{
|
||||
Vector3 vector = WeaponDealPoints.getRndWD_Route(client.GetUser().FactionId.Value);
|
||||
if (vector == new Vector3())
|
||||
return;
|
||||
List<Vector3> dealPoint = new List<Vector3>();
|
||||
dealPoint.Add(vector);
|
||||
dealPoint.Add(vehicle.GetData<Vector3>("weaponDealPoint"));
|
||||
CheckPointHandle.StartCheckPointRoute(client, dealPoint, 5000, 1, 7, "loadWeaponTransport");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
@@ -10,51 +7,50 @@ using ReallifeGamemode.Server.WeaponDeal;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
|
||||
public class EnterVehicleAttempt : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||
{
|
||||
if (seat == 1) seat = 0;
|
||||
else if (seat == 0) seat = 1;
|
||||
}
|
||||
|
||||
if (seat != 0) return;
|
||||
|
||||
User u = player.GetUser();
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3)
|
||||
{
|
||||
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
||||
return;
|
||||
}
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||
{
|
||||
if (seat == 1) seat = 0;
|
||||
else if (seat == 0) seat = 1;
|
||||
}
|
||||
|
||||
if (seat != 0) return;
|
||||
|
||||
User u = player.GetUser();
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||
{
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3)
|
||||
{
|
||||
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
||||
return;
|
||||
}
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (vehicle.GetServerVehicle() is SchoolVehicle sVeh)
|
||||
{
|
||||
if (!player.HasData("ActiveSchool"))
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
if (sVeh.SchoolId != player.GetData<int>("ActiveSchool"))
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vehicle.GetServerVehicle() is SchoolVehicle sVeh)
|
||||
{
|
||||
if (!player.HasData("ActiveSchool"))
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
if (sVeh.SchoolId != player.GetData<int>("ActiveSchool"))
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.WeaponDeal;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
@@ -15,8 +11,11 @@ namespace ReallifeGamemode.Server.Events
|
||||
[ServerEvent(Event.PlayerExitVehicleAttempt)]
|
||||
public void OnPlayerExitVehicle(Player client, GTANetworkAPI.Vehicle vehicle)
|
||||
{
|
||||
if (client.VehicleSeat != -1)
|
||||
if (client.VehicleSeat != 0)
|
||||
return;
|
||||
|
||||
client.TriggerEvent("SERVER:setMarkerBehindVehicle", vehicle);
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
User u = client.GetUser();
|
||||
@@ -25,6 +24,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
CheckPointHandle.RemovePlayerHandlerFromList(client);
|
||||
client.TriggerEvent("destroyCP");
|
||||
}
|
||||
else if ((u.FactionId != null) && (veh.GetOwners().Contains(u.FactionId ?? 0)) && ((VehicleHash)vehicle.Model == VehicleHash.Burrito3) && vehicle.HasData("WeaponDealLoad") && vehicle.GetData<bool>("WeaponDealLoad") == true)
|
||||
{
|
||||
client.TriggerEvent("SERVER:setMarkerBehindVehicle", vehicle);
|
||||
}
|
||||
}
|
||||
if (vehicle.GetServerVehicle() is SchoolVehicle vehS)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Faction : Script
|
||||
internal class Faction : Script
|
||||
{
|
||||
[RemoteEvent("OnFactionRanksEdit")]
|
||||
public void OnFactionRanksEdit(Player player, string jsonData)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
@@ -9,72 +7,69 @@ using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Inventory : Script
|
||||
{
|
||||
[RemoteEvent("getNearVehicles")]
|
||||
public void SrvEvent_GetNearVehicles(Player client)
|
||||
{
|
||||
var user = client.GetUser();
|
||||
if (!client.IsInVehicle)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
[RemoteEvent("getNearVehicles")]
|
||||
public void SrvEvent_GetNearVehicles(Player client)
|
||||
{
|
||||
foreach (GTANetworkAPI.Vehicle veh in NAPI.Pools.GetAllVehicles())
|
||||
{
|
||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||
if (veh.Position.DistanceTo(client.Position) < 5f)
|
||||
var user = client.GetUser();
|
||||
if (!client.IsInVehicle)
|
||||
{
|
||||
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearLeft) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearRight) == DoorState.DoorOpen)
|
||||
{
|
||||
vehicleInventory = getVehItem(veh);
|
||||
}
|
||||
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
|
||||
return;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
foreach (GTANetworkAPI.Vehicle veh in NAPI.Pools.GetAllVehicles())
|
||||
{
|
||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||
if (veh.Position.DistanceTo(client.Position) < 5f)
|
||||
{
|
||||
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearLeft) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearRight) == DoorState.DoorOpen)
|
||||
{
|
||||
vehicleInventory = getVehItem(veh);
|
||||
}
|
||||
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<VehicleInventory> getVehItem(GTANetworkAPI.Vehicle veh)
|
||||
{
|
||||
List<string> iName = new List<string>();
|
||||
List<int> iAmount = new List<int>();
|
||||
List<int> iId = new List<int>();
|
||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||
var inventoryWeight = 0;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||
List<VehicleItem> vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id);
|
||||
foreach (var vehItem in vehicleItems)
|
||||
public List<VehicleInventory> getVehItem(GTANetworkAPI.Vehicle veh)
|
||||
{
|
||||
IItem iItem = InventoryManager.GetItemById(vehItem.ItemId);
|
||||
var currentItemWeight = iItem.Gewicht * vehItem.Amount;
|
||||
inventoryWeight += currentItemWeight;
|
||||
|
||||
iName.Add(iItem.Name);
|
||||
iAmount.Add(vehItem.Amount);
|
||||
iId.Add(iItem.Id);
|
||||
List<string> iName = new List<string>();
|
||||
List<int> iAmount = new List<int>();
|
||||
List<int> iId = new List<int>();
|
||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||
var inventoryWeight = 0;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||
List<VehicleItem> vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id);
|
||||
foreach (var vehItem in vehicleItems)
|
||||
{
|
||||
IItem iItem = InventoryManager.GetItemById(vehItem.ItemId);
|
||||
var currentItemWeight = iItem.Gewicht * vehItem.Amount;
|
||||
inventoryWeight += currentItemWeight;
|
||||
|
||||
iName.Add(iItem.Name);
|
||||
iAmount.Add(vehItem.Amount);
|
||||
iId.Add(iItem.Id);
|
||||
}
|
||||
var vehInv = new VehicleInventory
|
||||
{
|
||||
ID = serverVehicle.Id,
|
||||
currentWeight = inventoryWeight,
|
||||
totalWeight = 250,
|
||||
ivehName = iName.ToArray(),
|
||||
ivehAmount = iAmount.ToArray(),
|
||||
ivehId = iId.ToArray()
|
||||
};
|
||||
vehicleInventory.Add(vehInv);
|
||||
}
|
||||
return vehicleInventory;
|
||||
}
|
||||
var vehInv = new VehicleInventory
|
||||
{
|
||||
ID = serverVehicle.Id,
|
||||
currentWeight = inventoryWeight,
|
||||
totalWeight = 250,
|
||||
ivehName = iName.ToArray(),
|
||||
ivehAmount = iAmount.ToArray(),
|
||||
ivehId = iId.ToArray()
|
||||
};
|
||||
vehicleInventory.Add(vehInv);
|
||||
}
|
||||
return vehicleInventory;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Classes;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Classes;
|
||||
using ReallifeGamemode.Server.DrivingSchool;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Finance;
|
||||
using ReallifeGamemode.Server.Inventory;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.DrivingSchool;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.WeaponDeal;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Key (Key.cs)
|
||||
* @author VegaZ
|
||||
@@ -46,6 +46,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
tempBlip.Transparency.ToString(), 200.ToString(), tempBlip.ShortRange.ToString(), 0.ToString(), 0.ToString());
|
||||
player.SendNotification("~y~Blip~s~ erstellt!", false);
|
||||
break;
|
||||
|
||||
case "atm":
|
||||
SaveManager.OnSaveBlipData(player, "500", "Geldautomat", 0.7.ToString(), "11",
|
||||
"0", "200", true.ToString(), 0.ToString(), 0.ToString());
|
||||
@@ -170,7 +171,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
|
||||
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearestDuty = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5 && d.FactionId == user.FactionId);
|
||||
@@ -179,7 +179,63 @@ namespace ReallifeGamemode.Server.Events
|
||||
ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3));
|
||||
ClotheshopPoint nearestClotheShopPoint = PositionManager.clotheshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData<bool>("duty")));
|
||||
ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
BehindVehiclePoint nearestBehindVehiclePoint = MarkerBehinVehicle.behindVehiclePoints.Find(s => s.marker.Position.DistanceTo(player.Position) <= 3 && (user.FactionId == 8 || user.FactionId == 7 || user.FactionId == 1 || user.FactionId == 3));
|
||||
|
||||
if (nearestBehindVehiclePoint != null)
|
||||
{
|
||||
if (player.HasAttachment("ammobox")) return;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
List<VehicleItem> vehicleItems = dbContext.VehicleItems.Where(f => f.GetVehicle().GetVehicle() == nearestBehindVehiclePoint.vehicle && InventoryManager.GetItemById(f.ItemId) is IWeaponDealItem).ToList();
|
||||
if (vehicleItems.Count == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle vehicle = nearestBehindVehiclePoint.vehicle;
|
||||
|
||||
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
||||
{
|
||||
vehicle.ResetData("WeaponDealLoad");
|
||||
}
|
||||
|
||||
nearestBehindVehiclePoint.vehicle.RemoveMarkerBehind();
|
||||
|
||||
return;
|
||||
}
|
||||
foreach (var v in vehicleItems)
|
||||
{
|
||||
int itemToAdd = 0;
|
||||
for (int i = 1; i <= v.Amount; i++)
|
||||
{
|
||||
if (InventoryManager.GetUserInventoryWeight(player) + (i * InventoryManager.GetItemById(v.ItemId).Gewicht) > 40000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemToAdd = i;
|
||||
}
|
||||
}
|
||||
if (itemToAdd == 0)
|
||||
break;
|
||||
|
||||
v.Amount -= itemToAdd;
|
||||
if (v.Amount <= 0)
|
||||
dbContext.VehicleItems.Remove(v);
|
||||
|
||||
var newItem = new UserItem()
|
||||
{
|
||||
ItemId = v.ItemId,
|
||||
Slot = v.Slot,
|
||||
Amount = itemToAdd,
|
||||
UserId = user.Id,
|
||||
};
|
||||
|
||||
InventoryManager.AddItemToInventory(player, newItem.Id, newItem.Amount);
|
||||
nearestBehindVehiclePoint.usePoint(player);
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nearestDuty != null)// Duty Point
|
||||
{
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
@@ -259,7 +315,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
if (nearestWeapon != null) // Weapon Point
|
||||
{
|
||||
|
||||
List<string> primarys = new List<string>();
|
||||
List<string> secondarys = new List<string>();
|
||||
List<string> melees = new List<string>();
|
||||
@@ -271,11 +326,13 @@ namespace ReallifeGamemode.Server.Events
|
||||
melees.Add("Keine");
|
||||
specials.Add("Keine");
|
||||
|
||||
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
|
||||
if (player.HasAttachment("ammobox"))
|
||||
{
|
||||
player.AddAttachment("ammobox", true);
|
||||
player.StopAnimation();
|
||||
}
|
||||
|
||||
List<UserItem> fItem = context.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
foreach (var item in fItem)
|
||||
@@ -285,7 +342,11 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
FactionWeapon weapon = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == iItem.Name).FirstOrDefault();
|
||||
if (weapon == null)
|
||||
{
|
||||
context.Remove(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
weapon.Ammount += item.Amount;
|
||||
ChatService.SendMessage(player, item.Amount + " " + iItem.Name + " wurden im Waffenlager hinzugefürgt.");
|
||||
context.Remove(item);
|
||||
@@ -311,14 +372,17 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
primarys.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
secondarys.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
melees.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
specials.Add(weapon.WeaponModel.ToString());
|
||||
@@ -374,7 +438,8 @@ namespace ReallifeGamemode.Server.Events
|
||||
public void KeyPressI(Player player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
InventoryManager.GetUserItems(player);
|
||||
player.TriggerEvent("inventoryShow");
|
||||
InventoryManager.SetBackpackItems(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:O")]
|
||||
@@ -429,9 +494,11 @@ namespace ReallifeGamemode.Server.Events
|
||||
case 11:
|
||||
tops.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
|
||||
case 4:
|
||||
legs.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
|
||||
case 6:
|
||||
shoes.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
@@ -441,7 +508,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:L")]
|
||||
@@ -526,7 +592,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
|
||||
Vehicle.VehicleMenuLockCarEvent(player);
|
||||
|
||||
GroundItem.PickUpGroundItem(player);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -21,138 +19,141 @@ using Newtonsoft.Json;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Login : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:Login_LoginRequest")]
|
||||
public void OnPlayerLogin(Player player, string username, string password)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = dbContext.Users
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.BankAccount)
|
||||
.SingleOrDefault(b => b.Name == username);
|
||||
|
||||
if (user == null)
|
||||
[RemoteEvent("CLIENT:Login_LoginRequest")]
|
||||
public void OnPlayerLogin(Player player, string username, string password)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = dbContext.Users
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.BankAccount)
|
||||
.SingleOrDefault(b => b.Name == username);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
|
||||
//TODO ?? Log einbauen für den bösen Bub.
|
||||
player.Kick();
|
||||
}
|
||||
if (user.Password != NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Name = username;
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true));
|
||||
player.SetData("spec", true);
|
||||
player.SetData("duty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
Gangwar.Gangwar.loadPlayer(player);
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
}
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN))
|
||||
{
|
||||
player.SetData("editmode", false);
|
||||
player.SetData("quicksavemode", "none");
|
||||
}
|
||||
|
||||
var userBankAccount = user.BankAccount;
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
user.Wanteds = user.Wanteds;
|
||||
|
||||
if (user.Group != null)
|
||||
{
|
||||
string msg = $"{player.Name} ist wieder online.";
|
||||
ChatService.BroadcastGroup(msg, user.Group);
|
||||
}
|
||||
|
||||
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + GlobalHelper.CustomJoinMessages[player.SocialClubName] + " [ID: " + player.Handle.Value + "] (" + user.AdminLevel.GetName() + ")", AdminLevel.MAPPING);
|
||||
}
|
||||
else if (user.IsAdmin(AdminLevel.MAPPING))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + user.Name + " [ID: " + player.Handle.Value + "]" + " hat sich als " + user.AdminLevel.GetName() + " eingeloggt!", AdminLevel.MAPPING);
|
||||
}
|
||||
|
||||
var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
player.SetData("items", userItems);
|
||||
|
||||
switch (user.FactionId)
|
||||
{
|
||||
case null:
|
||||
player.SetSharedData("blipColor", 0);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
player.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
player.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
player.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
}
|
||||
|
||||
if (user.CharacterId == null)
|
||||
{
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
player.Rotation = new Vector3(0, 0, 180);
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterCreator.ApplyCharacter(player);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
if (user.JailTime <= 0)
|
||||
{
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
}
|
||||
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
if (user.Dead == true)
|
||||
{
|
||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
player.Health = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
player.Health = 0;
|
||||
}
|
||||
player.SetData("isDead", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
|
||||
//TODO ?? Log einbauen für den bösen Bub.
|
||||
player.Kick();
|
||||
}
|
||||
if (user.Password != NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Name = username;
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true));
|
||||
player.SetData("spec", true);
|
||||
player.SetData("duty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
Gangwar.Gangwar.loadPlayer(player);
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
}
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN))
|
||||
{
|
||||
player.SetData("editmode", false);
|
||||
player.SetData("quicksavemode", "none");
|
||||
}
|
||||
|
||||
var userBankAccount = user.BankAccount;
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
user.Wanteds = user.Wanteds;
|
||||
|
||||
if (user.Group != null)
|
||||
{
|
||||
string msg = $"{player.Name} ist wieder online.";
|
||||
ChatService.BroadcastGroup(msg, user.Group);
|
||||
}
|
||||
|
||||
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + GlobalHelper.CustomJoinMessages[player.SocialClubName] + " [ID: " + player.Handle.Value + "] (" + user.AdminLevel.GetName() + ")", AdminLevel.MAPPING);
|
||||
}
|
||||
else if (user.IsAdmin(AdminLevel.MAPPING))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + user.Name + " [ID: " + player.Handle.Value + "]" + " hat sich als " + user.AdminLevel.GetName() + " eingeloggt!", AdminLevel.MAPPING);
|
||||
}
|
||||
|
||||
var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
player.SetData("items", userItems);
|
||||
|
||||
switch (user.FactionId)
|
||||
{
|
||||
case null:
|
||||
player.SetSharedData("blipColor", 0);
|
||||
break;
|
||||
case 8:
|
||||
player.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
case 7:
|
||||
player.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
case 4:
|
||||
player.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
}
|
||||
|
||||
if (user.CharacterId == null)
|
||||
{
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
player.Rotation = new Vector3(0, 0, 180);
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterCreator.ApplyCharacter(player);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
if (user.JailTime <= 0)
|
||||
{
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
}
|
||||
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
if (user.Dead == true)
|
||||
{
|
||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
player.Health = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
player.Health = 0;
|
||||
}
|
||||
player.SetData("isDead", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Register (Register.cs)
|
||||
@@ -11,7 +11,7 @@ using ReallifeGamemode.Database.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Register : Script
|
||||
internal class Register : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:Login_RegisterRequest")]
|
||||
public void OnPlayerRegister(Player player, string username, string password, string passwordRepeat)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using System.Linq;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event ResourceStop (ResourceStop.cs)
|
||||
@@ -11,24 +11,24 @@ using System.Linq;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class ResourceStop : Script
|
||||
{
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
{
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach (Player user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
{
|
||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
saveUser.PositionX = user.Position.X;
|
||||
saveUser.PositionY = user.Position.Y;
|
||||
saveUser.PositionZ = user.Position.Z;
|
||||
saveUsers.SaveChanges();
|
||||
foreach (Player user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
{
|
||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||
|
||||
saveUser.PositionX = user.Position.X;
|
||||
saveUser.PositionY = user.Position.Y;
|
||||
saveUser.PositionZ = user.Position.Z;
|
||||
saveUsers.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Siren : Script
|
||||
internal class Siren : Script
|
||||
{
|
||||
private readonly Dictionary<NetHandle, bool> _sirenStates = new Dictionary<NetHandle, bool>();
|
||||
|
||||
@@ -21,7 +19,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
pV.SetSharedData("sirenSound", newValue);
|
||||
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("toggleVehicleSiren", pV, newValue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,255 +9,253 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterCloth : Script
|
||||
{
|
||||
[RemoteEvent("updateDutyProp")]
|
||||
public void UpdateDutyProp(Player player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId != -1)
|
||||
{
|
||||
player.SetAccessories(componentId, componentVariation, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("updateDutyCloth")]
|
||||
public void UpdateDutyCloth(Player player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId == 11)
|
||||
{
|
||||
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
|
||||
using (var context = new DatabaseContext())
|
||||
[RemoteEvent("updateDutyProp")]
|
||||
public void UpdateDutyProp(Player player, int componentId, int componentVariation)
|
||||
{
|
||||
var character = player.GetUser().GetCharacter();
|
||||
|
||||
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
||||
player.SetClothes(11, componentVariation, 0);
|
||||
if (combination != null)
|
||||
{
|
||||
player.SetClothes(3, combination.Torso, 0);
|
||||
player.SetClothes(8, combination.Undershirt, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(componentId, componentVariation, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("saveCharacterCloth")]
|
||||
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||
|
||||
User user = client.GetUser();
|
||||
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
var character = client.GetUser().GetCharacter();
|
||||
|
||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||
if (charClothes == null)
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
if (componentId != -1)
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = (byte)slotType[x],
|
||||
SlotId = slotId[x],
|
||||
ClothId = clothId[x]
|
||||
};
|
||||
context.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
if (user.GetCharacter().Gender == false)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
||||
};
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
||||
};
|
||||
context.CharacterClothes.Add(newTorso);
|
||||
context.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||
loopCloth.ClothId = clothId[x];
|
||||
}
|
||||
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||
|
||||
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
||||
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
LoadCharacterDefaults(client);
|
||||
}
|
||||
|
||||
[RemoteEvent("defaultCharacterCloth")]
|
||||
public static void LoadCharacterDefaults(Player player)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
player.ClearAccessory(6);
|
||||
player.ClearAccessory(7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||
public void RmtEvent_BuyClothes(Player client, string type, string jsonData)
|
||||
{
|
||||
/*
|
||||
* [0] ComponentID
|
||||
* [1] TextureID
|
||||
* [2] ClotheID
|
||||
* [3] TorsoID
|
||||
* [4] UndershirtID
|
||||
* [5] UndershirtTextureID
|
||||
* [6] Price
|
||||
*/
|
||||
|
||||
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
|
||||
User user = client.GetUser();
|
||||
if (user.Handmoney < data[6])
|
||||
{
|
||||
client.TriggerEvent("clothesMenu:Error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "clothe")
|
||||
{
|
||||
if (data[0] == 11)//for tops
|
||||
{
|
||||
client.SetClothes(11, data[2], data[1]); //set Top
|
||||
client.SetClothes(8, data[4], data[5]); //set undershirt
|
||||
client.SetClothes(3, data[3], 0); //set Torso
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SetClothes(data[0], data[2], data[1]);
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
|
||||
|
||||
if(clothes == null)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = data[0],
|
||||
ClothId = data[2],
|
||||
Texture = data[1]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
else
|
||||
{
|
||||
clothes.ClothId = data[2];
|
||||
clothes.Texture = data[1];
|
||||
}
|
||||
if(data[0] == 11)
|
||||
{
|
||||
var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false);
|
||||
var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false);
|
||||
if(torso == null)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = data[3]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newTorso);
|
||||
player.SetAccessories(componentId, componentVariation, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
torso.ClothId = data[3];
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
}
|
||||
if(undershirt == null)
|
||||
}
|
||||
|
||||
[RemoteEvent("updateDutyCloth")]
|
||||
public void UpdateDutyCloth(Player player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId == 11)
|
||||
{
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
Duty = false,
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = data[4],
|
||||
Texture = data[5]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newUndershirt);
|
||||
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var character = player.GetUser().GetCharacter();
|
||||
|
||||
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
||||
player.SetClothes(11, componentVariation, 0);
|
||||
if (combination != null)
|
||||
{
|
||||
player.SetClothes(3, combination.Torso, 0);
|
||||
player.SetClothes(8, combination.Undershirt, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
undershirt.ClothId = data[4];
|
||||
undershirt.Texture = data[5];
|
||||
player.SetClothes(componentId, componentVariation, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("saveCharacterCloth")]
|
||||
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||
|
||||
User user = client.GetUser();
|
||||
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
var character = client.GetUser().GetCharacter();
|
||||
|
||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||
if (charClothes == null)
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = (byte)slotType[x],
|
||||
SlotId = slotId[x],
|
||||
ClothId = clothId[x]
|
||||
};
|
||||
context.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
if (user.GetCharacter().Gender == false)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
||||
};
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
||||
};
|
||||
context.CharacterClothes.Add(newTorso);
|
||||
context.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||
loopCloth.ClothId = clothId[x];
|
||||
}
|
||||
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||
|
||||
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
||||
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
LoadCharacterDefaults(client);
|
||||
}
|
||||
|
||||
[RemoteEvent("defaultCharacterCloth")]
|
||||
public static void LoadCharacterDefaults(Player player)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
player.ClearAccessory(6);
|
||||
player.ClearAccessory(7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||
public void RmtEvent_BuyClothes(Player client, string type, string jsonData)
|
||||
{
|
||||
/*
|
||||
* [0] ComponentID
|
||||
* [1] TextureID
|
||||
* [2] ClotheID
|
||||
* [3] TorsoID
|
||||
* [4] UndershirtID
|
||||
* [5] UndershirtTextureID
|
||||
* [6] Price
|
||||
*/
|
||||
|
||||
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
|
||||
User user = client.GetUser();
|
||||
if (user.Handmoney < data[6])
|
||||
{
|
||||
client.TriggerEvent("clothesMenu:Error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "clothe")
|
||||
{
|
||||
if (data[0] == 11)//for tops
|
||||
{
|
||||
client.SetClothes(11, data[2], data[1]); //set Top
|
||||
client.SetClothes(8, data[4], data[5]); //set undershirt
|
||||
client.SetClothes(3, data[3], 0); //set Torso
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SetClothes(data[0], data[2], data[1]);
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
|
||||
|
||||
if (clothes == null)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = data[0],
|
||||
ClothId = data[2],
|
||||
Texture = data[1]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
else
|
||||
{
|
||||
clothes.ClothId = data[2];
|
||||
clothes.Texture = data[1];
|
||||
}
|
||||
if (data[0] == 11)
|
||||
{
|
||||
var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false);
|
||||
var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false);
|
||||
if (torso == null)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = data[3]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newTorso);
|
||||
}
|
||||
else
|
||||
{
|
||||
torso.ClothId = data[3];
|
||||
}
|
||||
if (undershirt == null)
|
||||
{
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
Duty = false,
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = data[4],
|
||||
Texture = data[5]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
else
|
||||
{
|
||||
undershirt.ClothId = data[4];
|
||||
undershirt.Texture = data[5];
|
||||
}
|
||||
}
|
||||
client.GetUser(dbContext).Handmoney -= data[6];
|
||||
dbContext.SaveChanges();
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
|
||||
}
|
||||
}
|
||||
client.GetUser(dbContext).Handmoney -= data[6];
|
||||
dbContext.SaveChanges();
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterElevator : Script
|
||||
{
|
||||
[RemoteEvent("sendPlayerToStage")]
|
||||
public void SaveWeaponSelection(Player client, string stage)
|
||||
{
|
||||
ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage);
|
||||
if (elevator != null)
|
||||
{
|
||||
client.Position = elevator.Position;
|
||||
}
|
||||
[RemoteEvent("sendPlayerToStage")]
|
||||
public void SaveWeaponSelection(Player client, string stage)
|
||||
{
|
||||
ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage);
|
||||
if (elevator != null)
|
||||
{
|
||||
client.Position = elevator.Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
@@ -8,103 +7,101 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterWeapon : Script
|
||||
{
|
||||
[RemoteEvent("updateWeaponSelection")]
|
||||
public void UpdateWeaponSelection(Player client, string weaponModel, int slot)
|
||||
{
|
||||
if (weaponModel == "Keine")
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel);
|
||||
|
||||
if (slot == 1)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 2)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 3)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 4)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("cancelWeaponSelection")]
|
||||
public void CancelWeaponSelection(Player client)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("saveWeaponSelection")]
|
||||
public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
if (!uint.TryParse(primaryModel, out uint primary))
|
||||
{
|
||||
if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2");
|
||||
primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(secondaryModel, out uint secondary))
|
||||
{
|
||||
if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2");
|
||||
secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(meleeModel, out uint melee))
|
||||
{
|
||||
if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2");
|
||||
melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}");
|
||||
}
|
||||
|
||||
|
||||
client.GiveWeapon((WeaponHash)primary, 50);
|
||||
client.GiveWeapon((WeaponHash)secondary, 150);
|
||||
client.GiveWeapon((WeaponHash)melee, 1);
|
||||
if (specialModel != "Schutzweste")
|
||||
{
|
||||
client.Armor = 0;
|
||||
if (!uint.TryParse(specialModel, out uint special))
|
||||
[RemoteEvent("updateWeaponSelection")]
|
||||
public void UpdateWeaponSelection(Player client, string weaponModel, int slot)
|
||||
{
|
||||
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
||||
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
||||
}
|
||||
client.GiveWeapon((WeaponHash)special, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Armor = 50;
|
||||
}
|
||||
if (weaponModel == "Keine")
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
return;
|
||||
}
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser();
|
||||
FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault();
|
||||
if (slot1 != null)
|
||||
slot1.Ammount -= 1;
|
||||
FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault();
|
||||
if (slot2 != null)
|
||||
slot2.Ammount -= 1;
|
||||
FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault();
|
||||
if (slot3 != null)
|
||||
slot3.Ammount -= 1;
|
||||
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
||||
if (slot4 != null)
|
||||
slot4.Ammount -= 1;
|
||||
context.SaveChanges();
|
||||
}
|
||||
WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel);
|
||||
|
||||
if (slot == 1)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 2)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 3)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 4)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("cancelWeaponSelection")]
|
||||
public void CancelWeaponSelection(Player client)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
}
|
||||
|
||||
[RemoteEvent("saveWeaponSelection")]
|
||||
public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
if (!uint.TryParse(primaryModel, out uint primary))
|
||||
{
|
||||
if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2");
|
||||
primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(secondaryModel, out uint secondary))
|
||||
{
|
||||
if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2");
|
||||
secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(meleeModel, out uint melee))
|
||||
{
|
||||
if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2");
|
||||
melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}");
|
||||
}
|
||||
|
||||
client.GiveWeapon((WeaponHash)primary, 50);
|
||||
client.GiveWeapon((WeaponHash)secondary, 150);
|
||||
client.GiveWeapon((WeaponHash)melee, 1);
|
||||
if (specialModel != "Schutzweste")
|
||||
{
|
||||
client.Armor = 0;
|
||||
if (!uint.TryParse(specialModel, out uint special))
|
||||
{
|
||||
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
||||
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
||||
}
|
||||
client.GiveWeapon((WeaponHash)special, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Armor = 50;
|
||||
}
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser();
|
||||
FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault();
|
||||
if (slot1 != null)
|
||||
slot1.Ammount -= 1;
|
||||
FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault();
|
||||
if (slot2 != null)
|
||||
slot2.Ammount -= 1;
|
||||
FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault();
|
||||
if (slot3 != null)
|
||||
slot3.Ammount -= 1;
|
||||
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
||||
if (slot4 != null)
|
||||
slot4.Ammount -= 1;
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,286 +1,282 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database;
|
||||
using System;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Vehicle : Script
|
||||
{
|
||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||
public void VehicleMenuToggleEngineEvent(Player player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16)
|
||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||
public void VehicleMenuToggleEngineEvent(Player player)
|
||||
{
|
||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||
return;
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16)
|
||||
{
|
||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
bool state = VehicleStreaming.GetEngineState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle jV)
|
||||
{
|
||||
if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetEngineState(v, !state);
|
||||
}
|
||||
}
|
||||
|
||||
bool state = VehicleStreaming.GetEngineState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
if (sV != null)
|
||||
[RemoteEvent("VehicleMenu_LockCar")]
|
||||
public static void VehicleMenuLockCarEvent(Player player)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle jV)
|
||||
{
|
||||
if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetEngineState(v, !state);
|
||||
}
|
||||
}
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
[RemoteEvent("VehicleMenu_LockCar")]
|
||||
public static void VehicleMenuLockCarEvent(Player player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
bool state = VehicleStreaming.GetLockState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||
{
|
||||
return;
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (sV is SchoolVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(v, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.TriggerEvent("vehsync:OpenCar", state);
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
else if (!player.IsInVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
GTANetworkAPI.Vehicle vehicle = null;
|
||||
foreach (var veh in NAPI.Pools.GetAllVehicles())
|
||||
{
|
||||
if (player.Position.DistanceTo(veh.Position) <= 3f)
|
||||
{
|
||||
vehicle = veh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vehicle == null)
|
||||
return;
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(vehicle);
|
||||
ServerVehicle sV = vehicle.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(vehicle, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(vehicle, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.TriggerEvent("vehsync:OpenCar", state);
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (sV is SchoolVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(v, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.TriggerEvent("vehsync:OpenCar", state);
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
else if (!player.IsInVehicle)
|
||||
{
|
||||
GTANetworkAPI.Vehicle vehicle = null;
|
||||
foreach (var veh in NAPI.Pools.GetAllVehicles())
|
||||
{
|
||||
if (player.Position.DistanceTo(veh.Position) <= 3f)
|
||||
{
|
||||
vehicle = veh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vehicle == null)
|
||||
return;
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(vehicle);
|
||||
ServerVehicle sV = vehicle.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
||||
public void VehicleMenuParkCarEvent(Player player)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(vehicle, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
return;
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
||||
|
||||
if (sV == null) return;
|
||||
|
||||
if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) || !u.FactionLeader)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
else if (sV is SchoolVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 pos = v.Position;
|
||||
|
||||
sV.PositionX = pos.X;
|
||||
sV.PositionY = pos.Y;
|
||||
sV.PositionZ = pos.Z;
|
||||
sV.Heading = v.Heading;
|
||||
|
||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(vehicle, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.TriggerEvent("vehsync:OpenCar", state);
|
||||
player.SendNotification(msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
||||
public void VehicleMenuParkCarEvent(Player player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||
public void VehicleMenuToggleSingleDoorEvent(Player player, int door)
|
||||
{
|
||||
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
if (sV == null) return;
|
||||
DoorID doorId = (DoorID)door;
|
||||
|
||||
if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) || !u.FactionLeader)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
else if (sV is SchoolVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
||||
|
||||
Vector3 pos = v.Position;
|
||||
|
||||
sV.PositionX = pos.X;
|
||||
sV.PositionY = pos.Y;
|
||||
sV.PositionZ = pos.Z;
|
||||
sV.Heading = v.Heading;
|
||||
|
||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
||||
public void VehicleMenuOpenAllDoorsEvent(Player player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
||||
public void VehicleMenuCloseAllDoorsEvent(Player player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||
public void VehicleMenuToggleSingleDoorEvent(Player player, int door)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
DoorID doorId = (DoorID)door;
|
||||
|
||||
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
||||
|
||||
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
||||
public void VehicleMenuOpenAllDoorsEvent(Player player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
||||
public void VehicleMenuCloseAllDoorsEvent(Player player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Voice : Script
|
||||
internal class Voice : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:AddVoiceListener")]
|
||||
public void AddPlayerVoiceListenerEvent(Player player, Player target)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Player Extension (PlayerExtension.cs)
|
||||
@@ -17,53 +17,53 @@ using System.Linq;
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class PlayerExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt das User-Objekt eines Player's zurück.
|
||||
/// Gibt nichts zurück, wenn der Player nicht eingeloggt ist
|
||||
/// </summary>
|
||||
/// <param name="client">Der Player, dessen User man bekommen möchte</param>
|
||||
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
|
||||
/// <returns></returns>
|
||||
public static User GetUser(this Player client, DatabaseContext context = null)
|
||||
{
|
||||
context = context ?? new DatabaseContext();
|
||||
if (!client.IsLoggedIn()) return null;
|
||||
return context
|
||||
.Users
|
||||
.Include(u => u.Faction)
|
||||
.Include(u => u.FactionRank)
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.House)
|
||||
.Include(u => u.BankAccount)
|
||||
.Where(u => u.Name == client.Name)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static Character GetCharacter(this User user, DatabaseContext context = null)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
using (context = new DatabaseContext())
|
||||
/// <summary>
|
||||
/// Gibt das User-Objekt eines Player's zurück.
|
||||
/// Gibt nichts zurück, wenn der Player nicht eingeloggt ist
|
||||
/// </summary>
|
||||
/// <param name="client">Der Player, dessen User man bekommen möchte</param>
|
||||
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
|
||||
/// <returns></returns>
|
||||
public static User GetUser(this Player client, DatabaseContext context = null)
|
||||
{
|
||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||
context = context ?? new DatabaseContext();
|
||||
if (!client.IsLoggedIn()) return null;
|
||||
return context
|
||||
.Users
|
||||
.Include(u => u.Faction)
|
||||
.Include(u => u.FactionRank)
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.House)
|
||||
.Include(u => u.BankAccount)
|
||||
.Where(u => u.Name == client.Name)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt zurück, ob ein Player eingeloggt ist
|
||||
/// </summary>
|
||||
/// <param name="player">Der Player, dessen Login-Status man bekommen möchte</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsLoggedIn(this Player player)
|
||||
{
|
||||
return player.HasData("isLoggedIn") ? player.GetData<bool>("isLoggedIn") : false;
|
||||
}
|
||||
public static Character GetCharacter(this User user, DatabaseContext context = null)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
using (context = new DatabaseContext())
|
||||
{
|
||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt zurück, ob ein Player eingeloggt ist
|
||||
/// </summary>
|
||||
/// <param name="player">Der Player, dessen Login-Status man bekommen möchte</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsLoggedIn(this Player player)
|
||||
{
|
||||
return player.HasData("isLoggedIn") ? player.GetData<bool>("isLoggedIn") : false;
|
||||
}
|
||||
|
||||
public static bool IsDuty(this Player player)
|
||||
{
|
||||
@@ -81,125 +81,126 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
return newpos;
|
||||
}
|
||||
|
||||
internal static T GetData<T>(this User user, string key, T nullValue)
|
||||
{
|
||||
key += "data_";
|
||||
if (!user.Player.HasData(key)) return nullValue;
|
||||
return JsonConvert.DeserializeObject<T>(user.Player.GetData<dynamic>(key));
|
||||
}
|
||||
|
||||
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
||||
|
||||
internal static void SetData(this User user, string key, object value)
|
||||
{
|
||||
key += "data_";
|
||||
user.Player.SetData(key, JsonConvert.SerializeObject(value));
|
||||
}
|
||||
|
||||
internal static void GiveWanteds(this User user, Player cop, int amount, string reason)
|
||||
{
|
||||
if (user.Wanteds + amount > 50)
|
||||
{
|
||||
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 50 nicht überschreiten");
|
||||
return;
|
||||
}
|
||||
int newWanteds = user.Wanteds + amount;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||
dbUser.Wanteds = newWanteds;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
user.Player.SetSharedData("blipColor", 64);
|
||||
ChatService.SendMessage(user.Player, "!{#FF614A}Du hast ein Verbrechen begangen: " + reason + "" + (cop != null ? " | Gemeldet von: " + cop.Name + "." : ""));
|
||||
ChatService.SendMessage(user.Player, " !{#FFFF00}Fahnundgslevel:~s~ " + newWanteds);
|
||||
|
||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
User copUser = copPlayer.GetUser();
|
||||
if (cop != null && (copUser.FactionId == 1 || copUser.FactionId == 3))
|
||||
internal static T GetData<T>(this User user, string key, T nullValue)
|
||||
{
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Straftat gemeldet von " + cop.Name + " mit Fahndungslevel " + amount + ". Straftäter: " + user.Name + ".");
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Grund: " + reason + ".");
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht.");
|
||||
}
|
||||
else if ((copUser.FactionId == 1 || copUser.FactionId == 3) && cop == null)
|
||||
{
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: " + user.Name + " hat eine Straftat begangen. Grund: " + reason + ".");
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht.");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static FactionRank GetFactionRank(this User user)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == user.FactionRankId);
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == user.FactionId);
|
||||
key += "data_";
|
||||
if (!user.Player.HasData(key)) return nullValue;
|
||||
return JsonConvert.DeserializeObject<T>(user.Player.GetData<dynamic>(key));
|
||||
}
|
||||
|
||||
if (toReturn == null)
|
||||
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
||||
|
||||
internal static void SetData(this User user, string key, object value)
|
||||
{
|
||||
toReturn = new FactionRank
|
||||
{
|
||||
RankName = "Rang-Fehler"
|
||||
};
|
||||
key += "data_";
|
||||
user.Player.SetData(key, JsonConvert.SerializeObject(value));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
||||
public static void BanPlayer(this User user, Player admin, string reason, int mins)
|
||||
{
|
||||
using (var banUserContext = new DatabaseContext())
|
||||
{
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
Ban banUser;
|
||||
|
||||
if (mins == 0)
|
||||
internal static void GiveWanteds(this User user, Player cop, int amount, string reason)
|
||||
{
|
||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||
if (user.Wanteds + amount > 50)
|
||||
{
|
||||
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 50 nicht überschreiten");
|
||||
return;
|
||||
}
|
||||
int newWanteds = user.Wanteds + amount;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||
dbUser.Wanteds = newWanteds;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
user.Player.SetSharedData("blipColor", 64);
|
||||
ChatService.SendMessage(user.Player, "!{#FF614A}Du hast ein Verbrechen begangen: " + reason + "" + (cop != null ? " | Gemeldet von: " + cop.Name + "." : ""));
|
||||
ChatService.SendMessage(user.Player, " !{#FFFF00}Fahnundgslevel:~s~ " + newWanteds);
|
||||
|
||||
user.Player?.Kick();
|
||||
|
||||
mins--;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||
user.Player?.Kick();
|
||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
User copUser = copPlayer.GetUser();
|
||||
if (cop != null && (copUser.FactionId == 1 || copUser.FactionId == 3))
|
||||
{
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Straftat gemeldet von " + cop.Name + " mit Fahndungslevel " + amount + ". Straftäter: " + user.Name + ".");
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Grund: " + reason + ".");
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht.");
|
||||
}
|
||||
else if ((copUser.FactionId == 1 || copUser.FactionId == 3) && cop == null)
|
||||
{
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: " + user.Name + " hat eine Straftat begangen. Grund: " + reason + ".");
|
||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
banUserContext.Bans.Add(banUser);
|
||||
banUserContext.SaveChanges();
|
||||
public static FactionRank GetFactionRank(this User user)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == user.FactionRankId);
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == user.FactionId);
|
||||
}
|
||||
|
||||
var targetUser = banUserContext.Users.Where(u => u.Name == user.Name).FirstOrDefault();
|
||||
targetUser.BanId = banUser.Id;
|
||||
banUserContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = new FactionRank
|
||||
{
|
||||
RankName = "Rang-Fehler"
|
||||
};
|
||||
}
|
||||
|
||||
public static void UnbanPlayer(this User user)
|
||||
{
|
||||
using (var unbanUser = new DatabaseContext())
|
||||
{
|
||||
var targetUser = unbanUser.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||
targetUser.BanId = null;
|
||||
unbanUser.SaveChanges();
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<UserItem> GetItems(this User user)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
}
|
||||
public static void BanPlayer(this User user, Player admin, string reason, int mins)
|
||||
{
|
||||
using (var banUserContext = new DatabaseContext())
|
||||
{
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
Ban banUser;
|
||||
|
||||
if (mins == 0)
|
||||
{
|
||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||
|
||||
user.Player?.Kick();
|
||||
|
||||
mins--;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||
user.Player?.Kick();
|
||||
}
|
||||
|
||||
banUserContext.Bans.Add(banUser);
|
||||
banUserContext.SaveChanges();
|
||||
|
||||
var targetUser = banUserContext.Users.Where(u => u.Name == user.Name).FirstOrDefault();
|
||||
targetUser.BanId = banUser.Id;
|
||||
banUserContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnbanPlayer(this User user)
|
||||
{
|
||||
using (var unbanUser = new DatabaseContext())
|
||||
{
|
||||
var targetUser = unbanUser.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||
targetUser.BanId = null;
|
||||
unbanUser.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<UserItem> GetItems(this User user)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,60 @@
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using static ReallifeGamemode.Server.Types.AdminLevel;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class EnumExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt den richtigen Namen eines Admin Levels zurück
|
||||
/// </summary>
|
||||
/// <param name="level">Das Admin Level, dessen Namen man bekommen möchte.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetName(this AdminLevel level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case MAPPING:
|
||||
return "Mapper";
|
||||
case ENTWICKLUNG:
|
||||
return "Entwickler";
|
||||
case SUPPORTER:
|
||||
return "Supporter";
|
||||
case ADMIN:
|
||||
case ADMIN2:
|
||||
case ADMIN3:
|
||||
return "Admin";
|
||||
case HEADADMIN:
|
||||
return "Headadmin";
|
||||
case PROJEKTLEITUNG:
|
||||
return "Projektleiter";
|
||||
default:
|
||||
return "Spieler";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gibt den richtigen Namen eines Admin Levels zurück
|
||||
/// </summary>
|
||||
/// <param name="level">Das Admin Level, dessen Namen man bekommen möchte.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetName(this AdminLevel level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case MAPPING:
|
||||
return "Mapper";
|
||||
|
||||
public static string GetName(this GroupRank rank)
|
||||
{
|
||||
switch (rank)
|
||||
{
|
||||
case GroupRank.OWNER:
|
||||
return "Besitzer";
|
||||
case GroupRank.MANAGER:
|
||||
return "Manager";
|
||||
case GroupRank.MEMBER:
|
||||
return "Mitglied";
|
||||
default:
|
||||
return "Keiner";
|
||||
}
|
||||
case ENTWICKLUNG:
|
||||
return "Entwickler";
|
||||
|
||||
case SUPPORTER:
|
||||
return "Supporter";
|
||||
|
||||
case ADMIN:
|
||||
case ADMIN2:
|
||||
case ADMIN3:
|
||||
return "Admin";
|
||||
|
||||
case HEADADMIN:
|
||||
return "Headadmin";
|
||||
|
||||
case PROJEKTLEITUNG:
|
||||
return "Projektleiter";
|
||||
|
||||
default:
|
||||
return "Spieler";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetName(this GroupRank rank)
|
||||
{
|
||||
switch (rank)
|
||||
{
|
||||
case GroupRank.OWNER:
|
||||
return "Besitzer";
|
||||
|
||||
case GroupRank.MANAGER:
|
||||
return "Manager";
|
||||
|
||||
case GroupRank.MEMBER:
|
||||
return "Mitglied";
|
||||
|
||||
default:
|
||||
return "Keiner";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
static class HouseExtensions
|
||||
internal static class HouseExtensions
|
||||
{
|
||||
public static House Refresh(this House house)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class IntegerExtension
|
||||
{
|
||||
public static string ToMoneyString(this int? money)
|
||||
{
|
||||
return ToMoneyString(money ?? 0);
|
||||
public static string ToMoneyString(this int? money)
|
||||
{
|
||||
return ToMoneyString(money ?? 0);
|
||||
}
|
||||
|
||||
public static string ToMoneyString(this int money)
|
||||
{
|
||||
return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "").Trim();
|
||||
}
|
||||
}
|
||||
public static string ToMoneyString(this int money)
|
||||
{
|
||||
return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "").Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
static class ListExtensions
|
||||
internal static class ListExtensions
|
||||
{
|
||||
public static bool Contains(this List<Player> list, Player client)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Job;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
@@ -10,66 +7,66 @@ using ReallifeGamemode.Server.Util;
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class ServerVehicleExtensions
|
||||
{
|
||||
public static JobBase GetJob(this JobVehicle vehicle)
|
||||
{
|
||||
return JobManager.GetJob(vehicle.JobId);
|
||||
public static JobBase GetJob(this JobVehicle vehicle)
|
||||
{
|
||||
return JobManager.GetJob(vehicle.JobId);
|
||||
}
|
||||
|
||||
public static Vehicle GetVehicle(this ServerVehicle veh) => VehicleManager.GetVehicleFromServerVehicle(veh);
|
||||
|
||||
public static Vehicle Spawn(this ServerVehicle veh, Vehicle currentVeh = null)
|
||||
{
|
||||
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
|
||||
Vector3 position = veh.Position;
|
||||
uint model = (uint)veh.Model;
|
||||
float heading = veh.Heading;
|
||||
int c1 = veh.PrimaryColor;
|
||||
int c2 = veh.SecondaryColor;
|
||||
Vehicle newVeh = NAPI.Vehicle.CreateVehicle(model, position, heading, c1, c2, "", 255, false, false);
|
||||
veh.Livery = veh.Livery;
|
||||
VehicleStreaming.SetEngineState(newVeh, false);
|
||||
VehicleStreaming.SetLockStatus(newVeh, veh.Locked);
|
||||
VehicleManager.AddVehicle(veh, newVeh);
|
||||
newVeh.Rotation = new Vector3(0, 0, heading);
|
||||
|
||||
newVeh.SetSharedData("drivenDistance", veh.DistanceDriven);
|
||||
|
||||
string numberplate = $"{veh.Id}";
|
||||
|
||||
if (veh is FactionVehicle fV)
|
||||
{
|
||||
numberplate = $"F{string.Join(".", fV.GetOwners())} " + numberplate;
|
||||
}
|
||||
|
||||
if (veh is UserVehicle uV)
|
||||
{
|
||||
numberplate = $"U{uV.UserId} " + numberplate;
|
||||
}
|
||||
|
||||
if (veh is ShopVehicle sV)
|
||||
{
|
||||
numberplate = "Shop";
|
||||
VehicleStreaming.SetLockStatus(newVeh, false);
|
||||
TextLabel label = NAPI.TextLabel.CreateTextLabel("SHOPVEHICLE\n" + "~g~" + sV.Price.ToMoneyString(),
|
||||
veh.Position.Add(new Vector3(0, 0, 1.3)), 20.0f, 1f, 1, new Color(255, 255, 255));
|
||||
|
||||
newVeh.SetSharedData("shopVehicleTextLabel", label.Handle.Value);
|
||||
}
|
||||
|
||||
if (veh is GroupVehicle gV)
|
||||
{
|
||||
numberplate = $"G{gV.GroupId} " + numberplate;
|
||||
}
|
||||
|
||||
if (veh is JobVehicle jV)
|
||||
{
|
||||
numberplate = $"J{jV.JobId} " + numberplate;
|
||||
}
|
||||
NAPI.Vehicle.SetVehicleNumberPlate(newVeh, numberplate);
|
||||
veh.NumberPlate = numberplate;
|
||||
|
||||
return newVeh;
|
||||
}
|
||||
}
|
||||
|
||||
public static Vehicle GetVehicle(this ServerVehicle veh) => VehicleManager.GetVehicleFromServerVehicle(veh);
|
||||
|
||||
public static Vehicle Spawn(this ServerVehicle veh, Vehicle currentVeh = null)
|
||||
{
|
||||
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
|
||||
Vector3 position = veh.Position;
|
||||
uint model = (uint)veh.Model;
|
||||
float heading = veh.Heading;
|
||||
int c1 = veh.PrimaryColor;
|
||||
int c2 = veh.SecondaryColor;
|
||||
Vehicle newVeh = NAPI.Vehicle.CreateVehicle(model, position, heading, c1, c2, "", 255, false, false);
|
||||
veh.Livery = veh.Livery;
|
||||
VehicleStreaming.SetEngineState(newVeh, false);
|
||||
VehicleStreaming.SetLockStatus(newVeh, veh.Locked);
|
||||
VehicleManager.AddVehicle(veh, newVeh);
|
||||
newVeh.Rotation = new Vector3(0, 0, heading);
|
||||
|
||||
newVeh.SetSharedData("drivenDistance", veh.DistanceDriven);
|
||||
|
||||
string numberplate = $"{veh.Id}";
|
||||
|
||||
if (veh is FactionVehicle fV)
|
||||
{
|
||||
numberplate = $"F{string.Join(".", fV.GetOwners())} " + numberplate;
|
||||
}
|
||||
|
||||
if (veh is UserVehicle uV)
|
||||
{
|
||||
numberplate = $"U{uV.UserId} " + numberplate;
|
||||
}
|
||||
|
||||
if (veh is ShopVehicle sV)
|
||||
{
|
||||
numberplate = "Shop";
|
||||
VehicleStreaming.SetLockStatus(newVeh, false);
|
||||
TextLabel label = NAPI.TextLabel.CreateTextLabel("SHOPVEHICLE\n" + "~g~" + sV.Price.ToMoneyString(),
|
||||
veh.Position.Add(new Vector3(0, 0, 1.3)), 20.0f, 1f, 1, new Color(255, 255, 255));
|
||||
|
||||
newVeh.SetSharedData("shopVehicleTextLabel", label.Handle.Value);
|
||||
}
|
||||
|
||||
if (veh is GroupVehicle gV)
|
||||
{
|
||||
numberplate = $"G{gV.GroupId} " + numberplate;
|
||||
}
|
||||
|
||||
if (veh is JobVehicle jV)
|
||||
{
|
||||
numberplate = $"J{jV.JobId} " + numberplate;
|
||||
}
|
||||
NAPI.Vehicle.SetVehicleNumberPlate(newVeh, numberplate);
|
||||
veh.NumberPlate = numberplate;
|
||||
|
||||
return newVeh;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class VehicleExtension
|
||||
{
|
||||
public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null)
|
||||
{
|
||||
return VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||
}
|
||||
public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null)
|
||||
{
|
||||
return VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||
}
|
||||
|
||||
public static Player GetDriver(this Vehicle veh)
|
||||
{
|
||||
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault();
|
||||
public static Player GetDriver(this Vehicle veh)
|
||||
{
|
||||
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Server Factions Medic Medic.cs
|
||||
@@ -11,87 +8,96 @@ using ReallifeGamemode.Server.Services;
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
|
||||
namespace ReallifeGamemode.Server.Factions.Medic
|
||||
{
|
||||
public class Medic : Script
|
||||
{
|
||||
public static List<MedicTask> ReviveTasks = new List<MedicTask>();
|
||||
public static List<MedicTask> HealTasks = new List<MedicTask>();
|
||||
public static List<MedicTask> FireTasks = new List<MedicTask>();
|
||||
|
||||
public static void AddTaskToList(MedicTask task)
|
||||
{
|
||||
if (task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public static List<MedicTask> ReviveTasks = new List<MedicTask>();
|
||||
public static List<MedicTask> HealTasks = new List<MedicTask>();
|
||||
public static List<MedicTask> FireTasks = new List<MedicTask>();
|
||||
|
||||
switch (task.Type)
|
||||
{
|
||||
case MedicTaskType.REVIVE:
|
||||
ReviveTasks.Add(task);
|
||||
break;
|
||||
case MedicTaskType.HEAL:
|
||||
HealTasks.Add(task);
|
||||
break;
|
||||
case MedicTaskType.FIRE:
|
||||
FireTasks.Add(task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static void AddTaskToList(MedicTask task)
|
||||
{
|
||||
if (task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public static void RemoveTaskFromList(MedicTask task)
|
||||
{
|
||||
if (task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (task.Type)
|
||||
{
|
||||
case MedicTaskType.REVIVE:
|
||||
ReviveTasks.Add(task);
|
||||
break;
|
||||
|
||||
switch (task.Type)
|
||||
{
|
||||
case MedicTaskType.REVIVE:
|
||||
ReviveTasks.Remove(task);
|
||||
break;
|
||||
case MedicTaskType.HEAL:
|
||||
HealTasks.Remove(task);
|
||||
break;
|
||||
case MedicTaskType.FIRE:
|
||||
FireTasks.Remove(task);
|
||||
break;
|
||||
}
|
||||
case MedicTaskType.HEAL:
|
||||
HealTasks.Add(task);
|
||||
break;
|
||||
|
||||
case MedicTaskType.FIRE:
|
||||
FireTasks.Add(task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveTaskFromList(MedicTask task)
|
||||
{
|
||||
if (task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (task.Type)
|
||||
{
|
||||
case MedicTaskType.REVIVE:
|
||||
ReviveTasks.Remove(task);
|
||||
break;
|
||||
|
||||
case MedicTaskType.HEAL:
|
||||
HealTasks.Remove(task);
|
||||
break;
|
||||
|
||||
case MedicTaskType.FIRE:
|
||||
FireTasks.Remove(task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("loadMedicTasks")]
|
||||
public void LoadMedicTasks(Player player, int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("updateMedicTask")]
|
||||
public void UpdateMedicTasks(Player player, int type, int index, string medicName)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
ReviveTasks[index].MedicName = medicName;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
HealTasks[index].MedicName = medicName;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
FireTasks[index].MedicName = medicName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
[RemoteEvent("loadMedicTasks")]
|
||||
public void LoadMedicTasks(Player player, int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks));
|
||||
break;
|
||||
case 1:
|
||||
player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks));
|
||||
break;
|
||||
case 2:
|
||||
player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks));
|
||||
break;
|
||||
}
|
||||
}
|
||||
[RemoteEvent("updateMedicTask")]
|
||||
public void UpdateMedicTasks(Player player, int type, int index, string medicName)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
ReviveTasks[index].MedicName = medicName;
|
||||
break;
|
||||
case 1:
|
||||
HealTasks[index].MedicName = medicName;
|
||||
break;
|
||||
case 2:
|
||||
FireTasks[index].MedicName = medicName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
|
||||
/**
|
||||
@@ -9,25 +7,24 @@ using GTANetworkAPI;
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
|
||||
namespace ReallifeGamemode.Server.Factions.Medic
|
||||
{
|
||||
public class MedicTask
|
||||
{
|
||||
public string Victim { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
public MedicTaskType Type { get; set; }
|
||||
public string CauseOfDeath { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Caller { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
public string MedicName { get; set; }
|
||||
}
|
||||
{
|
||||
public string Victim { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
public MedicTaskType Type { get; set; }
|
||||
public string CauseOfDeath { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Caller { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
public string MedicName { get; set; }
|
||||
}
|
||||
|
||||
public enum MedicTaskType
|
||||
{
|
||||
REVIVE,
|
||||
HEAL,
|
||||
FIRE
|
||||
}
|
||||
public enum MedicTaskType
|
||||
{
|
||||
REVIVE,
|
||||
HEAL,
|
||||
FIRE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +1,81 @@
|
||||
/***
|
||||
@overview Life of German - Economy
|
||||
/***
|
||||
@overview Life of German - Economy
|
||||
@author kookroach
|
||||
@copyright (c) 2008 - 2019 Life of German
|
||||
@copyright (c) 2008 - 2019 Life of German
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Finance
|
||||
{
|
||||
public class Economy
|
||||
{
|
||||
public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>();
|
||||
|
||||
public static (int, float, float) GetEconomyClass(Player client, int wage)
|
||||
{
|
||||
int bankAccount = client.GetUser().BankAccount.Balance;
|
||||
float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000;
|
||||
float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1;
|
||||
if (financialInterest >= 0.7)
|
||||
financialInterest = 0.7f;
|
||||
public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>();
|
||||
|
||||
if (financialHelp > 2500)
|
||||
financialHelp = 2500;
|
||||
|
||||
return (bankAccount, financialHelp, financialInterest);
|
||||
}
|
||||
|
||||
public static int GetVehicleTaxation(Player client)
|
||||
{
|
||||
int vehicleTaxation = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser(dbContext);
|
||||
foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id))
|
||||
public static (int, float, float) GetEconomyClass(Player client, int wage)
|
||||
{
|
||||
if (uVeh.Price == null)
|
||||
{
|
||||
vehicleTaxation += 400;
|
||||
continue;
|
||||
}
|
||||
vehicleTaxation += (int)(uVeh.Price * 0.005f);
|
||||
int bankAccount = client.GetUser().BankAccount.Balance;
|
||||
float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000;
|
||||
float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1;
|
||||
if (financialInterest >= 0.7)
|
||||
financialInterest = 0.7f;
|
||||
|
||||
if (financialHelp > 2500)
|
||||
financialHelp = 2500;
|
||||
|
||||
return (bankAccount, financialHelp, financialInterest);
|
||||
}
|
||||
|
||||
}
|
||||
return vehicleTaxation;
|
||||
}
|
||||
public static int GetVehicleTaxation(Player client)
|
||||
{
|
||||
int vehicleTaxation = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser(dbContext);
|
||||
foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id))
|
||||
{
|
||||
if (uVeh.Price == null)
|
||||
{
|
||||
vehicleTaxation += 400;
|
||||
continue;
|
||||
}
|
||||
vehicleTaxation += (int)(uVeh.Price * 0.005f);
|
||||
}
|
||||
}
|
||||
return vehicleTaxation;
|
||||
}
|
||||
|
||||
public static float GetPropertyTaxation(Player client)
|
||||
{
|
||||
float propertyTaxation = 0;
|
||||
User user = client.GetUser();
|
||||
if (user.HouseId != null)
|
||||
{
|
||||
propertyTaxation += user.House.Price * 0.005f;
|
||||
}
|
||||
public static float GetPropertyTaxation(Player client)
|
||||
{
|
||||
float propertyTaxation = 0;
|
||||
User user = client.GetUser();
|
||||
if (user.HouseId != null)
|
||||
{
|
||||
propertyTaxation += user.House.Price * 0.005f;
|
||||
}
|
||||
|
||||
return propertyTaxation;
|
||||
}
|
||||
return propertyTaxation;
|
||||
}
|
||||
|
||||
public static void SetPaycheck(Player client)
|
||||
{
|
||||
User user = client.GetUser();
|
||||
int wage = user.Wage;
|
||||
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
||||
float propertyTax = GetPropertyTaxation(client);
|
||||
int vehicleTaxation = GetVehicleTaxation(client);
|
||||
int rentalFees = GetRentalFees(client);
|
||||
|
||||
public static void SetPaycheck(Player client)
|
||||
{
|
||||
User user = client.GetUser();
|
||||
int wage = user.Wage;
|
||||
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
||||
float propertyTax = GetPropertyTaxation(client);
|
||||
int vehicleTaxation = GetVehicleTaxation(client);
|
||||
int rentalFees = GetRentalFees(client);
|
||||
|
||||
int healthInsurance = (int)(user.BankAccount.Balance * 0.001);
|
||||
|
||||
int healthInsurance = (int)(user.BankAccount.Balance * 0.001);
|
||||
|
||||
int? factionMoney = null;
|
||||
|
||||
@@ -96,88 +91,85 @@ namespace ReallifeGamemode.Server.Finance
|
||||
ReleasePayDay(client, paycheck);
|
||||
}
|
||||
|
||||
private static int GetRentalFees(Player client)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser();
|
||||
return dbContext.HouseRentals.Where(h => h.UserId == user.Id).Include(h => h.House).Sum(h => h.House.RentalFee);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReleasePayDay(Player client, Paycheck paycheck)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("in release payday");
|
||||
if (client == null || paycheck == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NAPI.Util.ConsoleOutput($"client = {client.Name}, paycheck = {JsonConvert.SerializeObject(paycheck)}");
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = client.GetUser(dbContext);
|
||||
NAPI.Util.ConsoleOutput("get user");
|
||||
u.BankAccount.Balance += paycheck.Amount;
|
||||
u.Wage = 0;
|
||||
|
||||
u.PaydayTimer = 60;
|
||||
|
||||
|
||||
NAPI.Util.ConsoleOutput("set sachen");
|
||||
|
||||
var rentals = dbContext.HouseRentals
|
||||
.Include(hR => hR.House)
|
||||
.ThenInclude(h => h.BankAccount)
|
||||
.Where(hR => hR.UserId == u.Id);
|
||||
|
||||
|
||||
NAPI.Util.ConsoleOutput("get rentals");
|
||||
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
||||
|
||||
if (rentals.Any())
|
||||
private static int GetRentalFees(Player client)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("hat rentals");
|
||||
foreach (var rental in rentals)
|
||||
{
|
||||
if (rental?.House?.BankAccount != null)
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
||||
User user = client.GetUser();
|
||||
return dbContext.HouseRentals.Where(h => h.UserId == user.Id).Include(h => h.House).Sum(h => h.House.RentalFee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
if (paycheck.Amount > 0)
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
||||
else
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
||||
|
||||
}
|
||||
|
||||
public static void Timer_Elapsed()
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
if (player.IsLoggedIn())
|
||||
public static void ReleasePayDay(Player client, Paycheck paycheck)
|
||||
{
|
||||
if (user.PaydayTimer <= 0)
|
||||
{
|
||||
Economy.SetPaycheck(player);
|
||||
user.PaydayTimer = 60;
|
||||
}
|
||||
else if (user.PaydayTimer > 0)
|
||||
{
|
||||
user.PaydayTimer -= 1;
|
||||
}
|
||||
NAPI.Util.ConsoleOutput("in release payday");
|
||||
if (client == null || paycheck == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NAPI.Util.ConsoleOutput($"client = {client.Name}, paycheck = {JsonConvert.SerializeObject(paycheck)}");
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = client.GetUser(dbContext);
|
||||
NAPI.Util.ConsoleOutput("get user");
|
||||
u.BankAccount.Balance += paycheck.Amount;
|
||||
u.Wage = 0;
|
||||
|
||||
u.PaydayTimer = 60;
|
||||
|
||||
NAPI.Util.ConsoleOutput("set sachen");
|
||||
|
||||
var rentals = dbContext.HouseRentals
|
||||
.Include(hR => hR.House)
|
||||
.ThenInclude(h => h.BankAccount)
|
||||
.Where(hR => hR.UserId == u.Id);
|
||||
|
||||
NAPI.Util.ConsoleOutput("get rentals");
|
||||
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
||||
|
||||
if (rentals.Any())
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("hat rentals");
|
||||
foreach (var rental in rentals)
|
||||
{
|
||||
if (rental?.House?.BankAccount != null)
|
||||
{
|
||||
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
if (paycheck.Amount > 0)
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
||||
else
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
||||
}
|
||||
|
||||
public static void Timer_Elapsed()
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
if (player.IsLoggedIn())
|
||||
{
|
||||
if (user.PaydayTimer <= 0)
|
||||
{
|
||||
Economy.SetPaycheck(player);
|
||||
user.PaydayTimer = 60;
|
||||
}
|
||||
else if (user.PaydayTimer > 0)
|
||||
{
|
||||
user.PaydayTimer -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ReallifeGamemode.Server.Finance
|
||||
{
|
||||
public class Paycheck
|
||||
{
|
||||
[JsonProperty("financialHelp")]
|
||||
public float FinancialHelp { get; set; } = 0;
|
||||
{
|
||||
[JsonProperty("financialHelp")]
|
||||
public float FinancialHelp { get; set; } = 0;
|
||||
|
||||
[JsonProperty("financialInterest")]
|
||||
public float FinancialInterest { get; set; } = 0;
|
||||
[JsonProperty("financialInterest")]
|
||||
public float FinancialInterest { get; set; } = 0;
|
||||
|
||||
[JsonProperty("vehicleTaxation")]
|
||||
public int VehicleTaxation { get; set; } = 0;
|
||||
[JsonProperty("vehicleTaxation")]
|
||||
public int VehicleTaxation { get; set; } = 0;
|
||||
|
||||
[JsonProperty("propertyTaxation")]
|
||||
public float PropertyTaxation { get; set; } = 0;
|
||||
[JsonProperty("propertyTaxation")]
|
||||
public float PropertyTaxation { get; set; } = 0;
|
||||
|
||||
[JsonProperty("wage")]
|
||||
public int Wage { get; set; } = 0;
|
||||
[JsonProperty("wage")]
|
||||
public int Wage { get; set; } = 0;
|
||||
|
||||
[JsonProperty("amount")]
|
||||
public int Amount { get; set; } = 0;
|
||||
[JsonProperty("amount")]
|
||||
public int Amount { get; set; } = 0;
|
||||
|
||||
[JsonProperty("rentalFees")]
|
||||
public int RentalFees { get; set; } = 0;
|
||||
[JsonProperty("rentalFees")]
|
||||
public int RentalFees { get; set; } = 0;
|
||||
|
||||
[JsonProperty("healthInsurance")]
|
||||
public int HealthInsurance { get; set; } = 0;
|
||||
[JsonProperty("healthInsurance")]
|
||||
public int HealthInsurance { get; set; } = 0;
|
||||
|
||||
[JsonProperty("factionMoney")]
|
||||
public int? FactionMoney { get; set; } = 0;
|
||||
@@ -53,4 +44,4 @@ namespace ReallifeGamemode.Server.Finance
|
||||
this.FactionMoney = FactionMoney;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
@@ -11,217 +10,217 @@ using ReallifeGamemode.Server.Services;
|
||||
namespace ReallifeGamemode.Server.Gangwar
|
||||
{
|
||||
public class Gangwar : Script
|
||||
{
|
||||
public static Turf[] _loadedTurfs;
|
||||
private static List<Turfs> turfs;
|
||||
|
||||
public static void loadTurfs()
|
||||
{
|
||||
_loadedTurfs = null;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
turfs = context.Turfs.Select(t => t).ToList();
|
||||
List<Turf> turfing = new List<Turf>();
|
||||
foreach (var t in turfs)
|
||||
public static Turf[] _loadedTurfs;
|
||||
private static List<Turfs> turfs;
|
||||
|
||||
public static void loadTurfs()
|
||||
{
|
||||
Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus);
|
||||
turfing.Add(newTurf);
|
||||
}
|
||||
_loadedTurfs = turfing.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadPlayer(Player client)
|
||||
{
|
||||
client.TriggerEvent("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||
}
|
||||
|
||||
public static void loadTurfs_ToAllPlayers()
|
||||
{
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||
foreach (var l in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
if (!l.IsLoggedIn() && !l.GetUser().FactionLeader)
|
||||
return;
|
||||
|
||||
l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
}
|
||||
}
|
||||
|
||||
public static void GangwarKill(Player killer, Player victim)
|
||||
{
|
||||
if (killer.HasData("GotInsideOfTurf") && victim.HasData("GotInsideOfTurf"))
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == victim.GetData<int>("inGangWar"))
|
||||
{
|
||||
turf.setKill(victim.GetUser().Faction.Name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Turf[] getTurfs()
|
||||
{
|
||||
return _loadedTurfs;
|
||||
}
|
||||
|
||||
[RemoteEvent("Gangarea:Enter")]
|
||||
public void RmtEvent_TurfEnter(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == id)
|
||||
{
|
||||
turf.enter(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("Gangarea:Leave")]
|
||||
public void RmtEvent_TurfLeave(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == id)
|
||||
{
|
||||
turf.leave(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:SetTurf")]
|
||||
public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name)
|
||||
{
|
||||
float pX = JsonConvert.DeserializeObject<float>(jsonX);
|
||||
float pY = (float)JsonConvert.DeserializeObject<float>(jsonY);
|
||||
float Rot = (float)JsonConvert.DeserializeObject<float>(jsonRot);
|
||||
float Range = (float)JsonConvert.DeserializeObject<float>(jsonRange);
|
||||
|
||||
var newTurf = new Turfs
|
||||
{
|
||||
Name = Name,
|
||||
X = pX,
|
||||
Y = pY,
|
||||
Rotation = Rot,
|
||||
Range = Range,
|
||||
Owner = "Neutral",
|
||||
Color = 0,
|
||||
Vector = null
|
||||
};
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
dbContext.Turfs.Add(newTurf);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:DeleteTurf")]
|
||||
public void RmtEvent_DeleteTurf(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
if (id == -1)
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet!");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
||||
if (dturf != null)
|
||||
{
|
||||
dbContext.Turfs.Remove(dturf);
|
||||
dbContext.SaveChanges();
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
|
||||
public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
if (id == -1)
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
||||
if (dturf != null)
|
||||
{
|
||||
dturf.Vector = vector;
|
||||
dbContext.SaveChanges();
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:StartGangwar")]
|
||||
public void RmtEvent_StartGangwar(Player client)
|
||||
{
|
||||
if (!client.GetUser().FactionLeader)
|
||||
return;
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.status == "attack")
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (client.GetUser().Faction.Name == "Ballas" || client.GetUser().Faction.Name == "Grove")
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
foreach (var u in turf.playerInside)
|
||||
{
|
||||
if (u == client)
|
||||
_loadedTurfs = null;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
if (turf.Owner != client.GetUser().Faction.Name)
|
||||
turf.attack(client.GetUser().Faction.Name);
|
||||
turfs = context.Turfs.Select(t => t).ToList();
|
||||
List<Turf> turfing = new List<Turf>();
|
||||
foreach (var t in turfs)
|
||||
{
|
||||
Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus);
|
||||
turfing.Add(newTurf);
|
||||
}
|
||||
_loadedTurfs = turfing.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Value_TimerElapsed()
|
||||
{
|
||||
List<int> values = new List<int>();
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
public static void loadPlayer(Player client)
|
||||
{
|
||||
if((turf.getValue() + 5) >= turf.getMaxValue())
|
||||
{
|
||||
turf.setValue(turf.getMaxValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
turf.addValue(5);
|
||||
}
|
||||
values.Add(turf.getValue());
|
||||
Turfs _turf = dbContext.Turfs.Where(t => t.Id == turf.getId()).FirstOrDefault();
|
||||
_turf.Value = turf.getValue();
|
||||
client.TriggerEvent("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||
}
|
||||
|
||||
public static void loadTurfs_ToAllPlayers()
|
||||
{
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||
foreach (var l in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
if (!l.IsLoggedIn() && !l.GetUser().FactionLeader)
|
||||
return;
|
||||
|
||||
l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
}
|
||||
}
|
||||
|
||||
public static void GangwarKill(Player killer, Player victim)
|
||||
{
|
||||
if (killer.HasData("GotInsideOfTurf") && victim.HasData("GotInsideOfTurf"))
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == victim.GetData<int>("inGangWar"))
|
||||
{
|
||||
turf.setKill(victim.GetUser().Faction.Name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Turf[] getTurfs()
|
||||
{
|
||||
return _loadedTurfs;
|
||||
}
|
||||
|
||||
[RemoteEvent("Gangarea:Enter")]
|
||||
public void RmtEvent_TurfEnter(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == id)
|
||||
{
|
||||
turf.enter(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("Gangarea:Leave")]
|
||||
public void RmtEvent_TurfLeave(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == id)
|
||||
{
|
||||
turf.leave(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:SetTurf")]
|
||||
public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name)
|
||||
{
|
||||
float pX = JsonConvert.DeserializeObject<float>(jsonX);
|
||||
float pY = (float)JsonConvert.DeserializeObject<float>(jsonY);
|
||||
float Rot = (float)JsonConvert.DeserializeObject<float>(jsonRot);
|
||||
float Range = (float)JsonConvert.DeserializeObject<float>(jsonRange);
|
||||
|
||||
var newTurf = new Turfs
|
||||
{
|
||||
Name = Name,
|
||||
X = pX,
|
||||
Y = pY,
|
||||
Rotation = Rot,
|
||||
Range = Range,
|
||||
Owner = "Neutral",
|
||||
Color = 0,
|
||||
Vector = null
|
||||
};
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
dbContext.Turfs.Add(newTurf);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:DeleteTurf")]
|
||||
public void RmtEvent_DeleteTurf(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
if (id == -1)
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet!");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
||||
if (dturf != null)
|
||||
{
|
||||
dbContext.Turfs.Remove(dturf);
|
||||
dbContext.SaveChanges();
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
|
||||
public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
if (id == -1)
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
||||
if (dturf != null)
|
||||
{
|
||||
dturf.Vector = vector;
|
||||
dbContext.SaveChanges();
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:StartGangwar")]
|
||||
public void RmtEvent_StartGangwar(Player client)
|
||||
{
|
||||
if (!client.GetUser().FactionLeader)
|
||||
return;
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.status == "attack")
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (client.GetUser().Faction.Name == "Ballas" || client.GetUser().Faction.Name == "Grove")
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
foreach (var u in turf.playerInside)
|
||||
{
|
||||
if (u == client)
|
||||
{
|
||||
if (turf.Owner != client.GetUser().Faction.Name)
|
||||
turf.attack(client.GetUser().Faction.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Value_TimerElapsed()
|
||||
{
|
||||
List<int> values = new List<int>();
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if ((turf.getValue() + 5) >= turf.getMaxValue())
|
||||
{
|
||||
turf.setValue(turf.getMaxValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
turf.addValue(5);
|
||||
}
|
||||
values.Add(turf.getValue());
|
||||
Turfs _turf = dbContext.Turfs.Where(t => t.Id == turf.getId()).FirstOrDefault();
|
||||
_turf.Value = turf.getValue();
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray()));
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,356 +1,352 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using System.Timers;
|
||||
using System.Linq;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System.Timers;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Gangwar
|
||||
{
|
||||
public class Turf
|
||||
{
|
||||
|
||||
public int TurfID { get; set; }
|
||||
public string TurfName { get; set; }
|
||||
public int Color { get; set; }
|
||||
public string Owner { get; set; }
|
||||
public string Attacker { get; set; }
|
||||
public int Att_Score { get; set; }
|
||||
public int Def_Score { get; set; }
|
||||
public string status { get; set; }
|
||||
public int value { get; set; }
|
||||
public int maxValue { get; set; }
|
||||
public bool surplus { get; set; }
|
||||
public List<Player> playerInside { get; set; }
|
||||
public Timer timer { get; set; }
|
||||
public Player[] playerInGangwar { get; set; }
|
||||
public int timerCount;
|
||||
|
||||
|
||||
public Turf(int TurfID, string TurfName, int color, string Owner, int value, int maxValue,bool surplus)
|
||||
{
|
||||
this.TurfID = TurfID;
|
||||
this.TurfName = TurfName;
|
||||
this.Color = color;
|
||||
this.Owner = Owner;
|
||||
this.value = value;
|
||||
this.maxValue = maxValue;
|
||||
this.surplus = surplus;
|
||||
this.Attacker = null;
|
||||
this.Att_Score = 50;
|
||||
this.Def_Score = 50;
|
||||
this.status = "normal";
|
||||
this.timer = null;
|
||||
this.playerInside = new List<Player>();
|
||||
this.timerCount = 0;
|
||||
}
|
||||
public int TurfID { get; set; }
|
||||
public string TurfName { get; set; }
|
||||
public int Color { get; set; }
|
||||
public string Owner { get; set; }
|
||||
public string Attacker { get; set; }
|
||||
public int Att_Score { get; set; }
|
||||
public int Def_Score { get; set; }
|
||||
public string status { get; set; }
|
||||
public int value { get; set; }
|
||||
public int maxValue { get; set; }
|
||||
public bool surplus { get; set; }
|
||||
public List<Player> playerInside { get; set; }
|
||||
public Timer timer { get; set; }
|
||||
public Player[] playerInGangwar { get; set; }
|
||||
public int timerCount;
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.TurfID;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void addValue(int addedValue)
|
||||
{
|
||||
this.value += addedValue;
|
||||
}
|
||||
|
||||
public int getMaxValue()
|
||||
{
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
public bool getSurplus()
|
||||
{
|
||||
return surplus;
|
||||
}
|
||||
|
||||
public void setSurplus(bool surplus)
|
||||
{
|
||||
this.surplus = surplus;
|
||||
}
|
||||
|
||||
public string getName()
|
||||
{
|
||||
return this.TurfName;
|
||||
}
|
||||
|
||||
public int getColor()
|
||||
{
|
||||
return this.Color;
|
||||
}
|
||||
|
||||
public string getOwner()
|
||||
{
|
||||
return this.Owner;
|
||||
}
|
||||
|
||||
public string getAttacker()
|
||||
{
|
||||
return this.Attacker;
|
||||
}
|
||||
|
||||
private void TurfTick()
|
||||
{
|
||||
this.timer = new System.Timers.Timer(1000);
|
||||
|
||||
this.timer.Elapsed += Tick;
|
||||
this.timer.AutoReset = true;
|
||||
this.timer.Enabled = true;
|
||||
this.timerCount = 0;
|
||||
}
|
||||
|
||||
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (this.status == "attack")
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void update()
|
||||
{
|
||||
#region Ticket system
|
||||
/*
|
||||
try
|
||||
{
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
}catch(NullReferenceException ex)
|
||||
{
|
||||
int i = 0;
|
||||
foreach(var c in playerInGangwar)
|
||||
public Turf(int TurfID, string TurfName, int color, string Owner, int value, int maxValue, bool surplus)
|
||||
{
|
||||
if (!NAPI.Entity.DoesEntityExist(c.Handle))
|
||||
{
|
||||
this.playerInside = this.playerInside.Where(gp => gp != c).ToArray();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (owners.Length > attackers.Length)
|
||||
this.Att_Score -= owners.Length - attackers.Length;
|
||||
if(owners.Length < attackers.Length)
|
||||
this.Def_Score -= attackers.Length - owners.Length;
|
||||
*/
|
||||
#endregion
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||
}
|
||||
if (this.Def_Score <= 0)
|
||||
{
|
||||
this.takeOver(this.Attacker);
|
||||
}
|
||||
else if (this.Att_Score <= 0)
|
||||
{
|
||||
this.takeOver(this.Owner);
|
||||
}
|
||||
timerCount += 1;
|
||||
if (timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like
|
||||
{
|
||||
if (this.Def_Score > this.Att_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Owner);
|
||||
this.Att_Score = 0;
|
||||
}
|
||||
else if (this.Def_Score < this.Att_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Attacker);
|
||||
this.Def_Score = 0;
|
||||
return;
|
||||
}
|
||||
else if (this.Def_Score == this.Att_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Attacker);
|
||||
this.Def_Score = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enter(Player client)
|
||||
{
|
||||
if (this.status == "attack")
|
||||
{
|
||||
if (client.GetUser().Faction.Name != getOwner() && client.GetUser().Faction.Name != getAttacker())
|
||||
return;
|
||||
Player gPlayer = playerInGangwar.Where(c => c.GetUser().Id == client.GetUser().Id).FirstOrDefault();
|
||||
if (gPlayer == null)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerInside.Find(c => c == client) == null)
|
||||
{
|
||||
playerInside.Add(client);
|
||||
client.SetData("GotInsideOfTurf", true);
|
||||
}
|
||||
}
|
||||
|
||||
public void leave(Player client)
|
||||
{
|
||||
if (playerInside.Find(c => c == client) != null)
|
||||
{
|
||||
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
||||
if (this.status != "attack")
|
||||
client.ResetData("GotInsideOfTurf");
|
||||
}
|
||||
}
|
||||
|
||||
public void takeOver(string FactionName)
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer = null;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (getOwner() == FactionName)
|
||||
{
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
foreach (var o in owners)
|
||||
{
|
||||
o.TriggerEvent("CLIENT:win");
|
||||
}
|
||||
foreach (var a in attackers)
|
||||
{
|
||||
a.TriggerEvent("CLIENT:loose");
|
||||
}
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||
}
|
||||
else if (getOwner() != FactionName)
|
||||
{
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
foreach (var o in owners)
|
||||
{
|
||||
o.TriggerEvent("CLIENT:loose");
|
||||
}
|
||||
foreach (var a in attackers)
|
||||
{
|
||||
a.TriggerEvent("CLIENT:win");
|
||||
}
|
||||
this.Owner = FactionName;
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
|
||||
turf.Owner = this.Owner;
|
||||
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
||||
dbContext.SaveChanges();
|
||||
this.TurfID = TurfID;
|
||||
this.TurfName = TurfName;
|
||||
this.Color = color;
|
||||
this.Owner = Owner;
|
||||
this.value = value;
|
||||
this.maxValue = maxValue;
|
||||
this.surplus = surplus;
|
||||
this.Attacker = null;
|
||||
this.Att_Score = 50;
|
||||
this.Def_Score = 50;
|
||||
this.status = "normal";
|
||||
this.timer = null;
|
||||
this.playerInside = new List<Player>();
|
||||
this.timerCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
this.Attacker = null;
|
||||
foreach (var c in playerInGangwar)
|
||||
{
|
||||
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
||||
c.ResetData("inGangWar");
|
||||
c.ResetData("GotInsideOfTurf");
|
||||
}
|
||||
this.playerInGangwar = null;
|
||||
Gangwar.loadTurfs();
|
||||
Gangwar.loadTurfs_ToAllPlayers();
|
||||
}
|
||||
|
||||
public void attack(string attacker)
|
||||
{
|
||||
Player[] usersInGangwar;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name);
|
||||
|
||||
List<Player> ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList();
|
||||
List<Player> attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker).Select(u => u.Player).ToList();
|
||||
|
||||
if (ownersInGangwar.Count < 1 && attackersInGangwar.Count < 1)
|
||||
public int getId()
|
||||
{
|
||||
List<Player> leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker && u.FactionLeader).Select(u => u.Player).ToList();
|
||||
foreach(var l in leaders)
|
||||
{
|
||||
ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder aufweisen.");
|
||||
}
|
||||
|
||||
return;
|
||||
return this.TurfID;
|
||||
}
|
||||
List<Player> inGangwar = new List<Player>(ownersInGangwar.Concat(attackersInGangwar));
|
||||
|
||||
|
||||
usersInGangwar = inGangwar.ToArray();
|
||||
}
|
||||
if (this.status == "normal")
|
||||
{
|
||||
if (this.timer != null)
|
||||
public int getValue()
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer = null;
|
||||
return this.value;
|
||||
}
|
||||
this.Attacker = attacker;
|
||||
this.status = "attack";
|
||||
|
||||
List<Player> clientsInGangwar = new List<Player>();
|
||||
|
||||
foreach (var u in usersInGangwar)
|
||||
public void setValue(int value)
|
||||
{
|
||||
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
||||
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||
u.SetData("inGangWar", getId());
|
||||
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen.");
|
||||
clientsInGangwar.Add(u);
|
||||
this.value = value;
|
||||
}
|
||||
playerInGangwar = clientsInGangwar.ToArray();
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker));
|
||||
this.TurfTick();
|
||||
}
|
||||
}
|
||||
|
||||
public void setKill(string FactionName)
|
||||
{
|
||||
if (getOwner() == FactionName)
|
||||
{
|
||||
Def_Score -= 1;
|
||||
}
|
||||
else if (getAttacker() == FactionName)
|
||||
{
|
||||
Att_Score -= 1;
|
||||
}
|
||||
public void addValue(int addedValue)
|
||||
{
|
||||
this.value += addedValue;
|
||||
}
|
||||
|
||||
public int getMaxValue()
|
||||
{
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
public bool getSurplus()
|
||||
{
|
||||
return surplus;
|
||||
}
|
||||
|
||||
public void setSurplus(bool surplus)
|
||||
{
|
||||
this.surplus = surplus;
|
||||
}
|
||||
|
||||
public string getName()
|
||||
{
|
||||
return this.TurfName;
|
||||
}
|
||||
|
||||
public int getColor()
|
||||
{
|
||||
return this.Color;
|
||||
}
|
||||
|
||||
public string getOwner()
|
||||
{
|
||||
return this.Owner;
|
||||
}
|
||||
|
||||
public string getAttacker()
|
||||
{
|
||||
return this.Attacker;
|
||||
}
|
||||
|
||||
private void TurfTick()
|
||||
{
|
||||
this.timer = new System.Timers.Timer(1000);
|
||||
|
||||
this.timer.Elapsed += Tick;
|
||||
this.timer.AutoReset = true;
|
||||
this.timer.Enabled = true;
|
||||
this.timerCount = 0;
|
||||
}
|
||||
|
||||
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (this.status == "attack")
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
private void update()
|
||||
{
|
||||
#region Ticket system
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
}catch(NullReferenceException ex)
|
||||
{
|
||||
int i = 0;
|
||||
foreach(var c in playerInGangwar)
|
||||
{
|
||||
if (!NAPI.Entity.DoesEntityExist(c.Handle))
|
||||
{
|
||||
this.playerInside = this.playerInside.Where(gp => gp != c).ToArray();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (owners.Length > attackers.Length)
|
||||
this.Att_Score -= owners.Length - attackers.Length;
|
||||
if(owners.Length < attackers.Length)
|
||||
this.Def_Score -= attackers.Length - owners.Length;
|
||||
*/
|
||||
|
||||
#endregion Ticket system
|
||||
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||
}
|
||||
if (this.Def_Score <= 0)
|
||||
{
|
||||
this.takeOver(this.Attacker);
|
||||
}
|
||||
else if (this.Att_Score <= 0)
|
||||
{
|
||||
this.takeOver(this.Owner);
|
||||
}
|
||||
timerCount += 1;
|
||||
if (timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like
|
||||
{
|
||||
if (this.Def_Score > this.Att_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Owner);
|
||||
this.Att_Score = 0;
|
||||
}
|
||||
else if (this.Def_Score < this.Att_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Attacker);
|
||||
this.Def_Score = 0;
|
||||
return;
|
||||
}
|
||||
else if (this.Def_Score == this.Att_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Attacker);
|
||||
this.Def_Score = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enter(Player client)
|
||||
{
|
||||
if (this.status == "attack")
|
||||
{
|
||||
if (client.GetUser().Faction.Name != getOwner() && client.GetUser().Faction.Name != getAttacker())
|
||||
return;
|
||||
Player gPlayer = playerInGangwar.Where(c => c.GetUser().Id == client.GetUser().Id).FirstOrDefault();
|
||||
if (gPlayer == null)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerInside.Find(c => c == client) == null)
|
||||
{
|
||||
playerInside.Add(client);
|
||||
client.SetData("GotInsideOfTurf", true);
|
||||
}
|
||||
}
|
||||
|
||||
public void leave(Player client)
|
||||
{
|
||||
if (playerInside.Find(c => c == client) != null)
|
||||
{
|
||||
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
||||
if (this.status != "attack")
|
||||
client.ResetData("GotInsideOfTurf");
|
||||
}
|
||||
}
|
||||
|
||||
public void takeOver(string FactionName)
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer = null;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (getOwner() == FactionName)
|
||||
{
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
foreach (var o in owners)
|
||||
{
|
||||
o.TriggerEvent("CLIENT:win");
|
||||
}
|
||||
foreach (var a in attackers)
|
||||
{
|
||||
a.TriggerEvent("CLIENT:loose");
|
||||
}
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||
}
|
||||
else if (getOwner() != FactionName)
|
||||
{
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
foreach (var o in owners)
|
||||
{
|
||||
o.TriggerEvent("CLIENT:loose");
|
||||
}
|
||||
foreach (var a in attackers)
|
||||
{
|
||||
a.TriggerEvent("CLIENT:win");
|
||||
}
|
||||
this.Owner = FactionName;
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
|
||||
turf.Owner = this.Owner;
|
||||
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
this.Attacker = null;
|
||||
foreach (var c in playerInGangwar)
|
||||
{
|
||||
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
||||
c.ResetData("inGangWar");
|
||||
c.ResetData("GotInsideOfTurf");
|
||||
}
|
||||
this.playerInGangwar = null;
|
||||
Gangwar.loadTurfs();
|
||||
Gangwar.loadTurfs_ToAllPlayers();
|
||||
}
|
||||
|
||||
public void attack(string attacker)
|
||||
{
|
||||
Player[] usersInGangwar;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name);
|
||||
|
||||
List<Player> ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList();
|
||||
List<Player> attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker).Select(u => u.Player).ToList();
|
||||
|
||||
if (ownersInGangwar.Count < 1 && attackersInGangwar.Count < 1)
|
||||
{
|
||||
List<Player> leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker && u.FactionLeader).Select(u => u.Player).ToList();
|
||||
foreach (var l in leaders)
|
||||
{
|
||||
ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder aufweisen.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
List<Player> inGangwar = new List<Player>(ownersInGangwar.Concat(attackersInGangwar));
|
||||
|
||||
usersInGangwar = inGangwar.ToArray();
|
||||
}
|
||||
if (this.status == "normal")
|
||||
{
|
||||
if (this.timer != null)
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer = null;
|
||||
}
|
||||
this.Attacker = attacker;
|
||||
this.status = "attack";
|
||||
|
||||
List<Player> clientsInGangwar = new List<Player>();
|
||||
|
||||
foreach (var u in usersInGangwar)
|
||||
{
|
||||
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
||||
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||
u.SetData("inGangWar", getId());
|
||||
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen.");
|
||||
clientsInGangwar.Add(u);
|
||||
}
|
||||
playerInGangwar = clientsInGangwar.ToArray();
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker));
|
||||
this.TurfTick();
|
||||
}
|
||||
}
|
||||
|
||||
public void setKill(string FactionName)
|
||||
{
|
||||
if (getOwner() == FactionName)
|
||||
{
|
||||
Def_Score -= 1;
|
||||
}
|
||||
else if (getAttacker() == FactionName)
|
||||
{
|
||||
Att_Score -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using System.Linq;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory
|
||||
{
|
||||
@@ -34,10 +34,12 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
var invWeight = InventoryManager.GetUserInventoryWeight(player);
|
||||
var itemsToAdd = 0;
|
||||
GTANetworkAPI.Object nearestObject = GroundObjects.FirstOrDefault(d => d.Position == nearest.Position);
|
||||
TextLabel nearestTextLabel = GroundTextLabels.FirstOrDefault(d => d.Position == nearest.Position);
|
||||
TextLabel nearestTextLabel = GroundTextLabels.FirstOrDefault(d => d.Position == new Vector3(nearest.Position.X, nearest.Position.Y, nearest.Position.Z + 1.05) || d.Position == new Vector3(nearest.Position.X, nearest.Position.Y, nearest.Position.Z + 0.8));
|
||||
IItem nearestItem = InventoryManager.GetItemById(nearest.ItemId);
|
||||
UserItem existingItem = InventoryManager.UserHasThisItem(player, nearest.ItemId);
|
||||
var user = player.GetUser();
|
||||
if (player.HasAttachment("ammobox"))
|
||||
{ player.SendNotification("~r~Du kannst momentan nichts tragen!", false); return; }
|
||||
if (nearestItem.Gewicht * nearest.Amount + invWeight > 40000)
|
||||
{
|
||||
for (var i = 1; i <= nearest.Amount; i++)
|
||||
@@ -69,7 +71,7 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
else
|
||||
{
|
||||
UserItem newItem = new UserItem { ItemId = nearest.ItemId, UserId = user.Id, Amount = nearest.Amount };
|
||||
InventoryManager.AddItemToInventory(player, newItem);
|
||||
InventoryManager.AddItemToInventory(player, newItem.ItemId, newItem.Amount);
|
||||
}
|
||||
nearest.Amount -= itemsToAdd;
|
||||
nearestTextLabel.Text = nearestItem.Name + " ~s~(~y~" + nearest.Amount + "~s~)";
|
||||
@@ -90,11 +92,20 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
else
|
||||
{
|
||||
UserItem item = new UserItem() { ItemId = nearest.ItemId, UserId = user.Id, Amount = nearest.Amount };
|
||||
InventoryManager.AddItemToInventory(player, item);
|
||||
InventoryManager.AddItemToInventory(player, item.ItemId, item.Amount);
|
||||
}
|
||||
RemoveGroundItem(nearest, nearestObject, nearestTextLabel);
|
||||
player.SendNotification("Du hast ~g~" + nearest.Amount + " ~y~" + nearestItem.Name + " ~s~aufgehoben.");
|
||||
}
|
||||
if (nearestItem is IWeaponDealItem obj)
|
||||
{
|
||||
if (!player.HasAttachment("ammobox"))
|
||||
{
|
||||
player.PlayAnimation("anim@heists@box_carry@", "idle", 49);
|
||||
player.AddAttachment("ammobox", false);
|
||||
NAPI.Player.SetPlayerCurrentWeapon(player, WeaponHash.Unarmed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,4 +119,3 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
{
|
||||
public interface IDroppableItem : IItem
|
||||
{
|
||||
uint Object { get; }
|
||||
}
|
||||
{
|
||||
uint Object { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Interfaces Item (IItem.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
@@ -11,12 +7,12 @@ using System.Text;
|
||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
{
|
||||
public interface IItem
|
||||
{
|
||||
int Id { get; }
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
int Gewicht { get; }
|
||||
string Einheit { get; }
|
||||
int Price { get; }
|
||||
}
|
||||
{
|
||||
int Id { get; }
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
int Gewicht { get; }
|
||||
string Einheit { get; }
|
||||
int Price { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Interfaces UsableItem (IUsableItem.cs)
|
||||
@@ -13,7 +9,7 @@ using System.Text;
|
||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
{
|
||||
public interface IUsableItem : IItem, IDroppableItem
|
||||
{
|
||||
void Use(UserItem uItem);
|
||||
}
|
||||
{
|
||||
void Use(UserItem uItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
{
|
||||
public interface IWeaponDealItem : IItem, IDroppableItem
|
||||
{
|
||||
bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh);
|
||||
}
|
||||
{
|
||||
bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
@@ -19,6 +14,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override int Gewicht => 4000;
|
||||
public override string Einheit => "g";
|
||||
public override uint Object => 3666746839; //3061944032
|
||||
public override int Price => 0;
|
||||
public override int Price => 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Cheeseburger (Cheeseburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
@@ -21,6 +16,5 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 150;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Chickenburger (Chickenburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -3,27 +3,24 @@ using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public abstract class DropItem : IDroppableItem
|
||||
{
|
||||
public abstract int HpAmount { get; }
|
||||
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 uint Object { get; }
|
||||
public abstract int Price { get; }
|
||||
|
||||
public void Drop(UserItem uItem, Player player, int amount)
|
||||
{
|
||||
player.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~weggeworfen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, amount);
|
||||
public abstract int HpAmount { get; }
|
||||
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 uint Object { get; }
|
||||
public abstract int Price { get; }
|
||||
|
||||
public void Drop(UserItem uItem, Player player, int amount)
|
||||
{
|
||||
player.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~weggeworfen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -3,36 +3,33 @@ using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public abstract class FoodItem : IUsableItem
|
||||
{
|
||||
public abstract int HpAmount { get; }
|
||||
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 uint Object { get; }
|
||||
public abstract int Price { get; }
|
||||
|
||||
public void Use(UserItem uItem)
|
||||
{
|
||||
Player player = uItem.GetUser().Player;
|
||||
public abstract int HpAmount { get; }
|
||||
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 uint Object { get; }
|
||||
public abstract int Price { get; }
|
||||
|
||||
int amountToAdd = HpAmount;
|
||||
if (player.Health + amountToAdd > 100)
|
||||
{
|
||||
amountToAdd = 100 - player.Health;
|
||||
}
|
||||
public void Use(UserItem uItem)
|
||||
{
|
||||
Player player = uItem.GetUser().Player;
|
||||
|
||||
player.Health += amountToAdd;
|
||||
player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
int amountToAdd = HpAmount;
|
||||
if (player.Health + amountToAdd > 100)
|
||||
{
|
||||
amountToAdd = 100 - player.Health;
|
||||
}
|
||||
|
||||
player.Health += amountToAdd;
|
||||
player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -2,31 +2,27 @@
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public abstract class WeaponDealItem : IWeaponDealItem
|
||||
{
|
||||
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 uint Object { get; }
|
||||
public abstract int Price { get; }
|
||||
|
||||
public bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh)
|
||||
{
|
||||
if (!fVeh.GetOwners().Contains(client.GetUser().FactionId ?? 0))
|
||||
return false;
|
||||
if (fVeh.Model != VehicleHash.Burrito3)
|
||||
return false;
|
||||
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 uint Object { get; }
|
||||
public abstract int Price { get; }
|
||||
|
||||
return true;
|
||||
public bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh)
|
||||
{
|
||||
if (!fVeh.GetOwners().Contains(client.GetUser().FactionId ?? 0))
|
||||
return false;
|
||||
if (fVeh.Model != VehicleHash.Burrito3)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
class BusDriverJob : JobBase
|
||||
internal class BusDriverJob : JobBase
|
||||
{
|
||||
public override int Id => 4;
|
||||
|
||||
@@ -57,7 +57,6 @@ namespace ReallifeGamemode.Server.Job
|
||||
|
||||
private readonly IReadOnlyCollection<Vector3> RouteLong = new List<Vector3>
|
||||
{
|
||||
|
||||
new Vector3(403.8605,-597.0284,27.1788),
|
||||
new Vector3(953.7955,140.8976,79.34214),
|
||||
new Vector3(1531.374,832.1884,75.94727),
|
||||
@@ -67,12 +66,10 @@ namespace ReallifeGamemode.Server.Job
|
||||
new Vector3(2599.954,4264.15,40.87192),
|
||||
new Vector3(2705.722,3308.447,54.2841),
|
||||
new Vector3(355.8403,-634.835,27.56906),
|
||||
|
||||
}.AsReadOnly();
|
||||
|
||||
private readonly IReadOnlyCollection<Vector3> RouteVeryLong = new List<Vector3>
|
||||
{
|
||||
|
||||
new Vector3(-562.68, -2203.85, 6.72),
|
||||
new Vector3(-889.0892, -2190.34, 8.100273),
|
||||
new Vector3(-695.8978, -1197.1, 10.07723),
|
||||
@@ -149,12 +146,10 @@ namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
CheckPointHandle.StartCheckPointRoute(player, RouteVeryLong, 3000, 1, 7, "busDriverJob");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void payWage(Player jobber, int wage)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +1,66 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
public abstract class JobBase : Script
|
||||
{
|
||||
public delegate void JobStartHandler(Player player);
|
||||
public delegate void JobStopHandler(Player player);
|
||||
|
||||
public event JobStartHandler JobStart;
|
||||
public event JobStopHandler JobStop;
|
||||
|
||||
private readonly List<Player> _inJob = new List<Player>();
|
||||
private static readonly List<Player> jobPlayer = new List<Player>();
|
||||
|
||||
public abstract int Id { get; }
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract bool NeedVehicleToStart { get; }
|
||||
|
||||
public void StartJob(Player player)
|
||||
{
|
||||
if (_inJob.Contains(player)) return;
|
||||
_inJob.Add(player);
|
||||
jobPlayer.Add(player);
|
||||
public delegate void JobStartHandler(Player player);
|
||||
|
||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet.");
|
||||
public delegate void JobStopHandler(Player player);
|
||||
|
||||
JobStart?.Invoke(player);
|
||||
public event JobStartHandler JobStart;
|
||||
|
||||
public event JobStopHandler JobStop;
|
||||
|
||||
private readonly List<Player> _inJob = new List<Player>();
|
||||
private static readonly List<Player> jobPlayer = new List<Player>();
|
||||
|
||||
public abstract int Id { get; }
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract bool NeedVehicleToStart { get; }
|
||||
|
||||
public void StartJob(Player player)
|
||||
{
|
||||
if (_inJob.Contains(player)) return;
|
||||
_inJob.Add(player);
|
||||
jobPlayer.Add(player);
|
||||
|
||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet.");
|
||||
|
||||
JobStart?.Invoke(player);
|
||||
}
|
||||
|
||||
public void StopJob(Player player, bool quit = false)
|
||||
{
|
||||
if (!_inJob.Contains(player)) return;
|
||||
_inJob.Remove(player);
|
||||
jobPlayer.Remove(player);
|
||||
|
||||
if (quit)
|
||||
{
|
||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet.");
|
||||
}
|
||||
|
||||
JobStop?.Invoke(player);
|
||||
}
|
||||
|
||||
public List<JobVehicle> GetJobVehicles()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Player> GetPlayerInJob() => jobPlayer;
|
||||
|
||||
public List<Player> GetUsersInJob() => _inJob;
|
||||
}
|
||||
|
||||
public void StopJob(Player player, bool quit = false)
|
||||
{
|
||||
if (!_inJob.Contains(player)) return;
|
||||
_inJob.Remove(player);
|
||||
jobPlayer.Remove(player);
|
||||
|
||||
if (quit)
|
||||
{
|
||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet.");
|
||||
}
|
||||
|
||||
JobStop?.Invoke(player);
|
||||
}
|
||||
|
||||
public List<JobVehicle> GetJobVehicles()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Player> GetPlayerInJob() => jobPlayer;
|
||||
public List<Player> GetUsersInJob() => _inJob;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
class PilotJob : JobBase
|
||||
internal class PilotJob : JobBase
|
||||
{
|
||||
public override int Id => 3;
|
||||
|
||||
@@ -101,8 +102,6 @@ namespace ReallifeGamemode.Server.Job
|
||||
new Vector3(-591.96, -1943.26, 311.73),
|
||||
}.AsReadOnly();
|
||||
|
||||
|
||||
|
||||
public PilotJob()
|
||||
{
|
||||
JobStart += PilotJob_JobStart;
|
||||
@@ -117,7 +116,6 @@ namespace ReallifeGamemode.Server.Job
|
||||
|
||||
if (veh.DisplayName == "Velum")
|
||||
{
|
||||
|
||||
listRouteTexts2.Add("Route 4");
|
||||
listRouteTexts2.Add("Route 5");
|
||||
listRouteTexts2.Add("Route 6");
|
||||
@@ -132,8 +130,8 @@ namespace ReallifeGamemode.Server.Job
|
||||
|
||||
player.TriggerEvent("showPilotRouteMenu", JsonConvert.SerializeObject(listRouteTexts));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("startPilotRoute")]
|
||||
public void StartPilotRoute(Player player, string type)
|
||||
{
|
||||
|
||||
@@ -8,33 +8,33 @@ using ReallifeGamemode.Server.Services;
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
public class RefuseCollectorJob : JobBase
|
||||
{
|
||||
public override int Id => 2;
|
||||
|
||||
public override string Name => "Müllmann";
|
||||
|
||||
public override bool NeedVehicleToStart => false;
|
||||
|
||||
public RefuseCollectorJob()
|
||||
{
|
||||
JobStart += RefuseCollectorJobJobStart;
|
||||
JobStop += RefuseCollectorJobJobStop;
|
||||
}
|
||||
public override int Id => 2;
|
||||
|
||||
private void RefuseCollectorJobJobStart(Player player)
|
||||
{
|
||||
//setClothes
|
||||
}
|
||||
public override string Name => "Müllmann";
|
||||
|
||||
private void RefuseCollectorJobJobStop(Player player)
|
||||
{
|
||||
//removeClothes and replace with old
|
||||
MuellmannJobBeenden(player);
|
||||
}
|
||||
public override bool NeedVehicleToStart => false;
|
||||
|
||||
public static List<MuellmannData> muellmanData = new List<MuellmannData>();
|
||||
public RefuseCollectorJob()
|
||||
{
|
||||
JobStart += RefuseCollectorJobJobStart;
|
||||
JobStop += RefuseCollectorJobJobStop;
|
||||
}
|
||||
|
||||
private readonly IReadOnlyCollection<Vector3> vector3s = new List<Vector3>
|
||||
private void RefuseCollectorJobJobStart(Player player)
|
||||
{
|
||||
//setClothes
|
||||
}
|
||||
|
||||
private void RefuseCollectorJobJobStop(Player player)
|
||||
{
|
||||
//removeClothes and replace with old
|
||||
MuellmannJobBeenden(player);
|
||||
}
|
||||
|
||||
public static List<MuellmannData> muellmanData = new List<MuellmannData>();
|
||||
|
||||
private readonly IReadOnlyCollection<Vector3> vector3s = new List<Vector3>
|
||||
{
|
||||
new Vector3(332.9839782714844, -1741.807373046875, 29.73055076599121),
|
||||
new Vector3(321.3463439941406, -1759.986572265625, 29.644014358520508),
|
||||
@@ -153,303 +153,298 @@ namespace ReallifeGamemode.Server.Job
|
||||
|
||||
}.AsReadOnly();
|
||||
|
||||
[RemoteEvent("CLIENT:MuellmannJobStarten")]
|
||||
public void MuellmannJobStarten(Player player, Vehicle vehicle)
|
||||
{
|
||||
if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2)
|
||||
{
|
||||
Vehicle veh;
|
||||
foreach (var data in muellmanData)
|
||||
[RemoteEvent("CLIENT:MuellmannJobStarten")]
|
||||
public void MuellmannJobStarten(Player player, Vehicle vehicle)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
veh = data.vehicle;
|
||||
ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job gestartet!");
|
||||
player.TriggerEvent("SERVER:MuellmannStatusTrue");
|
||||
player.TriggerEvent("SERVER:MuellmannBCSErstellen", JsonConvert.SerializeObject(vector3s.ToArray()), veh);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MuellmannJobBeenden(Player player)
|
||||
{
|
||||
ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job beendet!");
|
||||
player.TriggerEvent("SERVER:MuellmannStatusFalse");
|
||||
player.TriggerEvent("SERVER:MuellmannBCSEntfernen");
|
||||
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
if (data.hasFreePlace())
|
||||
{
|
||||
muellmanData.Remove(data);
|
||||
//müllwagen respawnen
|
||||
return;
|
||||
}
|
||||
|
||||
data.removeClientFromData(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:MuellmannImShape")]
|
||||
public void MuellmannImShape(Player player, int colshapeIndex)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
Player target = data.getPartnerClient(player);
|
||||
if (target != null) target.TriggerEvent("MuellmannUpdateColshape", colshapeIndex);
|
||||
ChatService.SendMessage((Player)player, "Du hast den Müllsack in der Hand. Bringe ihm zum Müllwagen hinten.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:MuellmannAddSack")]
|
||||
public void MuellmannAddSack(Player player)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
int count = data.getTrashCount();
|
||||
count++;
|
||||
data.setTrashCount(count);
|
||||
|
||||
Player target = data.getPartnerClient(player);
|
||||
if (target != null) ChatService.SendMessage((Player)target, $"Es sind jetzt {count} Säcke im Müllwagen.");
|
||||
ChatService.SendMessage((Player)player, $"Es sind jetzt {count} Säcke im Müllwagen.");
|
||||
|
||||
if (data.getTrashCount() >= 20)
|
||||
{
|
||||
ChatService.SendMessage((Player)player, "Auto ist voll fahre nun zu Base.");
|
||||
if (target != null) { ChatService.SendMessage((Player)target, "Auto ist voll fahre nun zu Base."); target.TriggerEvent("SERVER:MuellmannZuBase"); }
|
||||
player.TriggerEvent("SERVER:MuellmannZuBase");
|
||||
}
|
||||
//bonus pro sack
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:MuellmannBaseSack")]
|
||||
public void MuellmannBaseSack(Player player)
|
||||
{
|
||||
if (player.VehicleSeat != 0) return;
|
||||
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
int count = data.getTrashCount();
|
||||
|
||||
Player target = data.getPartnerClient(player);
|
||||
if (target != null) ChatService.SendMessage((Player)target, $"Fahrzeug wurde entleert. Säcke: {count}");
|
||||
ChatService.SendMessage((Player)player, $"Fahrzeug wurde entleert. Säcke: {count}");
|
||||
//bonus pro sack
|
||||
|
||||
data.setTrashCount(0);
|
||||
Console.WriteLine($"[DATA DEBUG] vehicle: {data.vehicle.DisplayName} | Players: {data.getClientsFromData().Count} | Säcke: {data.getTrashCount()}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#region zweiSpeieler
|
||||
|
||||
public void MuellmannOnPlayerDc(Player player)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
if (data.hasFreePlace())
|
||||
{
|
||||
muellmanData.Remove(data);
|
||||
//müllwagen respawnen
|
||||
return;
|
||||
}
|
||||
|
||||
data.removeClientFromData(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void MuellmannOnPlayerDeath(Player player)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
if (data.hasFreePlace())
|
||||
{
|
||||
muellmanData.Remove(data);
|
||||
//müllwagen respawnen
|
||||
return;
|
||||
}
|
||||
|
||||
data.removeClientFromData(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.VehicleDeath)]
|
||||
private void MuellmannOnVehicle(Vehicle veh)
|
||||
{
|
||||
if (veh.Model != (uint)Types.VehicleModel.Trash && veh.Model != (uint)Types.VehicleModel.Trash2) return;
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.vehicle == veh)
|
||||
{
|
||||
//müllfahrzeug respawnen
|
||||
|
||||
List<Player> clients = data.getClientsFromData();
|
||||
foreach (var c in clients) { RefuseCollectorJobJobStop(c); }
|
||||
|
||||
muellmanData.Remove(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MuellmannOnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
Player target;
|
||||
if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.vehicle == vehicle)
|
||||
{
|
||||
if (data.getDataFromClient(player) != null)
|
||||
return;
|
||||
|
||||
if (!data.hasFreePlace())
|
||||
if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2)
|
||||
{
|
||||
player.StopAnimation();
|
||||
return;
|
||||
Vehicle veh;
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
veh = data.vehicle;
|
||||
ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job gestartet!");
|
||||
player.TriggerEvent("SERVER:MuellmannStatusTrue");
|
||||
player.TriggerEvent("SERVER:MuellmannBCSErstellen", JsonConvert.SerializeObject(vector3s.ToArray()), veh);
|
||||
return;
|
||||
}
|
||||
}
|
||||
CheckDataForDuplicatePlayer(player, data);
|
||||
data.setClientToData(player);
|
||||
|
||||
MuellmannJobStarten(player, vehicle);
|
||||
|
||||
target = data.getPartnerClient(player);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !");
|
||||
ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MuellmannData newData = new MuellmannData(vehicle);
|
||||
muellmanData.Add(newData);
|
||||
CheckDataForDuplicatePlayer(player, newData);
|
||||
newData.setClientToData(player);
|
||||
|
||||
MuellmannJobStarten(player, vehicle);
|
||||
|
||||
target = newData.getPartnerClient(player);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !");
|
||||
ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !");
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckDataForDuplicatePlayer(Player player, MuellmannData data)
|
||||
{
|
||||
foreach (var d in muellmanData)
|
||||
{
|
||||
if (d == data) continue;
|
||||
|
||||
MuellmannData temp = d.getDataFromClient(player);
|
||||
if (temp == null) continue;
|
||||
|
||||
temp.removeClientFromData(player);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion zweiSpeieler
|
||||
|
||||
#region Data
|
||||
|
||||
public class MuellmannData
|
||||
{
|
||||
private Player client1;
|
||||
private Player client2;
|
||||
public Vehicle vehicle;
|
||||
private static int trashCount = 0;
|
||||
|
||||
public MuellmannData(Vehicle vehicle)
|
||||
{
|
||||
this.vehicle = vehicle;
|
||||
}
|
||||
|
||||
public void setClientToData(Player player)
|
||||
{
|
||||
if (client1 == player || client2 == player)
|
||||
public void MuellmannJobBeenden(Player player)
|
||||
{
|
||||
Console.WriteLine("Spieler schon gespeichert");
|
||||
return;
|
||||
ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job beendet!");
|
||||
player.TriggerEvent("SERVER:MuellmannStatusFalse");
|
||||
player.TriggerEvent("SERVER:MuellmannBCSEntfernen");
|
||||
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
if (data.hasFreePlace())
|
||||
{
|
||||
muellmanData.Remove(data);
|
||||
//müllwagen respawnen
|
||||
return;
|
||||
}
|
||||
|
||||
data.removeClientFromData(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (client1 == null) { client1 = player; return; }
|
||||
else if (client2 == null) { client2 = player; return; }
|
||||
else if (client1 != null && client2 != null) { Console.WriteLine("kein Platz"); }
|
||||
}
|
||||
[RemoteEvent("CLIENT:MuellmannImShape")]
|
||||
public void MuellmannImShape(Player player, int colshapeIndex)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
Player target = data.getPartnerClient(player);
|
||||
if (target != null) target.TriggerEvent("MuellmannUpdateColshape", colshapeIndex);
|
||||
ChatService.SendMessage((Player)player, "Du hast den Müllsack in der Hand. Bringe ihm zum Müllwagen hinten.");
|
||||
player.AddAttachment("binbag", false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeClientFromData(Player player)
|
||||
{
|
||||
if (client1 == player) { client1 = null; }
|
||||
if (client2 == player) { client2 = null; }
|
||||
}
|
||||
[RemoteEvent("CLIENT:MuellmannAddSack")]
|
||||
public void MuellmannAddSack(Player player)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
public int getTrashCount()
|
||||
{
|
||||
return trashCount;
|
||||
}
|
||||
data.setTrashCount(data.getTrashCount() + 1);
|
||||
|
||||
public void setTrashCount(int i)
|
||||
{
|
||||
trashCount = i;
|
||||
}
|
||||
Player target = data.getPartnerClient(player);
|
||||
player.AddAttachment("binbag", true);
|
||||
if (data.getTrashCount() >= 20)
|
||||
{
|
||||
ChatService.SendMessage((Player)player, "Auto ist voll fahre nun zu Base.");
|
||||
if (target != null) { ChatService.SendMessage((Player)target, "Auto ist voll fahre nun zu Base."); target.TriggerEvent("SERVER:MuellmannZuBase"); }
|
||||
player.TriggerEvent("SERVER:MuellmannZuBase");
|
||||
}
|
||||
//bonus pro sack
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Player> getClientsFromData()
|
||||
{
|
||||
List<Player> tempList = new List<Player>();
|
||||
if (client1 != null) { tempList.Add(client1); }
|
||||
if (client2 != null) { tempList.Add(client2); }
|
||||
return tempList;
|
||||
}
|
||||
[RemoteEvent("CLIENT:MuellmannBaseSack")]
|
||||
public void MuellmannBaseSack(Player player)
|
||||
{
|
||||
if (player.VehicleSeat != 0) return;
|
||||
|
||||
public MuellmannData getDataFromClient(Player player)
|
||||
{
|
||||
if (client1 != player && client2 != player)
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
public bool hasFreePlace()
|
||||
{
|
||||
if (client1 != null && client2 != null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
Player target = data.getPartnerClient(player);
|
||||
if (target != null) ChatService.SendMessage((Player)target, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}");
|
||||
ChatService.SendMessage((Player)player, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}");
|
||||
//bonus pro sack
|
||||
|
||||
public Player getPartnerClient(Player player)
|
||||
{
|
||||
if (client1 != player && client2 != player)
|
||||
return null;
|
||||
data.setTrashCount(0);
|
||||
Console.WriteLine($"[DATA DEBUG] vehicle: {data.vehicle.DisplayName} | Players: {data.getClientsFromData().Count} | Säcke: {data.getTrashCount()}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (client1 == player) { return client2; }
|
||||
if (client2 == player) { return client1; }
|
||||
return null;
|
||||
}
|
||||
#region zweiSpeieler
|
||||
|
||||
public void MuellmannOnPlayerDc(Player player)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
if (data.hasFreePlace())
|
||||
{
|
||||
muellmanData.Remove(data);
|
||||
//müllwagen respawnen
|
||||
return;
|
||||
}
|
||||
|
||||
data.removeClientFromData(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void MuellmannOnPlayerDeath(Player player)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.getDataFromClient(player) == null) continue;
|
||||
|
||||
if (data.hasFreePlace())
|
||||
{
|
||||
muellmanData.Remove(data);
|
||||
//müllwagen respawnen
|
||||
return;
|
||||
}
|
||||
|
||||
data.removeClientFromData(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.VehicleDeath)]
|
||||
private void MuellmannOnVehicle(Vehicle veh)
|
||||
{
|
||||
if (veh.Model != (uint)Types.VehicleModel.Trash && veh.Model != (uint)Types.VehicleModel.Trash2) return;
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.vehicle == veh)
|
||||
{
|
||||
//müllfahrzeug respawnen
|
||||
|
||||
List<Player> clients = data.getClientsFromData();
|
||||
foreach (var c in clients) { RefuseCollectorJobJobStop(c); }
|
||||
|
||||
muellmanData.Remove(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MuellmannOnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
Player target;
|
||||
if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2)
|
||||
{
|
||||
foreach (var data in muellmanData)
|
||||
{
|
||||
if (data.vehicle == vehicle)
|
||||
{
|
||||
if (data.getDataFromClient(player) != null)
|
||||
return;
|
||||
|
||||
if (!data.hasFreePlace())
|
||||
{
|
||||
player.StopAnimation();
|
||||
return;
|
||||
}
|
||||
CheckDataForDuplicatePlayer(player, data);
|
||||
data.setClientToData(player);
|
||||
//destroy veh
|
||||
MuellmannJobStarten(player, vehicle);
|
||||
|
||||
target = data.getPartnerClient(player);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !");
|
||||
ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MuellmannData newData = new MuellmannData(vehicle);
|
||||
muellmanData.Add(newData);
|
||||
CheckDataForDuplicatePlayer(player, newData);
|
||||
newData.setClientToData(player);
|
||||
|
||||
MuellmannJobStarten(player, vehicle);
|
||||
|
||||
target = newData.getPartnerClient(player);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !");
|
||||
ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !");
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckDataForDuplicatePlayer(Player player, MuellmannData data)
|
||||
{
|
||||
foreach (var d in muellmanData)
|
||||
{
|
||||
if (d == data) continue;
|
||||
|
||||
MuellmannData temp = d.getDataFromClient(player);
|
||||
if (temp == null) continue;
|
||||
|
||||
temp.removeClientFromData(player);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion zweiSpeieler
|
||||
|
||||
#region Data
|
||||
|
||||
public class MuellmannData
|
||||
{
|
||||
private Player client1;
|
||||
private Player client2;
|
||||
public Vehicle vehicle;
|
||||
private static int trashCount = 0;
|
||||
|
||||
public MuellmannData(Vehicle vehicle)
|
||||
{
|
||||
this.vehicle = vehicle;
|
||||
}
|
||||
|
||||
public void setClientToData(Player player)
|
||||
{
|
||||
if (client1 == player || client2 == player)
|
||||
{
|
||||
Console.WriteLine("Spieler schon gespeichert");
|
||||
return;
|
||||
}
|
||||
|
||||
if (client1 == null) { client1 = player; return; }
|
||||
else if (client2 == null) { client2 = player; return; }
|
||||
else if (client1 != null && client2 != null) { Console.WriteLine("kein Platz"); }
|
||||
}
|
||||
|
||||
public void removeClientFromData(Player player)
|
||||
{
|
||||
if (client1 == player) { client1 = null; }
|
||||
if (client2 == player) { client2 = null; }
|
||||
}
|
||||
|
||||
public int getTrashCount()
|
||||
{
|
||||
return trashCount;
|
||||
}
|
||||
|
||||
public void setTrashCount(int i)
|
||||
{
|
||||
trashCount = i;
|
||||
}
|
||||
|
||||
public List<Player> getClientsFromData()
|
||||
{
|
||||
List<Player> tempList = new List<Player>();
|
||||
if (client1 != null) { tempList.Add(client1); }
|
||||
if (client2 != null) { tempList.Add(client2); }
|
||||
return tempList;
|
||||
}
|
||||
|
||||
public MuellmannData getDataFromClient(Player player)
|
||||
{
|
||||
if (client1 != player && client2 != player)
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public bool hasFreePlace()
|
||||
{
|
||||
if (client1 != null && client2 != null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public Player getPartnerClient(Player player)
|
||||
{
|
||||
if (client1 != player && client2 != player)
|
||||
return null;
|
||||
|
||||
if (client1 == player) { return client2; }
|
||||
if (client2 == player) { return client1; }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Data
|
||||
}
|
||||
|
||||
#endregion Data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using System.Timers;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
class TaxiDriverJob : JobBase
|
||||
internal class TaxiDriverJob : JobBase
|
||||
{
|
||||
public List<TaxiContract> TaxiContracts { get; set; } = new List<TaxiContract>();
|
||||
|
||||
@@ -27,7 +24,6 @@ namespace ReallifeGamemode.Server.Job
|
||||
|
||||
public override bool NeedVehicleToStart => true;
|
||||
|
||||
|
||||
private static TaxiDriverJob _Instance;
|
||||
|
||||
public TaxiDriverJob()
|
||||
@@ -42,6 +38,7 @@ namespace ReallifeGamemode.Server.Job
|
||||
_Instance = new TaxiDriverJob();
|
||||
return _Instance;
|
||||
}
|
||||
|
||||
private void TaxiDriverJobJobStart(Player player)
|
||||
{
|
||||
player.Vehicle.SetSharedData("vehicleTaxiLight", true);
|
||||
@@ -89,24 +86,23 @@ namespace ReallifeGamemode.Server.Job
|
||||
dbContext.SaveChanges();
|
||||
target.Player.TriggerEvent("SERVER:SET_HANDMONEY", target.Handmoney);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public static void StartTaxiTimer()
|
||||
{
|
||||
Timer timer = new Timer(500);
|
||||
timer.Start();
|
||||
timer.Elapsed += UpdateFare;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
public static void StartTaxiTimer()
|
||||
{
|
||||
Timer timer = new Timer(500);
|
||||
timer.Start();
|
||||
timer.Elapsed += UpdateFare;
|
||||
}
|
||||
*/
|
||||
|
||||
public static void UpdateFare()
|
||||
{
|
||||
foreach (var player in GetPlayerInJob())
|
||||
{
|
||||
User u = player.GetUser();
|
||||
if (u.JobId != 1) return;
|
||||
if (u.JobId != 1) return;
|
||||
Console.WriteLine(player.Name);
|
||||
if (!player.HasData("hasPassager")) { player.SetData<bool>("hasPassager", false); continue; }
|
||||
int playerId = player.GetUser().Id;
|
||||
@@ -124,9 +120,7 @@ namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
occupant.TriggerEvent("CLIENT:updateFare", JsonConvert.SerializeObject(distance));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,21 @@
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Classes;
|
||||
using ReallifeGamemode.Server.Finance;
|
||||
using ReallifeGamemode.Server.Common;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Core.Events;
|
||||
using ReallifeGamemode.Server.Core.RageMP;
|
||||
using ReallifeGamemode.Server.DrivingSchool;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
using ReallifeGamemode.Server.DrivingSchool;
|
||||
using ReallifeGamemode.Server.WeaponDeal;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Core.RageMP;
|
||||
using ReallifeGamemode.Server.Core.Events;
|
||||
using System.Collections.Generic;
|
||||
using ReallifeGamemode.Server.Common;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using ReallifeGamemode.Server.Job;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Services;
|
||||
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Main Class (Main.cs)
|
||||
* @author VegaZ, hydrant
|
||||
@@ -33,93 +25,93 @@ using ReallifeGamemode.Services;
|
||||
namespace ReallifeGamemode.Server
|
||||
{
|
||||
public class Main : Script
|
||||
{
|
||||
public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829);
|
||||
public static readonly float DEFAULT_SPAWN_HEADING = 340.8f;
|
||||
|
||||
public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE");
|
||||
|
||||
private EventHandler eventHandler;
|
||||
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
var methods = Assembly.GetExecutingAssembly()
|
||||
.GetTypes()
|
||||
.SelectMany(t => t.GetMethods())
|
||||
.Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0)
|
||||
.ToArray();
|
||||
public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829);
|
||||
public static readonly float DEFAULT_SPAWN_HEADING = 340.8f;
|
||||
|
||||
var cmdAttributes = methods.Select(c => c.GetCustomAttribute<CommandAttribute>()).ToList();
|
||||
public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE");
|
||||
|
||||
var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList();
|
||||
cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a =>
|
||||
{
|
||||
registeredCommands.AddRange(a.Alias.Split(','));
|
||||
});
|
||||
private EventHandler eventHandler;
|
||||
|
||||
IAPI apiInstance = new RageAPI();
|
||||
eventHandler = new EventHandler(apiInstance);
|
||||
|
||||
new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray());
|
||||
|
||||
NAPI.Server.SetGlobalServerChat(false);
|
||||
|
||||
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
|
||||
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
||||
|
||||
JsonConvert.DefaultSettings = () =>
|
||||
{
|
||||
return new JsonSerializerSettings()
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
};
|
||||
var methods = Assembly.GetExecutingAssembly()
|
||||
.GetTypes()
|
||||
.SelectMany(t => t.GetMethods())
|
||||
.Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0)
|
||||
.ToArray();
|
||||
|
||||
InventoryManager.LoadItems();
|
||||
ShopManager.LoadClotheShops();
|
||||
ShopManager.LoadItemShops();
|
||||
TuningManager.LoadTuningGarages();
|
||||
var cmdAttributes = methods.Select(c => c.GetCustomAttribute<CommandAttribute>()).ToList();
|
||||
|
||||
TimeManager.StartTimeManager();
|
||||
VehicleManager.CheckEnabledMods();
|
||||
var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList();
|
||||
cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a =>
|
||||
{
|
||||
registeredCommands.AddRange(a.Alias.Split(','));
|
||||
});
|
||||
|
||||
DatabaseHelper.InitDatabaseFirstTime();
|
||||
IAPI apiInstance = new RageAPI();
|
||||
eventHandler = new EventHandler(apiInstance);
|
||||
|
||||
FactionHelper.CheckFactionBankAccounts();
|
||||
BusinessManager.LoadBusinesses();
|
||||
//InteriorManager.LoadInteriors();
|
||||
DoorManager.LoadDoors();
|
||||
ATMManager.InitATMs();
|
||||
CityHallManager.LoadCityHall();
|
||||
JobManager.LoadJobs();
|
||||
//TaxiDriverJob.StartTaxiTimer(); Obselete
|
||||
//HouseManager.LoadHouses();
|
||||
DrivingSchool.DrivingSchool.Setup();
|
||||
PlaneSchool.Setup();
|
||||
Gangwar.Gangwar.loadTurfs();
|
||||
new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray());
|
||||
|
||||
TempBlip tempBlip = new TempBlip()
|
||||
{
|
||||
Color = 1,
|
||||
Name = "",
|
||||
Transparency = 0,
|
||||
ShortRange = true,
|
||||
Sprite = 1,
|
||||
Scale = 1,
|
||||
};
|
||||
NAPI.Server.SetGlobalServerChat(false);
|
||||
|
||||
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
||||
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
|
||||
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
||||
|
||||
//WantedEscapeTimer.WantedTimer(); Obselete
|
||||
//Jail.JailTimer(); Obselete
|
||||
//Economy.PaydayTimer(); Obselete
|
||||
// WeaponDealManager.WeaponDealTimer(); Obselete
|
||||
JsonConvert.DefaultSettings = () =>
|
||||
{
|
||||
return new JsonSerializerSettings()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
};
|
||||
|
||||
ThreadTimers.StartAllTimers();
|
||||
InventoryManager.LoadItems();
|
||||
ShopManager.LoadClotheShops();
|
||||
ShopManager.LoadItemShops();
|
||||
TuningManager.LoadTuningGarages();
|
||||
|
||||
TimeManager.StartTimeManager();
|
||||
VehicleManager.CheckEnabledMods();
|
||||
|
||||
DatabaseHelper.InitDatabaseFirstTime();
|
||||
|
||||
FactionHelper.CheckFactionBankAccounts();
|
||||
BusinessManager.LoadBusinesses();
|
||||
//InteriorManager.LoadInteriors();
|
||||
DoorManager.LoadDoors();
|
||||
ATMManager.InitATMs();
|
||||
CityHallManager.LoadCityHall();
|
||||
JobManager.LoadJobs();
|
||||
//TaxiDriverJob.StartTaxiTimer(); Obselete
|
||||
//HouseManager.LoadHouses();
|
||||
DrivingSchool.DrivingSchool.Setup();
|
||||
PlaneSchool.Setup();
|
||||
Gangwar.Gangwar.loadTurfs();
|
||||
|
||||
TempBlip tempBlip = new TempBlip()
|
||||
{
|
||||
Color = 1,
|
||||
Name = "",
|
||||
Transparency = 0,
|
||||
ShortRange = true,
|
||||
Sprite = 1,
|
||||
Scale = 1,
|
||||
};
|
||||
|
||||
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
||||
|
||||
//WantedEscapeTimer.WantedTimer(); Obselete
|
||||
//Jail.JailTimer(); Obselete
|
||||
//Economy.PaydayTimer(); Obselete
|
||||
// WeaponDealManager.WeaponDealTimer(); Obselete
|
||||
|
||||
ThreadTimers.StartAllTimers();
|
||||
|
||||
UserBankAccount.BalanceChanged += (account) =>
|
||||
{
|
||||
@@ -137,11 +129,11 @@ namespace ReallifeGamemode.Server
|
||||
};
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Event")]
|
||||
public void OnClientEvent(Player player, string dataStr)
|
||||
{
|
||||
var data = dataStr.DeserializeJson<List<object>>();
|
||||
eventHandler.HandleEvent(new RagePlayer(player), data);
|
||||
[RemoteEvent("CLIENT:Event")]
|
||||
public void OnClientEvent(Player player, string dataStr)
|
||||
{
|
||||
var data = dataStr.DeserializeJson<List<object>>();
|
||||
eventHandler.HandleEvent(new RagePlayer(player), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Managers ATMManager (ATMManager.cs)
|
||||
@@ -16,136 +14,140 @@ using ReallifeGamemode.Database.Models;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class ATMManager : Script
|
||||
{
|
||||
public static List<ColShape> ATMColShapes = new List<ColShape>();
|
||||
|
||||
public static void InitATMs()
|
||||
{
|
||||
var addedATMs = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var currentATM in dbContext.Blips)
|
||||
public static List<ColShape> ATMColShapes = new List<ColShape>();
|
||||
|
||||
public static void InitATMs()
|
||||
{
|
||||
if (currentATM.Sprite == 500)
|
||||
{
|
||||
if (dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
||||
var addedATMs = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new ATM
|
||||
{
|
||||
Id = currentATM.Id,
|
||||
X = currentATM.PositionX,
|
||||
Y = currentATM.PositionY,
|
||||
Z = currentATM.PositionZ
|
||||
};
|
||||
dbContext.Add(dataSet);
|
||||
addedATMs++;
|
||||
foreach (var currentATM in dbContext.Blips)
|
||||
{
|
||||
if (currentATM.Sprite == 500)
|
||||
{
|
||||
if (dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
||||
{
|
||||
var dataSet = new ATM
|
||||
{
|
||||
Id = currentATM.Id,
|
||||
X = currentATM.PositionX,
|
||||
Y = currentATM.PositionY,
|
||||
Z = currentATM.PositionZ
|
||||
};
|
||||
dbContext.Add(dataSet);
|
||||
addedATMs++;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addedATMs > 0)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
||||
}
|
||||
else
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
LoadATMs();
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addedATMs > 0)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
||||
}
|
||||
else
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
LoadATMs();
|
||||
}
|
||||
}
|
||||
public static void LoadATMs()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var currentATM in dbContext.ATMs)
|
||||
public static void LoadATMs()
|
||||
{
|
||||
var currentColShape = NAPI.ColShape.CreateCylinderColShape(new Vector3(currentATM.X, currentATM.Y, currentATM.Z), 2.5f, 3, 0);
|
||||
currentColShape.OnEntityEnterColShape += EnterATMRange;
|
||||
currentColShape.OnEntityExitColShape += ExitATMRange;
|
||||
ATMColShapes.Add(currentColShape);
|
||||
currentColShape.SetData("id", currentATM.Id);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var currentATM in dbContext.ATMs)
|
||||
{
|
||||
var currentColShape = NAPI.ColShape.CreateCylinderColShape(new Vector3(currentATM.X, currentATM.Y, currentATM.Z), 2.5f, 3, 0);
|
||||
currentColShape.OnEntityEnterColShape += EnterATMRange;
|
||||
currentColShape.OnEntityExitColShape += ExitATMRange;
|
||||
ATMColShapes.Add(currentColShape);
|
||||
currentColShape.SetData("id", currentATM.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void EnterATMRange(ColShape colShape, Player client)
|
||||
{
|
||||
client.SetData("nearATM", colShape.GetData<int>("id"));
|
||||
}
|
||||
public static void ExitATMRange(ColShape colShape, Player client)
|
||||
{
|
||||
client.ResetData("nearATM");
|
||||
}
|
||||
public static void ShowAtmUi(Player player, int atmId)
|
||||
{
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
||||
public void AtmAction(Player client, int site, int inputField1, int inputField2)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = client.GetUser(dbContext);
|
||||
int nearATM = client.GetData<int>("nearATM");
|
||||
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
||||
switch (site)
|
||||
public static void EnterATMRange(ColShape colShape, Player client)
|
||||
{
|
||||
//GELD EINZAHLEN in1
|
||||
case 0:
|
||||
|
||||
if (user.Handmoney < inputField1)
|
||||
{
|
||||
//TODO im CEFBrowser anzeigen
|
||||
//client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance);
|
||||
client.SendNotification("~r~Nicht genügend Geld auf der Hand!");
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateBankMoneyIn = user.BankAccount;
|
||||
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
user.Handmoney -= inputField1;
|
||||
updateBankMoneyIn.Balance += inputField1;
|
||||
updateATMBalanceIn.Balance += inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD AUSZAHLEN in1
|
||||
case 1:
|
||||
var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
|
||||
if (user.BankAccount.Balance < inputField1)
|
||||
{
|
||||
client.SendNotification("~r~Nicht genügend Geld auf dem Bankkonto!"); //TODO Im Automaten anzeigen lassen
|
||||
}
|
||||
else if (checkATM.Balance < inputField1)
|
||||
{
|
||||
client.SendNotification("~r~Nicht genügend Geld im Automaten vorhanden!"); //TODO Im Automaten anzeigen lassen |||| oder OUT OF ORDER anzeigen wenn leer
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
updateHandMoneyOut.Handmoney += inputField1;
|
||||
user.BankAccount.Balance -= inputField1;
|
||||
updateATMBalanceOut.Balance -= inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag
|
||||
case 2:
|
||||
|
||||
break;
|
||||
client.SetData("nearATM", colShape.GetData<int>("id"));
|
||||
}
|
||||
|
||||
public static void ExitATMRange(ColShape colShape, Player client)
|
||||
{
|
||||
client.ResetData("nearATM");
|
||||
}
|
||||
|
||||
public static void ShowAtmUi(Player player, int atmId)
|
||||
{
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
||||
public void AtmAction(Player client, int site, int inputField1, int inputField2)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = client.GetUser(dbContext);
|
||||
int nearATM = client.GetData<int>("nearATM");
|
||||
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
||||
switch (site)
|
||||
{
|
||||
//GELD EINZAHLEN in1
|
||||
case 0:
|
||||
|
||||
if (user.Handmoney < inputField1)
|
||||
{
|
||||
//TODO im CEFBrowser anzeigen
|
||||
//client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance);
|
||||
client.SendNotification("~r~Nicht genügend Geld auf der Hand!");
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateBankMoneyIn = user.BankAccount;
|
||||
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
user.Handmoney -= inputField1;
|
||||
updateBankMoneyIn.Balance += inputField1;
|
||||
updateATMBalanceIn.Balance += inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD AUSZAHLEN in1
|
||||
case 1:
|
||||
var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
|
||||
if (user.BankAccount.Balance < inputField1)
|
||||
{
|
||||
client.SendNotification("~r~Nicht genügend Geld auf dem Bankkonto!"); //TODO Im Automaten anzeigen lassen
|
||||
}
|
||||
else if (checkATM.Balance < inputField1)
|
||||
{
|
||||
client.SendNotification("~r~Nicht genügend Geld im Automaten vorhanden!"); //TODO Im Automaten anzeigen lassen |||| oder OUT OF ORDER anzeigen wenn leer
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
updateHandMoneyOut.Handmoney += inputField1;
|
||||
user.BankAccount.Balance -= inputField1;
|
||||
updateATMBalanceOut.Balance -= inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag
|
||||
case 2:
|
||||
|
||||
break;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Business;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Database.Entities.Logs;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Entities.Logs;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Managers BankManager (BankManager.cs)
|
||||
@@ -20,98 +15,98 @@ using ReallifeGamemode.Database.Entities;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class BankManager
|
||||
{
|
||||
public static TransactionResult SetMoney(Player admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt")
|
||||
{
|
||||
using (var transferMoney = new DatabaseContext())
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount account = owner.GetBankAccount(transferMoney);
|
||||
|
||||
if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
|
||||
var transactionLog = new BankAccountTransactionHistory
|
||||
public static TransactionResult SetMoney(Player admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt")
|
||||
{
|
||||
Sender = "ADMIN: " + admin.Name,
|
||||
SenderBalance = 0,
|
||||
Receiver = owner.Name,
|
||||
ReceiverBalance = amount,
|
||||
NewReceiverBalance = amount,
|
||||
NewSenderBalance = 0,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = reason
|
||||
};
|
||||
using (var transferMoney = new DatabaseContext())
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
// add log
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
IBankAccount account = owner.GetBankAccount(transferMoney);
|
||||
|
||||
account.Balance = amount;
|
||||
if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
|
||||
transferMoney.SaveChanges();
|
||||
var transactionLog = new BankAccountTransactionHistory
|
||||
{
|
||||
Sender = "ADMIN: " + admin.Name,
|
||||
SenderBalance = 0,
|
||||
Receiver = owner.Name,
|
||||
ReceiverBalance = amount,
|
||||
NewReceiverBalance = amount,
|
||||
NewSenderBalance = 0,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = reason
|
||||
};
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
// add log
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
account.Balance = amount;
|
||||
|
||||
transferMoney.SaveChanges();
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public static TransactionResult TransferMoney<TSender, TReceiver>(
|
||||
BankAccountHolder<TSender> sender,
|
||||
BankAccountHolder<TReceiver> receiver,
|
||||
int amount,
|
||||
string origin,
|
||||
DatabaseContext dbContext) where TSender : class, IBankAccount, new() where TReceiver : class, IBankAccount, new()
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount senderAccount;
|
||||
IBankAccount receiverAccount;
|
||||
|
||||
if (sender is BankAccountHolder<BusinessBankAccount> businessSender)
|
||||
{
|
||||
senderAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessSender.BankAccountId).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
senderAccount = sender.BankAccount;
|
||||
}
|
||||
|
||||
if (receiver is BankAccountHolder<BusinessBankAccount> businessReceiver)
|
||||
{
|
||||
receiverAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessReceiver.BankAccountId).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
receiverAccount = receiver.BankAccount;
|
||||
}
|
||||
|
||||
if (senderAccount == null) return TransactionResult.SENDER_NO_BANKACCOUNT;
|
||||
if (receiverAccount == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
|
||||
if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY;
|
||||
|
||||
var transactionLog = new BankAccountTransactionHistory
|
||||
{
|
||||
Sender = sender.BankAccountName,
|
||||
SenderBalance = senderAccount.Balance,
|
||||
Receiver = receiver.BankAccountName,
|
||||
ReceiverBalance = receiverAccount.Balance,
|
||||
NewReceiverBalance = receiverAccount.Balance + amount,
|
||||
NewSenderBalance = senderAccount.Balance - amount,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
// add log
|
||||
dbContext.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
senderAccount.Balance -= amount;
|
||||
receiverAccount.Balance += amount;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public static TransactionResult TransferMoney<TSender, TReceiver>(
|
||||
BankAccountHolder<TSender> sender,
|
||||
BankAccountHolder<TReceiver> receiver,
|
||||
int amount,
|
||||
string origin,
|
||||
DatabaseContext dbContext) where TSender : class, IBankAccount, new() where TReceiver : class, IBankAccount, new()
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount senderAccount;
|
||||
IBankAccount receiverAccount;
|
||||
|
||||
if (sender is BankAccountHolder<BusinessBankAccount> businessSender)
|
||||
{
|
||||
senderAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessSender.BankAccountId).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
senderAccount = sender.BankAccount;
|
||||
}
|
||||
|
||||
if (receiver is BankAccountHolder<BusinessBankAccount> businessReceiver)
|
||||
{
|
||||
receiverAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessReceiver.BankAccountId).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
receiverAccount = receiver.BankAccount;
|
||||
}
|
||||
|
||||
if (senderAccount == null) return TransactionResult.SENDER_NO_BANKACCOUNT;
|
||||
if (receiverAccount == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
|
||||
if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY;
|
||||
|
||||
var transactionLog = new BankAccountTransactionHistory
|
||||
{
|
||||
Sender = sender.BankAccountName,
|
||||
SenderBalance = senderAccount.Balance,
|
||||
Receiver = receiver.BankAccountName,
|
||||
ReceiverBalance = receiverAccount.Balance,
|
||||
NewReceiverBalance = receiverAccount.Balance + amount,
|
||||
NewSenderBalance = senderAccount.Balance - amount,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
// add log
|
||||
dbContext.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
senderAccount.Balance -= amount;
|
||||
receiverAccount.Balance += amount;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Business;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Business;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
class BusinessManager : Script
|
||||
internal class BusinessManager : Script
|
||||
{
|
||||
public static List<BusinessBase> Businesses { get; private set; }
|
||||
|
||||
|
||||
@@ -1,333 +1,332 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class CharacterCreator : Script
|
||||
{
|
||||
[RemoteEvent("creator_GenderChange")]
|
||||
public void changeGender(Player player, int gender)
|
||||
{
|
||||
if(gender == 0) player.SetSkin(PedHash.FreemodeMale01);
|
||||
else player.SetSkin(PedHash.FreemodeFemale01);
|
||||
}
|
||||
[RemoteEvent("creatorSave")]
|
||||
public void CreatorSave(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData)
|
||||
{
|
||||
var jParentData = JObject.Parse(parentData);
|
||||
var jFeatureData = JArray.Parse(featureData);
|
||||
var jAppearanceData = JArray.Parse(appearanceData);
|
||||
var jHairAndColorData = JArray.Parse(hairAndColorData);
|
||||
|
||||
byte father = jParentData.Value<byte>("Father");
|
||||
byte mother = jParentData.Value<byte>("Mother");
|
||||
float similarity = jParentData.Value<float>("Similarity");
|
||||
float skinSimilarity = jParentData.Value<float>("SkinSimilarity");
|
||||
|
||||
float noseWidth = jFeatureData.Value<float>(0);
|
||||
float noseBottomHeight = jFeatureData.Value<float>(1);
|
||||
float noseTipLength = jFeatureData.Value<float>(2);
|
||||
float noseBridgeDepth = jFeatureData.Value<float>(3);
|
||||
float noseTipHeight = jFeatureData.Value<float>(4);
|
||||
float noseBroken = jFeatureData.Value<float>(5);
|
||||
float browHeight = jFeatureData.Value<float>(6);
|
||||
float browDepth = jFeatureData.Value<float>(7);
|
||||
float cheekboneHeight = jFeatureData.Value<float>(8);
|
||||
float cheekboneWidth = jFeatureData.Value<float>(9);
|
||||
float cheekDepth = jFeatureData.Value<float>(10);
|
||||
float eyeSize = jFeatureData.Value<float>(11);
|
||||
float lipThickness = jFeatureData.Value<float>(12);
|
||||
float jawWidth = jFeatureData.Value<float>(13);
|
||||
float jawShape = jFeatureData.Value<float>(14);
|
||||
float chinHeight = jFeatureData.Value<float>(15);
|
||||
float chinDepth = jFeatureData.Value<float>(16);
|
||||
float chinWidth = jFeatureData.Value<float>(17);
|
||||
float chinIndent = jFeatureData.Value<float>(18);
|
||||
float neckWidth = jFeatureData.Value<float>(19);
|
||||
|
||||
byte blemishes = jAppearanceData[0].Value<byte>("Value");
|
||||
float blemishesOpacity = jAppearanceData[0].Value<byte>("Opacity");
|
||||
byte facialHair = jAppearanceData[1].Value<byte>("Value");
|
||||
float facialHairOpacity = jAppearanceData[1].Value<byte>("Opacity");
|
||||
byte eyebrows = jAppearanceData[2].Value<byte>("Value");
|
||||
float eyebrowsOpacity = jAppearanceData[2].Value<byte>("Opacity");
|
||||
byte ageing = jAppearanceData[3].Value<byte>("Value");
|
||||
float ageingOpacity = jAppearanceData[3].Value<byte>("Opacity");
|
||||
byte makeup = jAppearanceData[4].Value<byte>("Value");
|
||||
float makeupOpacity = jAppearanceData[4].Value<byte>("Opacity");
|
||||
byte blush = jAppearanceData[5].Value<byte>("Value");
|
||||
float blushOpacity = jAppearanceData[5].Value<byte>("Opacity");
|
||||
byte complexion = jAppearanceData[6].Value<byte>("Value");
|
||||
float complexionOpacity = jAppearanceData[6].Value<byte>("Opacity");
|
||||
byte sunDamage = jAppearanceData[7].Value<byte>("Value");
|
||||
float sunDamageOpacity = jAppearanceData[7].Value<byte>("Opacity");
|
||||
byte lipstick = jAppearanceData[8].Value<byte>("Value");
|
||||
float lipstickOpacity = jAppearanceData[8].Value<byte>("Opacity");
|
||||
byte freckles = jAppearanceData[9].Value<byte>("Value");
|
||||
float frecklesOpacity = jAppearanceData[9].Value<byte>("Opacity");
|
||||
byte chestHair = jAppearanceData[10].Value<byte>("Value");
|
||||
float chestHairOpacity = jAppearanceData[10].Value<byte>("Opacity");
|
||||
|
||||
byte hair = jHairAndColorData.Value<byte>(0);
|
||||
byte hairColor = jHairAndColorData.Value<byte>(1);
|
||||
byte hairHighlightColor = jHairAndColorData.Value<byte>(2);
|
||||
byte eyebrowColor = jHairAndColorData.Value<byte>(3);
|
||||
byte beardColor = jHairAndColorData.Value<byte>(4);
|
||||
byte eyeColor = jHairAndColorData.Value<byte>(5);
|
||||
byte blushColor = jHairAndColorData.Value<byte>(6);
|
||||
byte lipstickColor = jHairAndColorData.Value<byte>(7);
|
||||
byte chestHairColor = jHairAndColorData.Value<byte>(8);
|
||||
|
||||
using (var saveCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = new Database.Entities.Character
|
||||
[RemoteEvent("creator_GenderChange")]
|
||||
public void changeGender(Player player, int gender)
|
||||
{
|
||||
UserId = player.GetUser().Id,
|
||||
Gender = gender,
|
||||
Father = father,
|
||||
Mother = mother,
|
||||
Similarity = similarity,
|
||||
SkinSimilarity = skinSimilarity,
|
||||
|
||||
NoseWidth = noseWidth,
|
||||
NoseBottomHeight = noseBottomHeight,
|
||||
NoseTipLength = noseTipLength,
|
||||
NoseBridgeDepth = noseBridgeDepth,
|
||||
NoseTipHeight = noseTipHeight,
|
||||
NoseBroken = noseBroken,
|
||||
BrowHeight = browHeight,
|
||||
BrowDepth = browDepth,
|
||||
CheekboneHeight = cheekboneHeight,
|
||||
CheekboneWidth = cheekboneWidth,
|
||||
CheekDepth = cheekDepth,
|
||||
EyeSize = eyeSize,
|
||||
LipThickness = lipThickness,
|
||||
JawWidth = jawWidth,
|
||||
JawShape = jawShape,
|
||||
ChinHeight = chinHeight,
|
||||
ChinDepth = chinDepth,
|
||||
ChinWidth = chinWidth,
|
||||
ChinIndent = chinIndent,
|
||||
NeckWidth = neckWidth,
|
||||
|
||||
Blemishes = blemishes,
|
||||
BlemishesOpacity = blemishesOpacity,
|
||||
FacialHair = facialHair,
|
||||
FacialHairOpacity = facialHairOpacity,
|
||||
Eyebrows = eyebrows,
|
||||
EyebrowsOpacity = eyebrowsOpacity,
|
||||
Ageing = ageing,
|
||||
AgeingOpacity = ageingOpacity,
|
||||
Makeup = makeup,
|
||||
MakeupOpacity = makeupOpacity,
|
||||
Blush = blush,
|
||||
BlushOpacity = blushOpacity,
|
||||
Complexion = complexion,
|
||||
ComplexionOpacity = complexionOpacity,
|
||||
SunDamage = sunDamage,
|
||||
SunDamageOpacity = sunDamageOpacity,
|
||||
Lipstick = lipstick,
|
||||
LipstickOpacity = lipstickOpacity,
|
||||
Freckles = freckles,
|
||||
FrecklesOpacity = frecklesOpacity,
|
||||
ChestHair = chestHair,
|
||||
ChestHairOpacity = chestHairOpacity,
|
||||
|
||||
Hair = hair,
|
||||
HairColor = hairColor,
|
||||
HairHighlightColor = hairHighlightColor,
|
||||
EyebrowColor = eyebrowColor,
|
||||
BeardColor = beardColor,
|
||||
EyeColor = eyeColor,
|
||||
BlushColor = blushColor,
|
||||
LipstickColor = lipstickColor,
|
||||
ChestHairColor = chestHairColor
|
||||
};
|
||||
|
||||
saveCharacter.Characters.Add(character);
|
||||
saveCharacter.SaveChanges();
|
||||
|
||||
var userId = player.GetUser().Id;
|
||||
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
|
||||
|
||||
user.CharacterId = character.Id;
|
||||
saveCharacter.SaveChanges();
|
||||
}
|
||||
//HeadOverlay makeupHo = new HeadOverlay()
|
||||
//{
|
||||
// Index = 0,
|
||||
// Opacity = 0.0f,
|
||||
// Color = 0,
|
||||
// SecondaryColor = 0
|
||||
//};
|
||||
//HeadOverlay blushHo = new HeadOverlay()
|
||||
//{
|
||||
// Index = 0,
|
||||
// Opacity = 0.0f,
|
||||
// Color = 0,
|
||||
// SecondaryColor = 0
|
||||
//};
|
||||
//player.SetHeadOverlay(4, makeupHo);
|
||||
//player.SetHeadOverlay(5, blushHo);
|
||||
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
player.Dimension = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wendet den Character eines Spielers auf diesen an
|
||||
/// </summary>
|
||||
/// <param name="player">Der Player, dessen Aussehen man setzen will</param>
|
||||
public static void ApplyCharacter(Player player)
|
||||
{
|
||||
var user = player.GetUser();
|
||||
using (var loadCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = loadCharacter.Characters.SingleOrDefault(c => c.Id == user.CharacterId);
|
||||
|
||||
if (character == null) return;
|
||||
|
||||
//Männlich / Weiblich
|
||||
if (character.Gender == false)
|
||||
{
|
||||
player.SetSkin(PedHash.FreemodeMale01);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetSkin(PedHash.FreemodeFemale01);
|
||||
if (gender == 0) player.SetSkin(PedHash.FreemodeMale01);
|
||||
else player.SetSkin(PedHash.FreemodeFemale01);
|
||||
}
|
||||
|
||||
//Gesichtszüge
|
||||
float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight,
|
||||
[RemoteEvent("creatorSave")]
|
||||
public void CreatorSave(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData)
|
||||
{
|
||||
var jParentData = JObject.Parse(parentData);
|
||||
var jFeatureData = JArray.Parse(featureData);
|
||||
var jAppearanceData = JArray.Parse(appearanceData);
|
||||
var jHairAndColorData = JArray.Parse(hairAndColorData);
|
||||
|
||||
byte father = jParentData.Value<byte>("Father");
|
||||
byte mother = jParentData.Value<byte>("Mother");
|
||||
float similarity = jParentData.Value<float>("Similarity");
|
||||
float skinSimilarity = jParentData.Value<float>("SkinSimilarity");
|
||||
|
||||
float noseWidth = jFeatureData.Value<float>(0);
|
||||
float noseBottomHeight = jFeatureData.Value<float>(1);
|
||||
float noseTipLength = jFeatureData.Value<float>(2);
|
||||
float noseBridgeDepth = jFeatureData.Value<float>(3);
|
||||
float noseTipHeight = jFeatureData.Value<float>(4);
|
||||
float noseBroken = jFeatureData.Value<float>(5);
|
||||
float browHeight = jFeatureData.Value<float>(6);
|
||||
float browDepth = jFeatureData.Value<float>(7);
|
||||
float cheekboneHeight = jFeatureData.Value<float>(8);
|
||||
float cheekboneWidth = jFeatureData.Value<float>(9);
|
||||
float cheekDepth = jFeatureData.Value<float>(10);
|
||||
float eyeSize = jFeatureData.Value<float>(11);
|
||||
float lipThickness = jFeatureData.Value<float>(12);
|
||||
float jawWidth = jFeatureData.Value<float>(13);
|
||||
float jawShape = jFeatureData.Value<float>(14);
|
||||
float chinHeight = jFeatureData.Value<float>(15);
|
||||
float chinDepth = jFeatureData.Value<float>(16);
|
||||
float chinWidth = jFeatureData.Value<float>(17);
|
||||
float chinIndent = jFeatureData.Value<float>(18);
|
||||
float neckWidth = jFeatureData.Value<float>(19);
|
||||
|
||||
byte blemishes = jAppearanceData[0].Value<byte>("Value");
|
||||
float blemishesOpacity = jAppearanceData[0].Value<byte>("Opacity");
|
||||
byte facialHair = jAppearanceData[1].Value<byte>("Value");
|
||||
float facialHairOpacity = jAppearanceData[1].Value<byte>("Opacity");
|
||||
byte eyebrows = jAppearanceData[2].Value<byte>("Value");
|
||||
float eyebrowsOpacity = jAppearanceData[2].Value<byte>("Opacity");
|
||||
byte ageing = jAppearanceData[3].Value<byte>("Value");
|
||||
float ageingOpacity = jAppearanceData[3].Value<byte>("Opacity");
|
||||
byte makeup = jAppearanceData[4].Value<byte>("Value");
|
||||
float makeupOpacity = jAppearanceData[4].Value<byte>("Opacity");
|
||||
byte blush = jAppearanceData[5].Value<byte>("Value");
|
||||
float blushOpacity = jAppearanceData[5].Value<byte>("Opacity");
|
||||
byte complexion = jAppearanceData[6].Value<byte>("Value");
|
||||
float complexionOpacity = jAppearanceData[6].Value<byte>("Opacity");
|
||||
byte sunDamage = jAppearanceData[7].Value<byte>("Value");
|
||||
float sunDamageOpacity = jAppearanceData[7].Value<byte>("Opacity");
|
||||
byte lipstick = jAppearanceData[8].Value<byte>("Value");
|
||||
float lipstickOpacity = jAppearanceData[8].Value<byte>("Opacity");
|
||||
byte freckles = jAppearanceData[9].Value<byte>("Value");
|
||||
float frecklesOpacity = jAppearanceData[9].Value<byte>("Opacity");
|
||||
byte chestHair = jAppearanceData[10].Value<byte>("Value");
|
||||
float chestHairOpacity = jAppearanceData[10].Value<byte>("Opacity");
|
||||
|
||||
byte hair = jHairAndColorData.Value<byte>(0);
|
||||
byte hairColor = jHairAndColorData.Value<byte>(1);
|
||||
byte hairHighlightColor = jHairAndColorData.Value<byte>(2);
|
||||
byte eyebrowColor = jHairAndColorData.Value<byte>(3);
|
||||
byte beardColor = jHairAndColorData.Value<byte>(4);
|
||||
byte eyeColor = jHairAndColorData.Value<byte>(5);
|
||||
byte blushColor = jHairAndColorData.Value<byte>(6);
|
||||
byte lipstickColor = jHairAndColorData.Value<byte>(7);
|
||||
byte chestHairColor = jHairAndColorData.Value<byte>(8);
|
||||
|
||||
using (var saveCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = new Database.Entities.Character
|
||||
{
|
||||
UserId = player.GetUser().Id,
|
||||
Gender = gender,
|
||||
Father = father,
|
||||
Mother = mother,
|
||||
Similarity = similarity,
|
||||
SkinSimilarity = skinSimilarity,
|
||||
|
||||
NoseWidth = noseWidth,
|
||||
NoseBottomHeight = noseBottomHeight,
|
||||
NoseTipLength = noseTipLength,
|
||||
NoseBridgeDepth = noseBridgeDepth,
|
||||
NoseTipHeight = noseTipHeight,
|
||||
NoseBroken = noseBroken,
|
||||
BrowHeight = browHeight,
|
||||
BrowDepth = browDepth,
|
||||
CheekboneHeight = cheekboneHeight,
|
||||
CheekboneWidth = cheekboneWidth,
|
||||
CheekDepth = cheekDepth,
|
||||
EyeSize = eyeSize,
|
||||
LipThickness = lipThickness,
|
||||
JawWidth = jawWidth,
|
||||
JawShape = jawShape,
|
||||
ChinHeight = chinHeight,
|
||||
ChinDepth = chinDepth,
|
||||
ChinWidth = chinWidth,
|
||||
ChinIndent = chinIndent,
|
||||
NeckWidth = neckWidth,
|
||||
|
||||
Blemishes = blemishes,
|
||||
BlemishesOpacity = blemishesOpacity,
|
||||
FacialHair = facialHair,
|
||||
FacialHairOpacity = facialHairOpacity,
|
||||
Eyebrows = eyebrows,
|
||||
EyebrowsOpacity = eyebrowsOpacity,
|
||||
Ageing = ageing,
|
||||
AgeingOpacity = ageingOpacity,
|
||||
Makeup = makeup,
|
||||
MakeupOpacity = makeupOpacity,
|
||||
Blush = blush,
|
||||
BlushOpacity = blushOpacity,
|
||||
Complexion = complexion,
|
||||
ComplexionOpacity = complexionOpacity,
|
||||
SunDamage = sunDamage,
|
||||
SunDamageOpacity = sunDamageOpacity,
|
||||
Lipstick = lipstick,
|
||||
LipstickOpacity = lipstickOpacity,
|
||||
Freckles = freckles,
|
||||
FrecklesOpacity = frecklesOpacity,
|
||||
ChestHair = chestHair,
|
||||
ChestHairOpacity = chestHairOpacity,
|
||||
|
||||
Hair = hair,
|
||||
HairColor = hairColor,
|
||||
HairHighlightColor = hairHighlightColor,
|
||||
EyebrowColor = eyebrowColor,
|
||||
BeardColor = beardColor,
|
||||
EyeColor = eyeColor,
|
||||
BlushColor = blushColor,
|
||||
LipstickColor = lipstickColor,
|
||||
ChestHairColor = chestHairColor
|
||||
};
|
||||
|
||||
saveCharacter.Characters.Add(character);
|
||||
saveCharacter.SaveChanges();
|
||||
|
||||
var userId = player.GetUser().Id;
|
||||
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
|
||||
|
||||
user.CharacterId = character.Id;
|
||||
saveCharacter.SaveChanges();
|
||||
}
|
||||
//HeadOverlay makeupHo = new HeadOverlay()
|
||||
//{
|
||||
// Index = 0,
|
||||
// Opacity = 0.0f,
|
||||
// Color = 0,
|
||||
// SecondaryColor = 0
|
||||
//};
|
||||
//HeadOverlay blushHo = new HeadOverlay()
|
||||
//{
|
||||
// Index = 0,
|
||||
// Opacity = 0.0f,
|
||||
// Color = 0,
|
||||
// SecondaryColor = 0
|
||||
//};
|
||||
//player.SetHeadOverlay(4, makeupHo);
|
||||
//player.SetHeadOverlay(5, blushHo);
|
||||
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
player.Dimension = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wendet den Character eines Spielers auf diesen an
|
||||
/// </summary>
|
||||
/// <param name="player">Der Player, dessen Aussehen man setzen will</param>
|
||||
public static void ApplyCharacter(Player player)
|
||||
{
|
||||
var user = player.GetUser();
|
||||
using (var loadCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = loadCharacter.Characters.SingleOrDefault(c => c.Id == user.CharacterId);
|
||||
|
||||
if (character == null) return;
|
||||
|
||||
//Männlich / Weiblich
|
||||
if (character.Gender == false)
|
||||
{
|
||||
player.SetSkin(PedHash.FreemodeMale01);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetSkin(PedHash.FreemodeFemale01);
|
||||
}
|
||||
|
||||
//Gesichtszüge
|
||||
float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight,
|
||||
character.NoseBroken, character.BrowHeight, character.BrowDepth, character.CheekboneHeight, character.CheekboneWidth,
|
||||
character.CheekboneWidth, character.CheekDepth, character.EyeSize, character.LipThickness, character.JawWidth,
|
||||
character.JawShape, character.ChinHeight, character.ChinDepth, character.ChinWidth, character.ChinIndent, character.NeckWidth };
|
||||
|
||||
for (var i = 0; i < faceFeatures.Length; i++)
|
||||
{
|
||||
player.SetFaceFeature(i, faceFeatures[i]);
|
||||
for (var i = 0; i < faceFeatures.Length; i++)
|
||||
{
|
||||
player.SetFaceFeature(i, faceFeatures[i]);
|
||||
}
|
||||
|
||||
//Gesichtsmerkmale
|
||||
HeadOverlay blemishes = new HeadOverlay()
|
||||
{
|
||||
Index = character.Blemishes,
|
||||
Opacity = character.BlemishesOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay facialHair = new HeadOverlay()
|
||||
{
|
||||
Index = character.FacialHair,
|
||||
Opacity = character.FacialHairOpacity,
|
||||
Color = character.BeardColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay eyebrows = new HeadOverlay()
|
||||
{
|
||||
Index = character.Eyebrows,
|
||||
Opacity = character.EyebrowsOpacity,
|
||||
Color = character.EyebrowColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay ageing = new HeadOverlay()
|
||||
{
|
||||
Index = character.Ageing,
|
||||
Opacity = character.AgeingOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay makeup = new HeadOverlay()
|
||||
{
|
||||
Index = character.Makeup,
|
||||
Opacity = character.MakeupOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay blush = new HeadOverlay()
|
||||
{
|
||||
Index = character.Blush,
|
||||
Opacity = character.BlushOpacity,
|
||||
Color = character.BlushColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay complexion = new HeadOverlay()
|
||||
{
|
||||
Index = character.Complexion,
|
||||
Opacity = character.ComplexionOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay sunDamage = new HeadOverlay()
|
||||
{
|
||||
Index = character.SunDamage,
|
||||
Opacity = character.SunDamageOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay lipstick = new HeadOverlay()
|
||||
{
|
||||
Index = character.Lipstick,
|
||||
Opacity = character.LipstickOpacity,
|
||||
Color = character.LipstickColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay freckles = new HeadOverlay()
|
||||
{
|
||||
Index = character.Freckles,
|
||||
Opacity = character.FrecklesOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay chestHair = new HeadOverlay()
|
||||
{
|
||||
Index = character.ChestHair,
|
||||
Opacity = character.ChestHairOpacity,
|
||||
Color = character.ChestHairColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
|
||||
player.SetHeadOverlay(0, blemishes);
|
||||
player.SetHeadOverlay(1, facialHair);
|
||||
player.SetHeadOverlay(2, eyebrows);
|
||||
player.SetHeadOverlay(3, ageing);
|
||||
player.SetHeadOverlay(4, makeup);
|
||||
player.SetHeadOverlay(5, blush);
|
||||
player.SetHeadOverlay(6, complexion);
|
||||
player.SetHeadOverlay(7, sunDamage);
|
||||
player.SetHeadOverlay(8, lipstick);
|
||||
player.SetHeadOverlay(9, freckles);
|
||||
player.SetHeadOverlay(10, chestHair);
|
||||
player.SetHeadOverlay(11, blemishes);
|
||||
player.SetHeadOverlay(12, blemishes);
|
||||
|
||||
//Gesicht (Vererbung durch Mutter / Vater)
|
||||
HeadBlend headBlend = new HeadBlend()
|
||||
{
|
||||
ShapeFirst = character.Mother,
|
||||
ShapeSecond = character.Father,
|
||||
ShapeThird = 0,
|
||||
SkinFirst = character.Mother,
|
||||
SkinSecond = character.Father,
|
||||
SkinThird = 0,
|
||||
ShapeMix = character.Similarity,
|
||||
SkinMix = character.SkinSimilarity,
|
||||
ThirdMix = 0.0f
|
||||
};
|
||||
NAPI.Player.SetPlayerHeadBlend(player, headBlend);
|
||||
|
||||
//Haare und Haarfarbe
|
||||
player.SetClothes(2, character.Hair, 0);
|
||||
NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor);
|
||||
|
||||
//Augenfarbe
|
||||
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
|
||||
}
|
||||
}
|
||||
|
||||
//Gesichtsmerkmale
|
||||
HeadOverlay blemishes = new HeadOverlay()
|
||||
{
|
||||
Index = character.Blemishes,
|
||||
Opacity = character.BlemishesOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay facialHair = new HeadOverlay()
|
||||
{
|
||||
Index = character.FacialHair,
|
||||
Opacity = character.FacialHairOpacity,
|
||||
Color = character.BeardColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay eyebrows = new HeadOverlay()
|
||||
{
|
||||
Index = character.Eyebrows,
|
||||
Opacity = character.EyebrowsOpacity,
|
||||
Color = character.EyebrowColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay ageing = new HeadOverlay()
|
||||
{
|
||||
Index = character.Ageing,
|
||||
Opacity = character.AgeingOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay makeup = new HeadOverlay()
|
||||
{
|
||||
Index = character.Makeup,
|
||||
Opacity = character.MakeupOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay blush = new HeadOverlay()
|
||||
{
|
||||
Index = character.Blush,
|
||||
Opacity = character.BlushOpacity,
|
||||
Color = character.BlushColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay complexion = new HeadOverlay()
|
||||
{
|
||||
Index = character.Complexion,
|
||||
Opacity = character.ComplexionOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay sunDamage = new HeadOverlay()
|
||||
{
|
||||
Index = character.SunDamage,
|
||||
Opacity = character.SunDamageOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay lipstick = new HeadOverlay()
|
||||
{
|
||||
Index = character.Lipstick,
|
||||
Opacity = character.LipstickOpacity,
|
||||
Color = character.LipstickColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay freckles = new HeadOverlay()
|
||||
{
|
||||
Index = character.Freckles,
|
||||
Opacity = character.FrecklesOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay chestHair = new HeadOverlay()
|
||||
{
|
||||
Index = character.ChestHair,
|
||||
Opacity = character.ChestHairOpacity,
|
||||
Color = character.ChestHairColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
|
||||
player.SetHeadOverlay(0, blemishes);
|
||||
player.SetHeadOverlay(1, facialHair);
|
||||
player.SetHeadOverlay(2, eyebrows);
|
||||
player.SetHeadOverlay(3, ageing);
|
||||
player.SetHeadOverlay(4, makeup);
|
||||
player.SetHeadOverlay(5, blush);
|
||||
player.SetHeadOverlay(6, complexion);
|
||||
player.SetHeadOverlay(7, sunDamage);
|
||||
player.SetHeadOverlay(8, lipstick);
|
||||
player.SetHeadOverlay(9, freckles);
|
||||
player.SetHeadOverlay(10, chestHair);
|
||||
player.SetHeadOverlay(11, blemishes);
|
||||
player.SetHeadOverlay(12, blemishes);
|
||||
|
||||
|
||||
//Gesicht (Vererbung durch Mutter / Vater)
|
||||
HeadBlend headBlend = new HeadBlend()
|
||||
{
|
||||
ShapeFirst = character.Mother,
|
||||
ShapeSecond = character.Father,
|
||||
ShapeThird = 0,
|
||||
SkinFirst = character.Mother,
|
||||
SkinSecond = character.Father,
|
||||
SkinThird = 0,
|
||||
ShapeMix = character.Similarity,
|
||||
SkinMix = character.SkinSimilarity,
|
||||
ThirdMix = 0.0f
|
||||
};
|
||||
NAPI.Player.SetPlayerHeadBlend(player, headBlend);
|
||||
|
||||
//Haare und Haarfarbe
|
||||
player.SetClothes(2, character.Hair, 0);
|
||||
NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor);
|
||||
|
||||
//Augenfarbe
|
||||
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
class CityHallManager : Script
|
||||
internal class CityHallManager : Script
|
||||
{
|
||||
private static readonly Vector3 _cityHallPosition = new Vector3(273.22, -278.14, 53.9);
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Managers BankManager (BankManager.cs)
|
||||
* @author VegaZ
|
||||
@@ -16,71 +15,71 @@ using ReallifeGamemode.Server.Types;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class DoorManager : Script
|
||||
{
|
||||
private static Dictionary<int, NetHandle> _doorColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static void LoadDoors()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (Door door in dbContext.Doors)
|
||||
private static Dictionary<int, NetHandle> _doorColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static void LoadDoors()
|
||||
{
|
||||
_doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (Door door in dbContext.Doors)
|
||||
{
|
||||
_doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReloadDoors()
|
||||
{
|
||||
foreach (var doorPair in _doorColShapes)
|
||||
{
|
||||
doorPair.Value.Entity<ColShape>().Delete();
|
||||
}
|
||||
_doorColShapes.Clear();
|
||||
LoadDoors();
|
||||
}
|
||||
|
||||
public static void ChangeDoorState(Player player)
|
||||
{
|
||||
var user = player.GetUser();
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
IQueryable<Door> NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius);
|
||||
foreach (Door d in NearDoors)
|
||||
public static void ReloadDoors()
|
||||
{
|
||||
if (!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
||||
{
|
||||
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
||||
player.SendNotification(lockState, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
d.Locked = !d.Locked;
|
||||
|
||||
string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen";
|
||||
|
||||
player.SendNotification(notStr, true);
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f));
|
||||
foreach (var doorPair in _doorColShapes)
|
||||
{
|
||||
doorPair.Value.Entity<ColShape>().Delete();
|
||||
}
|
||||
_doorColShapes.Clear();
|
||||
LoadDoors();
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterColshape)]
|
||||
public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Player player)
|
||||
{
|
||||
if (_doorColShapes.ContainsValue(colShape.Handle))
|
||||
{
|
||||
int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
public static void ChangeDoorState(Player player)
|
||||
{
|
||||
Door door = dbContext.Doors.Where(d => d.Id == doorId).First();
|
||||
player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f);
|
||||
var user = player.GetUser();
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
IQueryable<Door> NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius);
|
||||
foreach (Door d in NearDoors)
|
||||
{
|
||||
if (!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
||||
{
|
||||
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
||||
player.SendNotification(lockState, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
d.Locked = !d.Locked;
|
||||
|
||||
string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen";
|
||||
|
||||
player.SendNotification(notStr, true);
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterColshape)]
|
||||
public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Player player)
|
||||
{
|
||||
if (_doorColShapes.ContainsValue(colShape.Handle))
|
||||
{
|
||||
int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Door door = dbContext.Doors.Where(d => d.Id == doorId).First();
|
||||
player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user