Author |
Topic: Disable the button for a score |
Moczulak |
General Member Since: Mar 30, 2009 Posts: 77 Last: Apr 8, 2013 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, May. 1, 2012 09:59 pm |
|
Hey all
I am trying to create a button that will be blocked, which will be visible but will be gray and will not action after mouse click.
Only when the 5 rank and button unlocks.
Look in my script:
Ps. Below script im save in format .gsc and im add thread in file zom.gsc to Callback_StartGameType()
Code:
init()
{
for(;;)
{
level waittill("connected",player);
player thread playerconnected();
}
}
playerconnected()
{
self endon("disconnect");
self thread files\hud\hud_rank::hudLogo();
self thread files\hud\hud_rank::hudText();
self thread files\hud\hud_propertiesplayer::hudLogo();
self thread files\hud\hud_propertiesplayer::hudText();
for(;;)
{
wait 0.5;
if(isDefined(self.rank) && self.rank <= 5)
{
self setClientCvar("ui_allow_crossbow", "1");
}
else
{
self setClientCvar("ui_allow_crossbow", "2");
}
}
}
And some weapon_american.menu:
Code: itemDef
{
name "button_crossbow"
visible 1
rect 0 0 170 18
origin ORIGIN_CHOICE1
forecolor NORMAL_UNFOCUSED_COLOR
type ITEM_TYPE_BUTTON
text "@MPUI_1_CROSSBOW"
textfont UI_FONT_NORMAL
textscale .28
textstyle ITEM_TEXTSTYLE_SHADOWED
textalignx 5
textaligny 14
dvar "ui_allow_crossbow"
showDvar { "1" }
action
{
play "mouse_click";
scriptmenuresponse "crossbow_mp";
}
onFocus
{
hide m1carbine_info;
play "mouse_over";
show crossbow_info;
}
}
itemDef
{
name "button_crossbow"
visible 1
rect 0 0 170 18
origin ORIGIN_CHOICE1
forecolor GLOBAL_DISABLED_COLOR
type ITEM_TYPE_BUTTON
text "@MPUI_1_CROSSBOW"
textfont UI_FONT_NORMAL
textscale .28
textalignx 5
textaligny 14
dvar "ui_allow_crossbow"
showDvar { "2" }
onFocus
{
hide m1carbine_info;
play "mouse_over";
show crossbow_info;
}
}
My problem is the appearance of the two buttons at one time in one place...
Then I gather that this script .gsc is not working properly...
edited on May. 1, 2012 02:59 pm by Moczulak
edited on May. 1, 2012 03:00 pm by Moczulak
edited on May. 1, 2012 03:00 pm by Moczulak |
|
|
|
IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, May. 1, 2012 10:24 pm |
|
replace "dvar" in your menu file with "dvartest" for both items.
edited on May. 1, 2012 03:24 pm by IzNoGoD
Edit: for the rest of your script, try not to do this in a loop. It takes unneccesary resources (setclientdvars can cause errors if used extensively), but instead set it each time a user levels up and on connect.
Also, check in your script at the menuresponse if a user has the required rank before processing. Wouldnt be the first time a menu will be exploited in such a way.
edited on May. 1, 2012 03:26 pm by IzNoGoD
Edit2: you might find that lvl 5 does not yet unlock the button. Replace the <=5 with <5 in your script to fix this
edited on May. 1, 2012 03:27 pm by IzNoGoD
Edit3: if you use it this way, the button will also unlock if the level of the user is undefined. replace the && in your if with || to fix this.
edited on May. 1, 2012 03:28 pm by IzNoGoD
Edit4: now i have more edits in this post than you have. :P |
|
|
|
Moczulak |
General Member Since: Mar 30, 2009 Posts: 77 Last: Apr 8, 2013 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, May. 1, 2012 10:42 pm |
|
Look.. again not works... please somebody help me...
I can not write good scripts based on cvarach so I ask you for help.
Code:
init()
{
for(;;)
{
level waittill("connected",player);
player thread playerconnected();
}
}
playerconnected()
{
self endon("disconnect");
self thread files\hud\hud_rank::hudLogo();
self thread files\hud\hud_rank::hudText();
self thread files\hud\hud_propertiesplayer::hudLogo();
self thread files\hud\hud_propertiesplayer::hudText();
if(isDefined(self.rank) && self.rank < 5)
{
self setClientCvar("ui_allow_crossbow", "1");
}
else
{
self setClientCvar("ui_allow_crossbow", "2");
}
} |
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
|
IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
|
Moczulak |
General Member Since: Mar 30, 2009 Posts: 77 Last: Apr 8, 2013 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Wednesday, May. 2, 2012 04:57 pm |
|
Look.. again not works :(
Code: itemDef
{
name "button_crossbow"
visible 1
rect 0 0 170 18
origin ORIGIN_CHOICE1
forecolor NORMAL_UNFOCUSED_COLOR
type ITEM_TYPE_BUTTON
text "@MPUI_1_CROSSBOW"
textfont UI_FONT_NORMAL
textscale .28
textstyle ITEM_TEXTSTYLE_SHADOWED
textalignx 5
textaligny 14
dvartest "scr_allow_crossbow"
showDvar { "1" }<br />
<br />
action
{
play "mouse_click";<br />
<br />
scriptmenuresponse "crossbow_mp";
}
onFocus
{
hide m1carbine_info;<br />
<br />
play "mouse_over";<br />
<br />
show crossbow_info;
}
}
itemDef
{
name "button_crossbow"
visible 1
rect 0 0 170 18
origin ORIGIN_CHOICE1
forecolor GLOBAL_DISABLED_COLOR
type ITEM_TYPE_BUTTON
text "@MPUI_1_CROSSBOW"
textfont UI_FONT_NORMAL
textscale .28
textalignx 5
textaligny 14
dvartest "scr_allow_crossbow"
showDvar { "2" }<br />
<br />
onFocus
{
hide m1carbine_info;<br />
<br />
play "mouse_over";<br />
<br />
show crossbow_info;
}
}
Code: init()
{
for(;;)
{
level waittill("connected",player);
player thread playerconnected();
}
}
playerconnected()
{
self endon("disconnect");
self thread files\hud\hud_rank::hudLogo();
self thread files\hud\hud_rank::hudText();
self thread files\hud\hud_propertiesplayer::hudLogo();
self thread files\hud\hud_propertiesplayer::hudText();
for(;;)
{
wait 0.5;
if(isDefined(self.rank) && self.rank < 5)
{
self setClientCvar("scr_allow_crossbow", "1");
}
else
{
self setClientCvar("scr_allow_crossbow", "2");
}
}
} |
|
|
|
Tally |
General Member Since: Apr 21, 2005 Posts: 819 Last: Oct 26, 2012 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Wednesday, May. 2, 2012 06:18 pm |
|
Try this:
Code: itemDef
{
name "button_crossbow"
visible 1
rect 0 0 170 18
origin ORIGIN_CHOICE1
forecolor NORMAL_UNFOCUSED_COLOR
type ITEM_TYPE_BUTTON
text "@MPUI_1_CROSSBOW"
textfont UI_FONT_NORMAL
textscale .28
textstyle ITEM_TEXTSTYLE_SHADOWED
textalignx 5
textaligny 14
dvartest "scr_allow_crossbow"
showDvar { "1" }
action
{
play "mouse_click";
scriptmenuresponse "crossbow_mp";
}
onFocus
{
hide m1carbine_info;
play "mouse_over";
show crossbow_info;
}
}
itemDef
{
name "button_crossbow"
visible 1
rect 0 0 170 18
origin ORIGIN_CHOICE1
forecolor GLOBAL_DISABLED_COLOR
type ITEM_TYPE_BUTTON
text "@MPUI_1_CROSSBOW"
textfont UI_FONT_NORMAL
textscale .28
textalignx 5
textaligny 14
dvartest "scr_allow_crossbow"
hideDvar { "1" }
onFocus
{
hide m1carbine_info;
play "mouse_over";
show crossbow_info;
}
}
Code: init()
{
level thread onPlayerConnect();
}<br />
<br />
onPlayerConnect()
{
for(;;)
{
level waittill( "connected",player );
player thread onJoinedTeam();
}
}<br />
<br />
onJoinedTeam()
{
self endon( "disconnect" );
for(;;)
{
self waittill( "joined_team" );<br />
<br />
self thread files\hud\hud_rank::hudLogo();
self thread files\hud\hud_rank::hudText();
self thread files\hud\hud_propertiesplayer::hudLogo();
self thread files\hud\hud_propertiesplayer::hudText();
if( isDefined(self.rank) && self.rank < 5 )
self setClientCvar( "scr_allow_crossbow", "1" );
else
self setClientCvar( "scr_allow_crossbow", "0" );
}
} |
|
|
|
Moczulak |
General Member Since: Mar 30, 2009 Posts: 77 Last: Apr 8, 2013 [view latest posts] |
|
|
|
Moczulak |
General Member Since: Mar 30, 2009 Posts: 77 Last: Apr 8, 2013 [view latest posts] |
|
|
|
IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Sunday, May. 6, 2012 10:18 pm |
|
IzNoGoD writes...Quote:
Edit: for the rest of your script, try not to do this in a loop. It takes unneccesary resources (setclientdvars can cause errors if used extensively), but instead set it each time a user levels up and on connect.
Please read everything that gets posted in this thread. People might not take kindly to being ignored. |
|
|
|