Obscurity Mod
HOMEFEATURESFORUMMEDIADOWNLOADSABOUT
   
 

AU/NZ Exclusive

Name: AK Obscurity
IP: 45.121.211.99:28960
(show/hide server details)

   
   
 

Africa

   
   
 

South America

   
   
 

UK/Europe

Name: IceOps-Team OBS
IP: 176.31.25.80:28965
(show/hide server details)

   
   
 

US/Canada

   
   
 

Honourable Donators

Spidergat
Batman_516
mavrick
AzzDawg
EAS Clan
killerciao
Awok3n
jesus
Describe
Ripper
LaZzy
   
   
  LOGIN | SIGNUP
Obscure Creations
on Facebook
   
   
 

Latest Forum Posts

Our Obscurity server
WEBSITE

Obscurity source files?
OBSCURITY

Hello again.
OBSCURITY COVERT OPS

Obs Final Update - Suggestions
OBSCURITY

New server from Slovenia
OBSCURITY

Modding help i need
MISC

   
   
 

Obscurity Flood

   
   
 

Latest Mod Updates

2.99d Release Notes

2.99d WIP Release Notes

2.99c Fixed Release

2.99b Release Notes

   
   
 

OBSCURITY >> Help & Tutorials >> Hud elements

Topgear
(xfire: topg3ar) 

Topgear

 

Posts: 26
05:21 AM 09/11/2009

This is a very weird problem i have here. This is my script:

init()
{
    self.healthHud = newHudElem();
    self.healthHud.alpha = 1;
    self.healthHud.x = 64;
    self.healthHud.y = 200;
    self.healthHud.alignX = "center";
    self.healthHud.alignY = "middle";
    self.healthHud setText("lol");
   
    self.healthHud2 = newHudElem();
    self.healthHud2.alpha = 1;
    self.healthHud2.x = 100;
    self.healthHud2.y = 200;
    self.healthHud2.alignX = "center";
    self.healthHud2.alignY = "middle";
    self.healthHud2 setText("omg");
}

When im testing i can only see the 'lol' hud element and the other one doesnt not show. I cant see anything wrong with it and its weird how 1 is showing but the other isnt. Anyone know why ?

Describe
 

Describe

OBSmin (S Rank) 

Posts: 256
11:05 AM 09/11/2009

I haven't coded in cod, but I'll take a stab and say that there is no entity called healthHud2 ?

Audioghost
 

Audioghost

 

Posts: 40
03:42 PM 09/11/2009

HealthHud2 is just the varible he has attached to the hud elem, so it wouldn't make a difference.

Also, since the variable is based on "self", you want it to be a newclienthudelem.

This should (will) fix your problem :P

 

init()

{

self.healthHud = newClientHudElem(self);
self.healthHud.alpha = 1;
self.healthHud.x = 64;
self.healthHud.y = 200;
self.healthHud.horzAlign = "fullscreen";
self.healthHud.vertAlign = "fullscreen";
self.healthHud.alignX = "left";
self.healthHud.alignY = "top";
self.healthHud setText("lol");
   
self.healthHud2 = newClientHudElem(self);
self.healthHud2.alpha = 1;
self.healthHud2.x = 100;
self.healthHud2.y = 200;
self.healthHud2.horzAlign = "fullscreen";
self.healthHud2.vertAlign = "fullscreen";
self.healthHud2.alignX = "top";
self.healthHud2.alignY = "left";
self.healthHud2 setText("omg");

}

 

run "init()" on a player, not level, and it will work. I've re-aligned the elem's to top left, as it's much easier to place them if the starting point is the top left of the screen. Also having a horzAlign and vertAlign "Fullscreen" will help with accurately placing it too, and avoid some issues where screensize and resolution can result in hud overlapping.

 

And yes, I do script for cod :P

 

Snakelet
(xfire: snakelet) 

Snakelet

OBS Dev 

Posts: 1330
09:30 PM 09/11/2009

I have seen what you have scripted Audioghost, and we never stated it was impossible to recreate phasing.

Audioghost
 

Audioghost

 

Posts: 40
12:36 AM 10/11/2009

Lol i might have mis-read/heard a post somewhere if thats the case, you have my apologies. I wasn't saying it in a snidy, competition-like way though, it was just an observation :) Again, my apologies.

