5 registered members (AndrewAMD, ozgur, Ayumi, 2 invisible),
690
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Turn Panels of and on - depending on a variable
#408652
10/05/12 09:05
10/05/12 09:05
|
Joined: Jul 2010
Posts: 974 United Arab Emirates, Dubai
TheShooter
OP
User
|
OP
User
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
|
Hi, I'm trying to hide my ammopanel, when the variable armed = 0. And I want also to show panels for different weapontypes depending on the value of armed. E.g. armed = 1 - pistolammo armed = 2 - rifleammo I also tried to work with INVISIBLE and TRANSLUCENT, but both don't work for me. Since I noticed that INVISIBLE is only for Level-Entitys, I worked with TRANSLUCENT from this point. Here's my code so far: The ammo and armed variables are global.
function hud()
{
//armed = 0 - unarmed
//armed = 1 - Pistol
//armed = 2 - Rifle
//armed = 3 - Shotgun
PANEL* pistol_muni_pan =
{
digits(1450,925,3,"Arial#150b",1,ammo_pistol);
flags = TRANSLUCENT;
}
pistol_muni_pan.alpha = 0;
PANEL* rifle_muni_pan =
{
digits(1450,925,3,"Arial#150b",1,ammo_rifle);
flags = TRANSLUCENT;
}
rifle_muni_pan.alpha = 0;
while(armed > 0)
{
switch(armed)
{
case 1:
pistol_muni_pan.alpha = 100;
case 2:
rifle_muni_pan.alpha = 100;
}
wait(1);
}
pistol_muni_pan.alpha = 0;
rifle_muni_pan.alpha = 0;
}
Am I doing something wrong? I did this a year ago the same way, and it worked just fine. (unfortunately I don't have the code any more) Would be really thankful for help, Shooter
|
|
|
Re: Turn Panels of and on - depending on a variable
[Re: MasterQ32]
#408654
10/05/12 09:08
10/05/12 09:08
|
Joined: Jul 2010
Posts: 974 United Arab Emirates, Dubai
TheShooter
OP
User
|
OP
User
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
|
I did already, and found this:
TRANSLUCENT Das Panel wird seinem alpha-Parameter entsprechend transparent gezeichent.
Which means at english, that the panel gets transparent with it's alphavalue.
And exactly this I tried in my code, since INVISIBLE didn't seem to work.
Last edited by TheShooter; 10/05/12 09:14.
|
|
|
Re: Turn Panels of and on - depending on a variable
[Re: MasterQ32]
#408658
10/05/12 09:34
10/05/12 09:34
|
Joined: Jul 2010
Posts: 974 United Arab Emirates, Dubai
TheShooter
OP
User
|
OP
User
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
|
Yes, I use SHOW to make them visible. But what can I use to make them invisible again? (!SHOW would be useful) I can't use toggle, because the panelmanagement is in a while, which would lead to complete chaos. regards, TheShooter
|
|
|
Re: Turn Panels of and on - depending on a variable
[Re: PadMalcom]
#408662
10/05/12 10:05
10/05/12 10:05
|
Joined: Jul 2010
Posts: 974 United Arab Emirates, Dubai
TheShooter
OP
User
|
OP
User
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
|
AH, thank you, I didn't know this command. The fully working code: (In the case someone needs such a code)
function hud()
{
//armed = 0 - unarmed
//armed = 1 - Pistol
//armed = 2 - Rifle
//armed = 3 - Shotgun
PANEL* pistol_muni_pan =
{
digits(1450,925,3,"Arial#150b",1,ammo_pistol);
}
PANEL* rifle_muni_pan =
{
digits(1450,925,3,"Arial#150b",1,ammo_rifle);
}
PANEL* shotgun_muni_pan =
{
digits(1450,925,3,"Arial#150b",1,ammo_shotgun);
}
while(1)
{
switch(armed)
{
case 1:
{
set(pistol_muni_pan, SHOW);
reset(rifle_muni_pan, SHOW);
reset(shotgun_muni_pan, SHOW);
break;
}
case 2:
{
set(rifle_muni_pan, SHOW);
reset(pistol_muni_pan, SHOW);
reset(shotgun_muni_pan, SHOW);
break;
}
case 3:
{
set(shotgun_muni_pan, SHOW);
reset(pistol_muni_pan, SHOW);
reset(rifle_muni_pan, SHOW);
break;
}
default:
reset(pistol_muni_pan, SHOW);
reset(rifle_muni_pan, SHOW);
reset(shotgun_muni_pan, SHOW);
}
wait(1);
}
}
Thank you, Shooter
|
|
|
Re: Turn Panels of and on - depending on a variable
[Re: TheShooter]
#408663
10/05/12 10:21
10/05/12 10:21
|
Joined: Mar 2006
Posts: 1,993 Karlsruhe
PadMalcom
Serious User
|
Serious User
Joined: Mar 2006
Posts: 1,993
Karlsruhe
|
Hey, eine kleine Verbesserung noch: - Setze die Panel-Definitionen (PANEL* pistol_muni_pan...) nicht in eine Funktion. Sonst kannst du später nicht von außen darauf zugreifen falls das mal nötig werden sollte. P.S. Sehr schön formatierter Quelltext EDIT: Und ich finde es toll, dass du die fertige Lösung nochmal postest!!!
Last edited by PadMalcom; 10/05/12 10:21.
|
|
|
|