Vehicle Damage System (Stall System) For Redage RP V 0.3.7:
My English is not very good and i can write russian but its very helpful for rp servers
in this topic we have new notification system for redage + Vehicle System Damage.
Server Side:
Files is with is Server with In: NeptuneEvo / Core / Vehicle.cs
Note: With "HEALTHVEHICLE" Data You Can shair It to your client and use it on your hud.(hud with vehicle damaged is my next topic)
After That Paste This Codes In All Location You have (Engine On) notification in Vehicle.cs where to have this code: switch (NAPI.Data.GetEntityData(vehicle, "ACCESS")) , Like
Code you must copy there:
All in Server Side done, and for fix vehicle we have mechanic job.
Client Side:
Add This code in your Main index.js in Client side:
All Done
My English is not very good and i can write russian but its very helpful for rp servers
in this topic we have new notification system for redage + Vehicle System Damage.
Server Side:
Files is with is Server with In: NeptuneEvo / Core / Vehicle.cs
C#:
[ServerEvent (Event.VehicleDamage)]
public void OnVehicleDamageHandler (Vehicle entity, float bodyHealthLoss, float engineHealthLoss)
{
List <Vehicle> allVehicles = NAPI.Pools.GetAllVehicles ();
if (allVehicles.Count == 0) return;
foreach (Vehicle veh in allVehicles)
{
var players = NAPI.Pools.GetAllPlayers ();
foreach (var player in players)
{
if (veh.Health> = 800)
{
if (player.IsInVehicle)
{
if (player.Vehicle == veh)
{
if (player.VehicleSeat == -1)
{
int damagged = (int) veh.Health;
var rnd = new Random ();
var damage = rnd.Next (5, 10);
veh.Health - = damage;
veh.SetSharedData ("HEALTHVEHICLE", damagged);
player.TriggerEvent ("createNewHeadNotificationAdvanced", "-" + damage + "Damaged" + "~ r ~ Health =" + veh.Health);
}
}
}
}
else if (veh.Health <800)
{
if (player.IsInVehicle)
{
if (player.Vehicle == veh)
{
if (player.VehicleSeat == -1)
{
var rndm = new Random ();
var emkan = rndm.Next (1, 10);
if (emkan> 6)
{
if (! NAPI.Data.HasEntityData (player.Vehicle, "vehicle_colision"))
{
player.TriggerEvent ("createNewHeadNotificationAdvanced", "~ r ~ Vehicle Damaged, ~ g ~ Try again");
NAPI.Data.SetEntityData (veh, "vehicle_colision", true);
NAPI.Vehicle.SetVehicleEngineStatus (veh, false);
var damage = rndm.Next (5, 7);
veh.Health - = damage;
int random_timer = rndm.Next (15, 45);
int damagged = (int) veh.Health;
veh.SetSharedData ("HEALTHVEHICLE", damagged);
NAPI.Task.Run (() =>
{
NAPI.Data.ResetEntityData (veh, "vehicle_colision");
}, random_timer * 1000);
}
}
}
}
}
}
}
}
}
Note: With "HEALTHVEHICLE" Data You Can shair It to your client and use it on your hud.(hud with vehicle damaged is my next topic)
After That Paste This Codes In All Location You have (Engine On) notification in Vehicle.cs where to have this code: switch (NAPI.Data.GetEntityData(vehicle, "ACCESS")) , Like
C#:
case "HOTEL":
if (NAPI.Data.GetEntityData(vehicle, "OWNER") != sender && Main.Players[sender].AdminLVL < 3)
{
Notify.Send(sender, NotifyType.Error, NotifyPosition.BottomCenter, $"У Вас нет ключей от этого транспорта", 3000);
return;
}
if (Core.VehicleStreaming.GetEngineState(vehicle))
{
Core.VehicleStreaming.SetEngineState(vehicle, false);
Notify.Send(sender, NotifyType.Success, NotifyPosition.BottomCenter, $"Вы заглушили двигатель машины", 3000);
}
else
{
if (NAPI.Data.HasEntityData(sender.Vehicle, "vehicle_colision") || NAPI.Data.HasEntityData(sender.Vehicle, "vehicle_colision_low") || NAPI.Data.HasEntityData(sender.Vehicle, "vehicle_colision_high"))
{
Notify.Send(sender, NotifyType.Warning, NotifyPosition.BottomCenter, "Trying To Start The Vehicle...", 1000);
return;
}
else if (sender.Vehicle.Health < 350)
{
Notify.Send(sender, NotifyType.Warning, NotifyPosition.BottomCenter, "Vehicle Damaged a lot, You Must Call To Mechanic", 1000);
return;
}
else if (sender.Vehicle.Health > 350)
{
Core.VehicleStreaming.SetEngineState(vehicle, true);
Notify.Send(sender, NotifyType.Success, NotifyPosition.BottomCenter, $"Вы завели машину", 3000);
}
}
break;
Code you must copy there:
C#:
if (NAPI.Data.HasEntityData(sender.Vehicle, "vehicle_colision") || NAPI.Data.HasEntityData(sender.Vehicle, "vehicle_colision_low") || NAPI.Data.HasEntityData(sender.Vehicle, "vehicle_colision_high"))
{
Notify.Send(sender, NotifyType.Warning, NotifyPosition.BottomCenter, "You are Trying To Start The Vehicle...", 1000);
return;
}
else if (sender.Vehicle.Health < 350)
{
Notify.Send(sender, NotifyType.Warning, NotifyPosition.BottomCenter, "Vehicle damaged a lot, You Must Call To Mechanic", 1000);
return;
}
else if (sender.Vehicle.Health > 350)
{
Core.VehicleStreaming.SetEngineState(vehicle, true);
Notify.Send(sender, NotifyType.Success, NotifyPosition.BottomCenter, $"Вы завели машину", 3000);
}
All in Server Side done, and for fix vehicle we have mechanic job.
Client Side:
Add This code in your Main index.js in Client side:
JavaScript:
var duration;
mp.events.add("playerEnterVehicle", (vehicle, seat) => {
vehicle.setInvincible(false);
});
class HeadNotification {
constructor(text) {
// why on earth does this take arguments? damn ragemp
this.resolution = mp.game.graphics.getScreenActiveResolution(0, 0);
this.text = text;
this.startDuration = duration;
this.alpha = 255;
this.offset = 0;
this.onUpdateEventHandler = mp.events.add('render', () => this.onUpdateHandler());
}
onUpdateHandler() {
if (this.alpha <= 0) {
return;
}
mp.game.graphics.drawText(
this.text,
[0.5, 0.5 + this.offset], {
font: 4,
color: [255, 255, 255, this.alpha],
scale: [0.5, 0.5],
outline: true
});
this.offset -= 0.0005;
this.alpha -= 1;
}
}
mp.events.add("createNewHeadNotificationAdvanced", (notificationText) => {
new HeadNotification(notificationText);
});
All Done