« [Release] Developer Panel
[Release] Vehicle Damage Meter
[Release] Animated Announcement »

Anik

  • Sr. Member
  • Posts: 356
[Release] Vehicle Damage Meter
« on March 25th, 2017, 06:16 PM »
Credits :-

Vehicle Damage Meter

Vehicle's HP/Damage meter with Progressbar.

(click to show/hide)
Server side :-

Code: [Select]
function onPlayerEnterVehicle(player, vehicle, door)
 {
    local Stream = Stream();
Stream.WriteInt( 1 );
Stream.WriteString( vehicle.ID );
Stream.SendStream( player );
}

function onPlayerExitVehicle(player, vehicle)
{
    local Stream = Stream();
Stream.WriteInt( 2 );
Stream.SendStream( player );
}

Client Side :-

Code: [Select]
Veh <-
{
Window = null
progressBar = null
Label = null
vehicle = null
HP = null
}

function DelVehDamageMeter( )
{
Veh.vehicle = null;
Veh.HP = null;
Veh.Window = null;
Veh.Label = null;
Veh.progressBar = null;
}

function CreateVehDamageMeter( strread )
{
strread = strread.tointeger();
Veh.vehicle = World.FindVehicle( strread );
Veh.HP = (Veh.vehicle.Health/10).tointeger();
Veh.Window = GUIWindow( );
Veh.Window.Size = VectorScreen( 300, 100 );
Veh.Window.Pos = VScreen( 550, 850 );
Veh.Window.Text = "Vehicle ID - "+strread;
Veh.Window.FontFlags = ( GUI_FFLAG_BOLD | GUI_FFLAG_ULINE );
Veh.Window.RemoveFlags( GUI_FLAG_WINDOW_RESIZABLE | GUI_FLAG_WINDOW_CLOSEBTN );

Veh.Label = GUILabel();
Veh.Label.Text = "HP : "+Veh.HP+"%";
Veh.Label.FontSize = 13;
Veh.Label.Pos = VectorScreen( 110, -1 );

Veh.progressBar = GUIProgressBar();
Veh.progressBar.Pos = VectorScreen( 10, 18 );
Veh.progressBar.Size = VectorScreen( 280, 50 );
Veh.progressBar.BackgroundShade = 0.2;
Veh.progressBar.Thickness = 3;
Veh.progressBar.MaxValue = 1000;
Veh.progressBar.Value = Veh.vehicle.Health;
Veh.progressBar.StartColour = Colour( 255, 0, 0 );
Veh.progressBar.EndColour  = Colour( 0, 255, 0 );

Veh.Window.AddChild( Veh.progressBar );
Veh.Window.AddChild( Veh.Label );
}

function Server::ServerData( stream )
{
local StreamReadInt = stream.ReadInt( ),
StreamReadString = stream.ReadString( );
switch( StreamReadInt.tointeger( ) )
{
case 1: CreateVehDamageMeter( StreamReadString ); break;
case 2: DelVehDamageMeter( ); break;
}
}

function Script::ScriptProcess()
{
if( Veh.vehicle )
{
if ( Veh.vehicle.Health.tointeger() != Veh.HP*10 )
{
Veh.HP = (Veh.vehicle.Health/10).tointeger();
Veh.Label.Text = "HP : "+Veh.HP+"%";
Veh.progressBar.Value = Veh.vehicle.Health;
}
}
}

function GUI::GameResize(width, height)
{
if ( ::Veh.Window ) Veh.Window.Pos = VScreen( 550, 850 );
}

function VScreen( pos_x, pos_y )//Credits goes to Doom_Kill3R for this function
{
local
    screenSize = GUI.GetScreenSize( ),
    x = floor( pos_x * screenSize.X / 1920 ),
    y = floor( pos_y * screenSize.Y / 1080 );

return VectorScreen( x, y );
}

Demo of the release.


https://www.youtube.com/watch?v=3A0fbeoMPNw#

KAKAN

  • Wiki Contributor
  • Posts: 3,343
[Release] Re: Vehicle Damage Meter
« Reply #1, on March 25th, 2017, 07:13 PM »
Cool, it looks like the good ol' Windows XP :D( from video thumbnail )
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

AdrenAline

  • Newbie
  • Posts: 35

Zone_Killer

  • Jr. Member
  • K.D.M No.1
  • Posts: 99
Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai

Thijn

  • VC:MP Beta Tester
  • Posts: 1,687
[Release] Re: Vehicle Damage Meter
« Reply #4, on March 26th, 2017, 06:01 PM »
Jesus, do you actually play on that framerate?

kennedyarz

  • Sr. Member
  • Making American Great Again
  • Posts: 334

Anik

  • Sr. Member
  • Posts: 356

KAKAN

  • Wiki Contributor
  • Posts: 3,343
[Release] Re: Vehicle Damage Meter
« Reply #7, on March 27th, 2017, 06:12 AM »Last edited on March 27th, 2017, 06:15 AM
Quote from Anik on March 26th, 2017, 07:22 PM
Quote from Thijn on March 26th, 2017, 06:01 PM
Jesus, do you actually play on that framerate?
Nah! When I used the screen recorder it decreased my frame rate :/
Screen recorder? Use game recording option in your recorder lol
Thijn, if it were me, I'd rather upload a 1fps GIF file, because, 60FPS video is not worth it.
P.S:- Watched the video, it looks just like some images gathered :D
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

« [Release] Developer Panel
[Release] Animated Announcement »