PDA

View Full Version : Huds appears invisible sometime.. weird :/



ORDI
27th June 2014, 22:21
Hello everybody,
i have a problem with my Huds, "They work" but sometime in the server, some huds appears invisible.
i thought i had too many of Huds but nop with only 3 Huds in a mod zom: Money, streak and nade
these 3 Huds bugs often.
However the script Money and streak are the only that i isn't make. I took from killtube when i started to make scripts.

i tried to do some test about it:
1)On all the functions, put:
-thread maps\mp\gametypes\_scripts::money();
-thread maps\mp\gametypes\_scripts::streak();
it dont work.
2)i'm making a thing in menu ingame when it dont work:
6.reload Huds
script:

if(response == reload)
{
thread maps\mp\gametypes\_scripts::money();
thread maps\mp\gametypes\_scripts::streak();
self iprintlnbold("huds reloaded");
}
i have the message but it dont work..
someone have a idea ?

money script and streak script:

money()
{
self.hudmoney = newClientHudElem(self);
self.hudmoney.alignx = "right";
self.hudmoney.x = 610;
self.hudmoney.y = 285;
self.hudmoney.fontscale = 1.4;
self.hudmoney.label = &"^7Money^1: &&1^7$";

while(1)
{
wait(0.2);
if(isdefined(self))
{
self.hudmoney setValue(self.money);
}
else if(!isdefined(self))
{
break;
}
}
}


streak()
{
if(isdefined(self.streak))
self.streak destroy();

self.streak = newClientHudElem(self);
self.streak.alignx = "right";
self.streak.x = 610;
self.streak.y = 305;
self.streak.fontscale = 1.3;

while(1)
{
wait(0.5);
if(isdefined(self))
{
if(self.pers["team"] == "allies")
{
self.streak.label = &"^7KillStreak: ^1&&1";
self.streak setValue(self.killstreak);
}
else
if(self.pers["team"] == "axis")
{
self.streak.label = &"^7DeathStreak: ^1&&1";
self.streak setValue(self.deathstreak);

}
}
else if(!isdefined(self))
{
break;
}
}
}

And all the Huds are precached.

in .cfg:

set logfile "2"
set sv_fps "20"

developper 0
dedicated 2

i am actually on a local server but on a real server, it dont work also.
i hope you will help me ;)
ORDI
xfire: ordi37zk

Ni3ls
28th June 2014, 08:59
Test with developer 1

filthy_freak_
28th June 2014, 11:39
self.hudmoney.label = &"^7Money^1: &&1^7$";
self.streak.label = &"^7KillStreak: ^1&&1";
self.streak.label = &"^7DeathStreak: ^1&&1";


Pretty sure this needs to be precached. Can't tell if you changed it for the purpose of this post.

If not;



game["blah_text"] = &"^7Money^1: &&1^7$";
precacheString(game["blah_text"]);

self.hudmoney.label = game["blah_text"];


edit:

Also, you forget to destroy self.hudmoney. Again, not sure if this is intentional.



money()
{
if(isDefined(self.hudmoney))
self.hudmoney destroy();

self.hudmoney = newClientHudElem(self);
self.hudmoney.alignx = "right";
self.hudmoney.x = 610;
self.hudmoney.y = 285;
self.hudmoney.fontscale = 1.4;
self.hudmoney.label = &"^7Money^1: &&1^7$";

while(1)
{
wait(0.2);
if(isdefined(self))
{
self.hudmoney setValue(self.money);
}
else if(!isdefined(self))
{
break;
}
}
}


Or, if you intentionally don't want it deleted;



money()
{
if(!isDefined(self.hudmoney)) {
self.hudmoney = newClientHudElem(self);
self.hudmoney.alignx = "right";
self.hudmoney.x = 610;
self.hudmoney.y = 285;
self.hudmoney.fontscale = 1.4;
self.hudmoney.label = &"^7Money^1: &&1^7$";
}

while(1)
{
wait(0.2);
if(isdefined(self))
{
self.hudmoney setValue(self.money);
}
else if(!isdefined(self))
{
break;
}
}
}

IzNoGoD
28th June 2014, 12:41
Your money hud doesnt get destroyed, it gets re-created every time, overflowing hud count.

ORDI
28th June 2014, 15:40
before i had placed

if(isDefined(self.hudmoney))
self.hudmoney destroy();
i got a error weird sometime. idk what was this error
but it appears still invisible

