diff --git a/Templates/BaseGame/game/data/DamageModel/DamageModel.tscript b/Templates/BaseGame/game/data/DamageModel/DamageModel.tscript index 3268a5b9e..f3932781d 100644 --- a/Templates/BaseGame/game/data/DamageModel/DamageModel.tscript +++ b/Templates/BaseGame/game/data/DamageModel/DamageModel.tscript @@ -23,6 +23,7 @@ function DamageModel::onCreateGameServer(%this) %this.queueExec("./scripts/server/shapeBase"); %this.queueExec("./scripts/server/vehicle"); %this.queueExec("./scripts/server/player"); + %this.queueExec("./scripts/server/commands"); } //This is called when the server is shut down due to the game/map being exited @@ -35,6 +36,7 @@ function DamageModel::initClient(%this) { %this.queueExec("./guis/damageGuiOverlay.gui"); %this.queueExec("./scripts/client/playGui"); + %this.queueExec("./scripts/client/client"); } //This is called when a client connects to a server diff --git a/Templates/BaseGame/game/data/DamageModel/scripts/client/client.tscript b/Templates/BaseGame/game/data/DamageModel/scripts/client/client.tscript new file mode 100644 index 000000000..4f015a954 --- /dev/null +++ b/Templates/BaseGame/game/data/DamageModel/scripts/client/client.tscript @@ -0,0 +1,67 @@ + +// ---------------------------------------------------------------------------- +// WeaponHUD +// ---------------------------------------------------------------------------- + +// Update the Ammo Counter with current ammo, if not any then hide the counter. +function clientCmdSetAmmoAmountHud(%amount, %amountInClips) +{ + if (!%amount) + AmmoAmount.setVisible(false); + else + { + AmmoAmount.setVisible(true); + AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips); + } +} + +// Here we update the Weapon Preview image & reticle for each weapon. We also +// update the Ammo Counter (just so we don't have to call it separately). +// Passing an empty parameter ("") hides the HUD component. + +function clientCmdRefreshWeaponHUD(%amount, %preview, %ret, %zoomRet, %amountInClips) +{ + if (!%amount) + AmmoAmount.setVisible(false); + else + { + AmmoAmount.setVisible(true); + AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips); + } + + if (%preview $= "" || detag(%preview) $= "blank") + { + WeaponHUD.setVisible(false); + PreviewImage.setBitmap(""); + } + else + { + WeaponHUD.setVisible(true); + PreviewImage.setbitmap(detag(%preview)); + } + + if (%ret $= "" || detag(%ret) $= "blank") + { + Reticle.setVisible(false); + Reticle.setBitmap(""); + } + else + { + Reticle.setVisible(true); + Reticle.setbitmap(detag(%ret)); + } + + if (isObject(ZoomReticle) || detag(%zoomRet) $= "blank") + { + if (%zoomRet $= "" || detag(%zoomRet) $= "blank") + { + ZoomReticle.setVisible(false); + ZoomReticle.setBitmap(""); + } + else + { + ZoomReticle.setVisible(true); + ZoomReticle.setBitmap(detag(%zoomRet)); + } + } +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/DamageModel/scripts/server/commands.tscript b/Templates/BaseGame/game/data/DamageModel/scripts/server/commands.tscript new file mode 100644 index 000000000..1a03625ce --- /dev/null +++ b/Templates/BaseGame/game/data/DamageModel/scripts/server/commands.tscript @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// weapon HUD +// ---------------------------------------------------------------------------- +function GameConnection::setAmmoAmountHud(%client, %amount, %amountInClips ) +{ + commandToClient(%client, 'SetAmmoAmountHud', %amount, %amountInClips); +} + +function GameConnection::RefreshWeaponHud(%client, %amount, %preview, %ret, %zoomRet, %amountInClips) +{ + commandToClient(%client, 'RefreshWeaponHud', %amount, %preview, %ret, %zoomRet, %amountInClips); +} \ No newline at end of file