[Release] Vehicle Damage Meter

Started by Anik, Mar 25, 2017, 06:16 PM

Previous topic - Next topic

Anik

Credits :-

Vehicle Damage Meter

Vehicle's HP/Damage meter with Progressbar.

[spoiler]
Server side :-

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 :-

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 );
}
[/spoiler]

Demo of the release.

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

KAKAN

Cool, it looks like the good ol' Windows XP :D( from video thumbnail )
oh no


Zone_Killer

Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai

Thijn

Jesus, do you actually play on that framerate?

kennedyarz


Anik

Quote from: Thijn on Mar 26, 2017, 05:01 PMJesus, do you actually play on that framerate?
Nah! When I used the screen recorder it decreased my frame rate :/

KAKAN

#7
Quote from: Anik on Mar 26, 2017, 06:22 PM
Quote from: Thijn on Mar 26, 2017, 05:01 PMJesus, 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
oh no