View Full Version : Moving huds :D
Rocky
23rd March 2014, 10:26
How to make moving huds? to they are moving on screen?
Thanks.!
Ni3ls
23rd March 2014, 10:38
use moveovertime, scaleovertime and fadeovertime
Rocky
23rd March 2014, 10:39
something()
{
self endon("disconnect");
if(isdefined(self.m))
self.m destroy();
self.m = newClientHudElem(self);
self.m.x = 550;
self.m.y = 90;
self.m.alignX = "left";
self.m.alpha = 0;
self.m.sort = 50;
self.m.fontScale = 1;
self.m.archived = true;
for(;;)
{
self.m fadeOverTime(1);
self.m moveOverTime(5);
self.m.alpha = 1;
self.m.label = &"something:";
self.m setValue(self.something);
wait 300;
self.m fadeOverTime(1);
self.m.alpha = 0;
wait 10;
}
}
that? its not updating huds..
Ni3ls
23rd March 2014, 11:16
you set the coordinates of the hud. Then you do moveovertime(time) and then the new coordinates of the hud
kung foo man
23rd March 2014, 12:50
Learning by example ftw:
self.m moveOverTime(1);
self.m.x = 550;
self.m.y = 90;
wait 1;
self.m moveOverTime(1);
self.m.x = 10;
self.m.y = 10;
wait 1;
self.m moveOverTime(1);
self.m.x = 222;
self.m.y = 222;
wait 1;
self.m moveOverTime(1);
self.m.x = 320;
self.m.y = 240;
wait 1;
ORDI
23rd March 2014, 12:52
i think its what i want too but i do not knew how create :)
i would like a text who is from left and who rotate for the right
i have the HTML to create on website:
<marquee direction="left" behavior="scroll" scrollamount="3" scrolldelay="2" style="color:#000000;font-size:32px;font-family:Arial;">my website<br>
<br></marquee>
pollo
23rd March 2014, 22:05
i think its what i want too but i do not knew how create :)
i would like a text who is from left and who rotate for the right
i have the HTML to create on website:
<marquee direction="left" behavior="scroll" scrollamount="3" scrolldelay="2" style="color:#000000;font-size:32px;font-family:Arial;">my website<br>
<br></marquee>
That makes no sense, he is talking about CoD2 lol
Tally
24th March 2014, 08:52
i think its what i want too but i do not knew how create :)
i would like a text who is from left and who rotate for the right
i have the HTML to create on website:
<marquee direction="left" behavior="scroll" scrollamount="3" scrolldelay="2" style="color:#000000;font-size:32px;font-family:Arial;">my website<br>
<br></marquee>
COD2 does not use HTML as a language. Please go to a web building site for your web support.
thank you.
kung foo man
24th March 2014, 09:39
He is just refering to the html-element marquee as an analogy for a hud moving from right to left.
As base you could use this old ad hud script: http://killtube.org/downloads/cod2/exampleserver/main/std/ad.gsc
std\ad::addAd(&"1st marquee", 2, (1,0,0));
std\ad::addAd(&"2nd marquee", 2, (0,1,0));
std\ad::addAd(&"3rd marquee", 2, (0,0,1));
std\ad::precache();
// in startgametype:
thread std\ad::ad();
You basically just need to edit the for loop in ad::ad() to move it with moveOverTime() like shown in the example.
while (1)
{
for (i=0; i<level.ad.size; i++)
{
level.hud_ad.fontscale = level.ad[i].scale;
level.hud_ad.color = level.ad[i].color;
level.hud_ad fadeOverTime(1);
level.hud_ad.alpha = 1;
level.hud_ad.label = level.ad[i].ad;
wait 10;
level.hud_ad fadeOverTime(1);
level.hud_ad.alpha = 0;
wait 20;
}
}
Loveboy
25th March 2014, 15:40
Is there any way to do a shader from .alpha 0 to .alpha 1 in 5 secounds? I tried it and there is a problem, it just showed the shader instantly. If you try it on the default shader "black", then you will see, that it works. But not on own shaders. I tried already fadeOverTime(time) too, but it doesn't work, only on text.
Ni3ls
25th March 2014, 16:33
Shaders work too with fadeovertime
{
hud = newClientHudElem(self);
hud.horzAlign = "fullscreen";
hud.vertAlign = "fullscreen";
hud setShader("white", 640, 480);
hud.alpha = 1;
hud.x = 0;
hud.y = 0;
hud fadeovertime(2.5);
hud.alpha = 0;
}
Loveboy
25th March 2014, 17:31
Doesn't work, you tested it with your own texture?
If yes and if it does work, then do a .iwd file and upload here, I want to check it.
Edit: My current HUD script:
spawnHud()
{
hud = newClientHudElem(self);
hud.horzAlign = "fullscreen";
hud.vertAlign = "fullscreen";
hud setShader("texture_test", 640, 480);
hud.alpha = 1;
hud.x = 0;
hud.y = 0;
hud fadeovertime(10);
hud.alpha = 0;
self thread destroyOnDeath(hud);
}
destroyOnDeath(hud)
{
self waittill("killed_player");
if(isDefined(hud))
hud destroy();
}
notes:
- spawnHud() will be called if someone is spawning
- destroyOnDeath() will be called if someone die
- the shader "texture_test" is precached
- the hud spawns instantly (visible) and not from visible to invisible
In game it looks like this (after spawned):
676
Ni3ls
25th March 2014, 18:42
The thing I posted works. I use it for flashnade. The shader "white" is a default cod2 shader. I didnt test it with own texture. Maybe you need to compile your shader with certain options to make it work
Tally
25th March 2014, 18:48
Is there any way to do a shader from .alpha 0 to .alpha 1 in 5 secounds? I tried it and there is a problem, it just showed the shader instantly. If you try it on the default shader "black", then you will see, that it works. But not on own shaders. I tried already fadeOverTime(time) too, but it doesn't work, only on text.
fadeOverTime() works on shaders as well.
Example of a working fading server logo shader:
if( isdefined( level.svrlogo ) ) level.svrlogo destroy();
if( !isdefined( level.svrlogo ) )
{
level.svrlogo = newHudElem();
level.svrlogo.x = X;
level.svrlogo.y = Y;
level.svrlogo.hidden = false;
level.svrlogo.alignX = "left";
level.svrlogo.alignY = "top";
level.svrlogo.horzAlign = "fullscreen";
level.svrlogo.vertAlign = "fullscreen";
level.svrlogo.archived = false;
level.svrlogo.hideWhenInMenu = true;
level.svrlogo setShader( game[ "demonlogo" ], W, D );
level.svrlogo.alpha = 0;
}
for( ;; )
{
wait looptime;
if( isdefined( level.svrlogo ) ) level.svrlogo fadeOverTime( 2 );
if( isdefined( level.svrlogo) ) level.svrlogo.alpha = .7;
wait screentime;
if( isdefined( level.svrlogo ) ) level.svrlogo fadeOverTime( 2 );
if( isdefined( level.svrlogo ) ) level.svrlogo.alpha = 0;
}
Loveboy
28th March 2014, 23:40
No, now I found the problem, I looked on the material and image from the shader "black" and "white".
The material name is "black" and the image name is "$black" (open the material from main/iw_13.iwd/materials/black to see what image name it has).
You can also read the options what there is used for the material, but I it's just hard to understand, what they set:
V \ e‘( P D P c \ tools black $black colorMap
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.