[T1 Request] trans ammohud and pinghud

Hilikus
03-19-2003, 09:42 PM
compatible with stripped

Ambient7
03-19-2003, 10:06 PM
AmmoHUD (is this what you want?):

// How often, in seconds, is the HUD to update itself?
$AmmoHUD::updatetime = 0.1;

Event::Attach(eventPlayGu iCreated, AmmoHUD::Create);
Event::Attach(eventExit, AmmoHUD::Destroy);
Event::Attach(eventConnec ted, AmmoHUD::Update);

$Ammo::Descr[13] = "Bullet";
$Ammo::Descr[15] = "Plasma Bolt";
$Ammo::Descr[17] = "Grenade Ammo";
$Ammo::Descr[19] = "Mortar Ammo";
$Ammo::Descr[21] = "Disc";

// Create HUD, if exists Update
function AmmoHUD::Create(%gui)
{
if($AmmoHUD::Exists)
{
echo("AmmoHUD::Exists!");
AmmoHUD::Update();
return;
}

// Make sure we don't double it!
$AmmoHUD::Exists ="TRUE";

// Here's the main container
$AmmoHUD::hudContainer=ne wObject(AmmoHUD_Container , SimGui::Control, 375, 325, 38, 54);

// Here's the itemicons
$AmmoHUD::ItemsTextObj = newObject(AmmoHUD_Text,Fe arGuiFormattedText,3,-2,32,58);

// Add our controls to the container
addToSet(AmmoHUD_Containe r, $AmmoHUD::ItemsTextObj);

// Add the whole container to PlayGui
addToSet(PlayGui, $AmmoHUD::hudContainer);

// Update the HUD to set values
AmmoHUD::Update();

}

function AmmoCount(%weaponId)
{
%ammo = getItemCount($Ammo::Descr[%weaponId]);

if(%ammo)
{
return("<F2>" @ %ammo);
}
else
{
return("<F1>~");
}
}

function AmmoHUD::Update()
{
// Only update if the Hud exists. We don't want a ton of error
// messages if it doesn't.
if($AmmoHUD::exists)
{
Control::SetValue(AmmoHUD _Text, AmmoCount(getMountedItem( 0)));

// Return in $AmmoHUD::updatetime seconds!
schedule("AmmoHUD::Update();", $AmmoHUD::updatetime);
}
}
function AmmoHUD::Destroy()
{
if($AmmoHUD::exists)
{
removeFromSet(PlayGui, $AmmoHUD::hudContainer);
deleteObject($AmmoHUD::hu dContainer);

$AmmoHUD::Exists = "";
}
}

Haven't ported a PingHUD yet, though.

cyclonite
03-19-2003, 11:57 PM
Give this Ping Hud a try:


//File: Ping.cs
//Credits: Cyclonite
//My attempt to grab your relative ping in Tribes.

Event::Attach(EventConnec ted, Ping::Update);
Event::Attach(eventPlayGu iCreated, Ping::Create);
Event::Attach(EventExit, Ping::Destroy);

function Ping::Destroy() {
removeFromSet("playgui", $Ping::HUD);
deleteObject($Ping::HUD);
}


function Ping::Create() {
$Ping::HUD = newobject("PingHUD_Text", FearGuiFormattedText, 630, 84, 20, 20);
AddtoSet(playGui, $Ping::HUD);
}

function Ping::Update()
{
Ping::computePing();
control::setValue("PingHUD_Text", "<F1>" @ $Ping::currentPing @ "ms");
schedule("Ping::Update();", 3);
}

function Ping::Ping() {

remoteeval(2048, eval, PingHUDResponse, getsimtime());
}

function remotePingHUDResponse(%cl ient, %origtime) {

$Ping::currentPing = ((getsimtime() - %origtime) * 500);
}

function Ping::computePing()
{
%p = Ping::Ping();
$Ping::currentPing = floor($Ping::currentPing) ;
}

Hilikus
03-20-2003, 06:34 PM
ammohud=no work

Ambient7
03-20-2003, 06:44 PM
ammohud=no work

In the line:

$AmmoHUD::hudContainer=ne wObject(AmmoHUD_Containe r, SimGui::Control, 375, 325, 38, 54);

Remove the two spaces between "AmmoHUD_Containe" and the "r" (forum bugged it up).

GreeD
03-27-2003, 11:43 AM
Any way to get the Mines, nades, repair kit as a hud, much like ammo hud?

Ambient7
03-27-2003, 12:12 PM
ItemHUD?

GreeD
03-27-2003, 01:53 PM
Where you could place each hud where you wanted, like....



Mines--->3 1 <-----Repair Kit
x <--- Crosshair

Nades---->5 15 <---- Ammo Hud

I cant get it strait on here but i hope you get it, i think coolguy did it for t2. The items are independant...

Savage
03-27-2003, 01:56 PM
that would be nice, like ammoHUD where it only requires events.cs.

cyclonite
03-27-2003, 03:52 PM
Greed, I sorta get what you are saying.
Do a paint or photoshop of it so we can get a better idea of exactly what you want and I shall see if I can make that ItemHUD for ya ;)

insidious
03-27-2003, 04:08 PM
hes talking about a transparent itemhud, that shows how many mines, hand grenades, health kits you have, just like ammoHUD. it would be nice to have it only require events.cs.