Snakelet
(xfire: snakelet) 

Snakelet

OBS Dev 

Posts: 1330
01:32 AM 10/11/2009

If we created something, then it isn't impossible to do...otherwise we wouldn't have achieved it. It may have been said that it could be difficult to replicate, but TBH I don't think it was in reference to phasing Tongue out

Audioghost
 

Audioghost

 

Posts: 40
07:34 AM 10/11/2009

Yeah I see what you mean, I just guess I mis-understood xD I'll change the video (if it was the video) description to remove any further confusion :P

Topgear
(xfire: topg3ar) 

Topgear

 

Posts: 26
04:38 AM 11/11/2009

This is my whole code right now:

This is all started from _load.gsc using this: thread scripts\_mod::main();

and this is the code im having trouble with

main()
{
    thread onNewConnection();
}

onNewConnection()
{
    while(1)
    {
        level waittill("connected", player);
        player thread scripts\_mod::init();
    }
}

init()
{
    self.healthHud = newClientHudElem(self);
    self.healthHud.alpha = 1;
    self.healthHud.x = 64;
    self.healthHud.y = 200;
    self.healthHud.horzAlign = "fullscreen";
    self.healthHud.vertAlign = "fullscreen";
    self.healthHud.alignX = "top";
    self.healthHud.alignY = "left";
    self.healthHud setText("lol");
   
    self.healthHud2 = newClientHudElem(self);
    self.healthHud2.alpha = 1;
    self.healthHud2.x = 100;
    self.healthHud2.y = 200;
    self.healthHud2.horzAlign = "fullscreen";
    self.healthHud2.vertAlign = "fullscreen";
    self.healthHud2.alignX = "top";
    self.healthHud2.alignY = "left";
    self.healthHud2 setText("omg");
}

The self.healthHud2 still doesnt show i only can see the first HudElem

Snakelet
(xfire: snakelet) 

Snakelet

OBS Dev 

Posts: 1330
05:46 AM 11/11/2009

Ignore me :)

Topgear
(xfire: topg3ar) 

Topgear

 

Posts: 26
06:27 AM 11/11/2009

who are you talking to Snake ? me ?

Audioghost
 

Audioghost

 

Posts: 40
07:55 AM 11/11/2009

When the thread you wish to run is in the same .gsc file or is used in an #include, you can just use 'thread()' no need for the folder structure :P Try this, but I cant see any reason why the second one won't show UNLESS you already have a tonne of hudelems and you've hit the limit.

 

main()
{
thread PlayerConnect();
}

PlayerConnect()
{
while(1)
    {
    level waittill("connecting", player);
    player thread PlayerSpawned();
    }
}

Spawned()
{
self endon("disconnect");
self waittill("spawned_player");
self thread init();
}

init()
{
self.healthHud = newClientHudElem(self);
self.healthHud.alpha = 1;
self.healthHud.x = 64;
self.healthHud.y = 200;
self.healthHud.horzAlign = "fullscreen";
self.healthHud.vertAlign = "fullscreen";
self.healthHud.alignX = "top";
self.healthHud.alignY = "left";
self.healthHud setText("lol");
  
self.healthHud2 = newClientHudElem(self);
self.healthHud2.alpha = 1;
self.healthHud2.x = self.healthHud.x + 36;
self.healthHud2.y = self.healthHud.y;
self.healthHud2.horzAlign = "fullscreen";
self.healthHud2.vertAlign = "fullscreen";
self.healthHud2.alignX = "top";
self.healthHud2.alignY = "left";
self.healthHud2 setText("omg");
}

 

Is there a reason the self.healthhud.x = 64, as 64 seems very specific? :P

Audio

Snakelet
(xfire: snakelet) 

Snakelet

OBS Dev 

Posts: 1330
08:00 AM 11/11/2009

Yeah, I wrote a reply, but then realised it was incorrect so I removed it Tongue out Was in a rush as finishing my working day!

As Ghost said above, you can just use "self thread function ();" to call functions within the same file. I also suggest throwing in some iPrintLn (); statements to help you debug it ( such as "iPrintLn (self.healthHud2.x);" )  . My first suggestion for debugging would be to switch the two statements and see which one shows up.