and when i say precache:


precacheString(&"^7Money^1: &&1^7$");
precacheString(&"^7KillStreak: ^1&&1");
precacheString(&"^7DeathStreak: ^1&&1");

a video in showing the hud money which work and which dont work:

http://fr.xfire.com/video/62859e/

filthy_freak_
28th June 2014, 16:11
I'v tested the code and it works fine.

This means the problem must be elsewhere.

Try and debug your code....



money()
{
if(isDefined(self.hudmoney))
self.hudmoney destroy();

self.hudmoney = newClientHudElem(self);
self.hudmoney.alignx = "right";
self.hudmoney.x = 610;
self.hudmoney.y = 285;
self.hudmoney.fontscale = 1.4;
self.hudmoney.label = &"^7Money^1: &&1^7$";

while(1)
{
wait(0.2);
if(isdefined(self) && isDefined(self.money))
{
self.hudmoney setValue(self.money);
}
else if(!isDefined(self.money))
{
self iprintlnbold("self.money is undefined!");
break;
}
else if(!isdefined(self))
{
self iprintlnbold("self is undefined!");
break;
}
}
}




streak()
{
if(isdefined(self.streak))
self.streak destroy();

self.streak = newClientHudElem(self);
self.streak.alignx = "right";
self.streak.x = 610;
self.streak.y = 305;
self.streak.fontscale = 1.3;

while(1)
{
wait(0.5);
if(isdefined(self))
{
if(self.pers["team"] == "allies")
{
if(isDefined(self.killstreak))
{
self.streak.label = &"^7KillStreak: ^1&&1";
self.streak setValue(self.killstreak);
} else {
iprintlnbold("self.killstreak is undefined!");
break;
}
}
else
if(self.pers["team"] == "axis")
{
if(isDefined(self.deathstreak))
{
self.streak.label = &"^7DeathStreak: ^1&&1";
self.streak setValue(self.deathstreak);
} else {
iprintlnbold("self.deathstreak is undefined!");
break;
}
}
}
else if(!isdefined(self))
{
iprintln("self is undefined!");
break;
}
}
}




i got a error weird sometime.

Try fixing the error, like izno said, if you don't destroy it you will overflow your hud count.


EDIT: You will probably find the problem easy if you were to set developer 1.

ORDI
29th June 2014, 11:36
euhm developer 1:
it do nothing.

i did what you said:

wait(0.2);
if(isdefined(self) && isDefined(self.money))
{
self.hudmoney setValue(self.money);
}
else if(!isDefined(self.money))
{
self iprintlnbold("self.money is undefined!");
break;
}
else if(!isdefined(self))
{
self iprintlnbold("self is undefined!");
break;
}
results:
i cant see:
self iprintlnbold("self.money is undefined!");
and
self iprintlnbold("self is undefined!");
when it dont work.

filthy_freak_
4th July 2014, 06:00
euhm developer 1:
it do nothing.

i did what you said:

wait(0.2);
if(isdefined(self) && isDefined(self.money))
{
self.hudmoney setValue(self.money);
}
else if(!isDefined(self.money))
{
self iprintlnbold("self.money is undefined!");
break;
}
else if(!isdefined(self))
{
self iprintlnbold("self is undefined!");
break;
}
results:
i cant see:
self iprintlnbold("self.money is undefined!");
and
self iprintlnbold("self is undefined!");
when it dont work.

I'm not going to debug your code, what I said was mostly meant to be an example of what you should be doing.


I'v tested the code and it works fine.

This means the problem must be elsewhere.

----

Also, you mentioned you can write your own code. Why did you copy this script, modify it and ask us for help when it doesn't work, instead of writing a script yourself? This could be re-written to suit your needs in under two minutes. I sound harsh but come on... this script is easy!

IzNoGoD
4th July 2014, 10:44
euhm developer 1:
it do nothing.

i did what you said:

wait(0.2);
if(isdefined(self) && isDefined(self.money))
{
self.hudmoney setValue(self.money);
}
else if(!isDefined(self.money))
{
self iprintlnbold("self.money is undefined!");
break;
}
else if(!isdefined(self))
{
self iprintlnbold("self is undefined!");
break;
}
results:
i cant see:
self iprintlnbold("self.money is undefined!");
and
self iprintlnbold("self is undefined!");
when it dont work.

If self is undefined then you are calling your scripts wrong.