corvex seine sachen drauf + hitmarker test
This commit is contained in:
@@ -43,6 +43,9 @@ const chatbox = mp.browsers.new("package://assets/html/chat/index.html");
|
||||
chatbox.markAsChat();
|
||||
|
||||
require('./Gui/house');
|
||||
require('./util/vMachines');
|
||||
require('./util/vVehicleDamage');
|
||||
require('./util/hitmarker');
|
||||
|
||||
import vehicleEntering from './vehiclesync/entering';
|
||||
vehicleEntering(globalData);
|
||||
|
||||
40
ReallifeGamemode.Client/util/hitmarker.ts
Normal file
40
ReallifeGamemode.Client/util/hitmarker.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
class HitObject {
|
||||
amount: number;
|
||||
position: Vector3Mp;
|
||||
count: number = 0;
|
||||
|
||||
constructor(amount: number, position: Vector3Mp) {
|
||||
this.amount = amount;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
class HitText {
|
||||
list: HitObject[] = [];
|
||||
|
||||
add(amount: number, position: Vector3Mp) {
|
||||
this.list.push(new HitObject(amount, position));
|
||||
}
|
||||
|
||||
render() {
|
||||
this.list.forEach((element: HitObject) => {
|
||||
|
||||
mp.game.graphics.drawText(element.amount.toString(), [element.position.x, element.position.y, element.position.z + 1.4], { font: 2, centre: true, color: [255, 255, 255, 155 - element.count], scale: [0.3, 0.3], outline: true });
|
||||
element.count += 3;
|
||||
element.position.z += 0.03;
|
||||
|
||||
if (element.count > 155) {
|
||||
var find = Hits.list.findIndex(elemen => elemen == element);
|
||||
|
||||
Hits.list.splice(find, 1);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var Hits = new HitText();
|
||||
|
||||
mp.events.add(RageEnums.EventKey.RENDER, () => {
|
||||
Hits.render();
|
||||
});
|
||||
251
ReallifeGamemode.Client/util/vMachines.ts
Normal file
251
ReallifeGamemode.Client/util/vMachines.ts
Normal file
@@ -0,0 +1,251 @@
|
||||
export class vMachines
|
||||
{
|
||||
public Player: PlayerMp = mp.players.local;
|
||||
public IsUsingVendingMachine: boolean = false;
|
||||
|
||||
private VMANIM: vMachinesAnim = new vMachinesAnim(this);
|
||||
|
||||
public VendingMachineHashes =
|
||||
[
|
||||
mp.game.gameplay.getHashKey("prop_vend_coffe_01"),
|
||||
mp.game.gameplay.getHashKey("prop_vend_snak_01"),
|
||||
mp.game.gameplay.getHashKey("prop_vend_snak_01_tu"),
|
||||
mp.game.gameplay.getHashKey("prop_vend_soda_01"),
|
||||
mp.game.gameplay.getHashKey("prop_vend_soda_02"),
|
||||
mp.game.gameplay.getHashKey("prop_vend_water_01")
|
||||
];
|
||||
|
||||
public IsNearVendingMachine = () : boolean =>
|
||||
{
|
||||
return this.GetNearestVendingMachineToPlayer() != -1;
|
||||
}
|
||||
|
||||
public GetOffsetWorldCoordinateForVendingMachine = (handle: number) : Vector3Mp =>
|
||||
{
|
||||
if(handle === -1)
|
||||
return new mp.Vector3(-1, -1, -1);
|
||||
return mp.game.invokeVector3(vMachinesConst.GetOffsetFromEntityInWorldCoords, handle, 0, -1, 0) as Vector3Mp;
|
||||
}
|
||||
|
||||
public GetEntityHeading = (handle: number) : number =>
|
||||
{
|
||||
if(handle === -1)
|
||||
return -1;
|
||||
let a = mp.game.invokeFloat(vMachinesConst.GetEntityHeading, handle) as number;
|
||||
return a;
|
||||
}
|
||||
|
||||
public GetNearestVendingMachineToPlayer = () : number =>
|
||||
{
|
||||
for(let hash of this.VendingMachineHashes)
|
||||
{
|
||||
var handle = mp.game.object.getClosestObjectOfType(this.Player.position.x, this.Player.position.y, this.Player.position.z, 0.70, hash, false, false, false);
|
||||
|
||||
if(mp.game.entity.isAnEntity(handle))
|
||||
return handle;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public TriggerVendingMachine = () : boolean =>
|
||||
{
|
||||
let handle = this.GetNearestVendingMachineToPlayer();
|
||||
let coordinates = this.GetOffsetWorldCoordinateForVendingMachine(handle);
|
||||
|
||||
if(this.IsUsingVendingMachine || handle === -1 || (coordinates.x === -1 && coordinates.y === -1 && coordinates.z === -1) || this.IsVendingMachineInUse(handle))
|
||||
return false;
|
||||
|
||||
this.SetVendingMachineStateRemote(handle)
|
||||
|
||||
mp.game.invoke(vMachinesConst.SetPedCurrentWeaponVisible, this.Player.handle, false, true, true, true);
|
||||
mp.game.invoke(vMachinesConst.SetPedStealthMovement, this.Player.handle, false, 'DEFAULT_ACTION');
|
||||
//mp.game.invoke(vMachinesConst.AiTaskLookAtEntity, this.Player.handle, handle, 2000, 2048, 3);
|
||||
mp.game.invoke(vMachinesConst.SetPedResetFlag, this.Player.handle, 322, true);
|
||||
//mp.game.invoke(vMachinesConst.AiTaskGoStraightToCoord, this.Player.handle, coordinates.x, coordinates.y, coordinates.z, 1, 20000, this.GetEntityHeading(handle), 0.1)
|
||||
|
||||
/*while(this.Player.getScriptTaskStatus(2106541073) != 7 && !this.Player.isAtCoord(coordinates.x, coordinates.z, coordinates.y, 0.1, 0, 0, false, true, 0))
|
||||
mp.game.wait(0); */
|
||||
|
||||
this.VMANIM.BeginAnimation();
|
||||
return true;
|
||||
}
|
||||
|
||||
public InteractionCheck = () =>
|
||||
{
|
||||
if( mp.game.controls.isControlJustPressed(vMachinesConst.INPUT_GROUP_ALL, vMachinesConst.CONTROL_CONTEXT)
|
||||
&& !this.IsUsingVendingMachine
|
||||
&& this.IsNearVendingMachine()
|
||||
&& !this.IsVendingMachineInUse(this.GetNearestVendingMachineToPlayer()))
|
||||
{
|
||||
this.SetVendingMachineUseState(true);
|
||||
}
|
||||
if( mp.game.controls.isControlJustPressed(vMachinesConst.INPUT_GROUP_ALL, vMachinesConst.CONTROL_FRONTENDCANCEL)
|
||||
&& this.IsUsingVendingMachine)
|
||||
{
|
||||
this.SetVendingMachineUseState(false);
|
||||
}
|
||||
}
|
||||
|
||||
public SetVendingMachineUseState = (State: boolean) =>
|
||||
{
|
||||
if(State && this.TriggerVendingMachine())
|
||||
this.IsUsingVendingMachine = State;
|
||||
else
|
||||
{
|
||||
this.Player.clearTasksImmediately();
|
||||
this.SetVendingMachineStateRemote(-1)
|
||||
this.IsUsingVendingMachine = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SetVendingMachineStateRemote = (handle: number) =>
|
||||
{
|
||||
if(this.Player.getVariable('IsUsingVendingMachine') != handle)
|
||||
{
|
||||
mp.events.callRemote('vendingMachine.Remote.SharedData', 'IsUsingVendingMachine', handle);
|
||||
|
||||
while(this.Player.getVariable('IsUsingVendingMachine') != handle)
|
||||
mp.game.wait(0);
|
||||
}
|
||||
}
|
||||
|
||||
public IsVendingMachineInUse = (handle: number) : boolean =>
|
||||
{
|
||||
return mp.players.streamed.some(p => p.getVariable('IsUsingVendingMachine') === handle);
|
||||
}
|
||||
|
||||
public Update = (nametags: any) =>
|
||||
{
|
||||
if(!this.IsUsingVendingMachine)
|
||||
{
|
||||
if(this.IsNearVendingMachine())
|
||||
vMachinesUI.Show();
|
||||
this.InteractionCheck();
|
||||
}
|
||||
this.VMANIM.UpdateAnimation();
|
||||
}
|
||||
|
||||
public constructor()
|
||||
{
|
||||
mp.events.add('render', this.Update);
|
||||
}
|
||||
}
|
||||
|
||||
class vMachinesConst
|
||||
{
|
||||
public static readonly ANIMATION_DICTIONARY_STRING = "MINI@SPRUNK@FIRST_PERSON";
|
||||
public static readonly ANIMATION_BUY_DRINK_PART1 = "PLYR_BUY_DRINK_PT1";
|
||||
public static readonly ANIMATION_BUY_DRINK_PART2 = "PLYR_BUY_DRINK_PT2";
|
||||
public static readonly ANIMATION_BUY_DRINK_PART3 = "PLYR_BUY_DRINK_PT3";
|
||||
public static readonly AUDIO_BANK_VENDING_MACHINE = "VENDING_MACHINE";
|
||||
public static readonly INPUT_GROUP_ALL = 2;
|
||||
public static readonly CONTROL_CONTEXT = 51;
|
||||
public static readonly CONTROL_FRONTENDCANCEL = 202;
|
||||
|
||||
//NATIVES
|
||||
public static readonly SET_PED_FAST_ANIMATIONS = '0x2208438012482A1A';
|
||||
public static readonly GetOffsetFromEntityInWorldCoords = '0x1899F328B0E12848';
|
||||
public static readonly GetEntityHeading = '0xE83D4F9BA2A38914';
|
||||
public static readonly ReleaseAmbientAudioBank = '0x65475A218FFAA93D'
|
||||
public static readonly SetPedCurrentWeaponVisible = '0x725A4CCFDED9A70';
|
||||
public static readonly AiTaskLookAtEntity = '0x69F4BE8C8CC4796C'
|
||||
public static readonly SetPedResetFlag = '0xC1E8A365BF3B29F2'
|
||||
public static readonly AiTaskGoStraightToCoord = '0xD76B57B44F1E6F8B'
|
||||
public static readonly SetPedStealthMovement = '0x88CBB5CEB96B7BD2';
|
||||
public static readonly GetEntityModel = '0x9F47B058362C84B5';
|
||||
}
|
||||
|
||||
class vMachinesAnim
|
||||
{
|
||||
private Machines: vMachines;
|
||||
private IsAnimDictLoaded: boolean = false;
|
||||
|
||||
public constructor(Machines: vMachines)
|
||||
{
|
||||
this.Machines = Machines;
|
||||
}
|
||||
|
||||
public BeginAnimation = () =>
|
||||
{
|
||||
mp.game.streaming.requestAnimDict(vMachinesConst.ANIMATION_DICTIONARY_STRING);
|
||||
mp.game.audio.requestAmbientAudioBank(vMachinesConst.AUDIO_BANK_VENDING_MACHINE, false);
|
||||
|
||||
while((this.IsAnimDictLoaded = mp.game.streaming.hasAnimDictLoaded(vMachinesConst.ANIMATION_DICTIONARY_STRING)) === false)
|
||||
mp.game.wait(0);
|
||||
|
||||
this.Machines.Player.taskPlayAnim(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART1, 2, -4, -1, 1048576, 0, false, false, false);
|
||||
}
|
||||
|
||||
public UpdateAnimation = () =>
|
||||
{
|
||||
if(!this.IsAnimDictLoaded)
|
||||
return;
|
||||
|
||||
if(this.Machines.Player.isPlayingAnim(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART1, 1))
|
||||
{
|
||||
if(this.Machines.Player.getAnimCurrentTime(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART1) > 0.1)
|
||||
vMachinesObjects.AttachObject("ng_proc_sodacan_01a");
|
||||
|
||||
if(this.Machines.Player.getAnimCurrentTime(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART1) > 0.95)
|
||||
{
|
||||
this.Machines.Player.taskPlayAnim(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART2, 4, -1000, -1, 1048576, 0, false, false, false);
|
||||
mp.game.invoke(vMachinesConst.SET_PED_FAST_ANIMATIONS, this.Machines.Player.handle, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.Machines.Player.isPlayingAnim(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART2, 1))
|
||||
{
|
||||
if(this.Machines.Player.getAnimCurrentTime(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART2) > 0.95)
|
||||
{
|
||||
this.Machines.Player.taskPlayAnim(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART3, 1000, -4, -1, 1048624, 0, false, false, false);
|
||||
mp.game.invoke(vMachinesConst.SET_PED_FAST_ANIMATIONS, this.Machines.Player.handle, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.Machines.Player.isPlayingAnim(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART3, 1))
|
||||
{
|
||||
if(this.Machines.Player.getAnimCurrentTime(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART3) > 0.1)
|
||||
vMachinesObjects.DetachObject("ng_proc_sodacan_01a");
|
||||
|
||||
if(this.Machines.Player.getAnimCurrentTime(vMachinesConst.ANIMATION_DICTIONARY_STRING, vMachinesConst.ANIMATION_BUY_DRINK_PART3) > 0.95)
|
||||
this.EndAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
public EndAnimation = () =>
|
||||
{
|
||||
mp.game.streaming.removeAnimDict(vMachinesConst.ANIMATION_DICTIONARY_STRING);
|
||||
mp.game.invoke(vMachinesConst.ReleaseAmbientAudioBank);
|
||||
this.Machines.SetVendingMachineUseState(false);
|
||||
mp.events.callRemote('vendingMachines.Remote.Finish');
|
||||
}
|
||||
}
|
||||
|
||||
class vMachinesUI
|
||||
{
|
||||
private static readonly INTERACT_HELP_TEXT: string = "~h~Drücke ~g~ ~INPUT_CONTEXT~ ~s~ um etwas zu Kaufen!";
|
||||
|
||||
public static Show = () =>
|
||||
{
|
||||
var Text = vMachinesUI.INTERACT_HELP_TEXT;
|
||||
mp.game.ui.setTextComponentFormat("STRING");
|
||||
mp.game.ui.addTextComponentSubstringPlayerName(Text);
|
||||
mp.game.ui.displayHelpTextFromStringLabel(0, false, true, -1);
|
||||
}
|
||||
}
|
||||
|
||||
class vMachinesObjects
|
||||
{
|
||||
public static AttachObject = (objectName: string) =>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static DetachObject = (objectName: string) =>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const Machines = new vMachines();
|
||||
43
ReallifeGamemode.Client/util/vVehicleDamage.ts
Normal file
43
ReallifeGamemode.Client/util/vVehicleDamage.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
export class vVehicleDamage
|
||||
{
|
||||
public OnEntityStreamIn = (entity: EntityMp) =>
|
||||
{
|
||||
if(entity.isAVehicle())
|
||||
{
|
||||
let car = entity as VehicleMp;
|
||||
car.setDisablePetrolTankDamage(true);
|
||||
car.setDisablePetrolTankFires(true);
|
||||
}
|
||||
}
|
||||
|
||||
public OnUpdate = (nametags: any) =>
|
||||
{
|
||||
for(let veh of mp.vehicles.streamed)
|
||||
{
|
||||
if(veh == undefined)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
if(veh.getEngineHealth() < 0 || veh.getHealth() <= 250)
|
||||
{
|
||||
veh.setEngineHealth(0);
|
||||
veh.setEngineOn(false, true, false);
|
||||
}
|
||||
else if(veh.getEngineHealth() < 1000 && veh.getHealth() > 250)
|
||||
{
|
||||
veh.setEngineHealth(1000);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
public constructor()
|
||||
{
|
||||
mp.events.add('entityStreamIn', this.OnEntityStreamIn);
|
||||
mp.events.add('render', this.OnUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
const PetrolDamage = new vVehicleDamage();
|
||||
19
ReallifeGamemode.Server/Util/vMachinesRemote.cs
Normal file
19
ReallifeGamemode.Server/Util/vMachinesRemote.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using GTANetworkAPI;
|
||||
|
||||
public class vMachnesRemote : Script
|
||||
{
|
||||
//IMPORTANT: THIS EVENT IS REQUIRED!
|
||||
[RemoteEvent("vendingMachine.Remote.SharedData")]
|
||||
public void UpdatePlayerData(Player player, string key, object data)
|
||||
{
|
||||
player.SetSharedData(key, data);
|
||||
}
|
||||
|
||||
//This event gets fired once the Animation finished playing. You can for example use it, to give a Player Health etc.
|
||||
[RemoteEvent("vendingMachines.Remote.Finish")]
|
||||
public void OnVendingMachineInteractionFinish(Player player)
|
||||
{
|
||||
var health = (player.Health + 25 < 100 ? player.Health + 25 : 100);
|
||||
NAPI.Player.SetPlayerHealth(player, health);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user