Audioghost
 

Audioghost

 

Posts: 40
09:39 AM 11/11/2009

Yeah.

I'm not 100% certain, but "self.healthHud2" could be failing out as it contains an integer (number), and I'm not sure that actual variables can contain int's.

Maybe think about turning the hudelem into an array.

EG:

self.healthHud[0] and self.healthHud[1]

(Arrays have to start at 0, it's stupid I know :P)

Setting up the HUD would still be the same.

self.healthHud[0].x = ##

self.healthHud[1].x = ##

etc etc.

Audio

Topgear
(xfire: topg3ar) 

Topgear

 

Posts: 26
06:14 AM 12/11/2009

Snake i tried what you said to do and i get the same result:

( i changed self.healthHud to self.tree so it didnt have an Integer in it and tree was the first thing that popped into my head )

    self.tree = newClientHudElem(self);
    self.tree.alpha = 1;
    self.tree.x = 64;
    self.tree.y = 200;
    self.tree.horzAlign = "fullscreen";
    self.tree.vertAlign = "fullscreen";
    self.tree.alignX = "center";
    self.tree.alignY = "middle";
    self.tree setText("lol");
 
    self.healthHud = newClientHudElem(self);
    self.healthHud.alpha = 1;
    self.healthHud.x = 100;
    self.healthHud.y = 200;
    self.healthHud.horzAlign = "fullscreen";
    self.healthHud.vertAlign = "fullscreen";
    self.healthHud.alignX = "center";
    self.healthHud.alignY = "middle";
    self.healthHud setText("omg");

'lol' is still the only one that shows up

oh and Audioghost the 'top' and 'left' alignment values for alignX and alignY cause errors.

Audioghost
 

Audioghost

 

Posts: 40
07:39 AM 12/11/2009

Oh yeah lol, sorry - got them mixed up XD

AlignY = "top";

AlignX = "left";

 

I don't see any reason why these wont work, your calling the thread on a player, the syntax & coding are fine.

I know this might sound stupid, but try removing the capital H from self.healthHud, for example "if(self.pers["team"] == "Allies")" will fail because it has a capital A, but "if(self.pers["team"] == "allies")" will work fine.

My only other idea is that you've hit the hudelem limit. How many hudelem's have you added?

 

EDIT: Doubtfull, but maybe "self.healthHud" is already a variable elsewhere in the game.

Audio

 

Topgear
(xfire: topg3ar) 

Topgear

 

Posts: 26
07:48 AM 12/11/2009

:P

I have just came across something else interesting when i was moving on from it:

if ( !self.scr_hasclaymore ) {
        self giveWeapon("claymore_mp");
        wait 1;
        self SwitchToWeapon("claymore_mp");
        self.scr_hasclaymore = true;
}

If i do what ive scripted i get the claymore but when i place them the HudElement i already have disappears and if i shoot both of the claymores the hudelem comes back. My guess is something to do with self. is interfering with anything else to do with self. Its like only one thing can be used with self.

Audioghost
 

Audioghost

 

Posts: 40
07:52 AM 12/11/2009

Sounds alot like the hudlelem limit to me. When claymores are placed they get an overhead icon with their team emblem, which counts as a hudelem. Maxxing the hudelem limit would explain why when you place these claymores, your hud you added disappears - and why it comes back when the clay's are gone.

Audio

Topgear
(xfire: topg3ar) 

Topgear

 

Posts: 26
07:56 AM 12/11/2009

I have only made 1 hud element.

Well heres an interesting turn of events. I would not have a clue what happened but i added a few more things and then tested and when i planted a clay the Hudelem didnt go away :D. though this isnt good because i dont have a clue how it was fixed. I havent tried adding another elem yet.

Heres a quick vid

http://www.xfire.com/video/189d24/

Snakelet
(xfire: snakelet) 

Snakelet

OBS Dev 

Posts: 1330
10:46 AM 12/11/2009

Is it going to be like a CS type thing where you earn money and buy your weapons each round? That could be interesting.

Topgear
(xfire: topg3ar) 

Topgear

 

Posts: 26
09:39 PM 12/11/2009

Yep. thats the plan :D

 

^