1 registered members (7th_zorro),
793
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Panel Fading Problems
[Re: xbox]
#214619
07/05/08 19:07
07/05/08 19:07
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
Ok here is an example of the top of my head... 1) Create a variable to act as counter. 2) Create a TEXT object with the string set as the longest gun name. 3) Create a function for the Q and E keys, which inside increments the counter. 4) Check the counter number against gun number or something 5) Finally change the TEXT object's string by using str_cpy( my_text.string[0], "Gun name here!!!" ); Here is an example to clear things up. Just copy all of this into a blank WDL file and then run it. Press Q & E and the weapon names will switch.
var gun_number=1;
TEXT gun_label
{
pos_x=0;
pos_y=0;
string="Rocket Launcher";
flags=VISIBLE;
}
function check_weapon()
{
if(gun_number==1){str_cpy(gun_label.string[0], "Machine Gun");}
if(gun_number==2){str_cpy(gun_label.string[0], "Shotgun");}
if(gun_number==3){str_cpy(gun_label.string[0], "Rocket Launcher");}
if(gun_number==4){str_cpy(gun_label.string[0], "Shock Rifle");}
if(gun_number==5){str_cpy(gun_label.string[0], "Railgun");}
}
function prev_weapon()
{
if (gun_number==5){gun_number=1;}else{gun_number+=1;}
check_weapon();
}
function next_weapon()
{
if (gun_number==1){gun_number=5;}else{gun_number-=1;}
check_weapon();
}
function main()
{
vec_set(screen_color,vector(255,0,0)); // set background to prevent blur rendering
check_weapon();
on_q=prev_weapon;
on_e=next_weapon;
}
I've built this example with 5 weapons although it is easy to add more. Just make sure that the TEXT object's string is set to the longest name of a weapon.
Last edited by DJBMASTER; 07/05/08 19:12.
|
|
|
Re: Panel Fading Problems
[Re: DJBMASTER]
#214641
07/06/08 00:56
07/06/08 00:56
|
Joined: Nov 2006
Posts: 497 Ohio
xbox
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2006
Posts: 497
Ohio
|
It works correctly if i do what u said and put it in a separate file. But i tried using the code in my current project and it doesn't work. I have the two weapons, and the first line of each says this, action ak47
{
gun_number = 1;
...
}
action mp5
{
gun_number = 2;
...
}
Now when i start the game, the AK47 string loads along with the gun, but when i pick up the mp5, the string does not update. (the check function of mine is the same as yours). Any ideas?
|
|
|
Re: Panel Fading Problems
[Re: xbox]
#214643
07/06/08 03:00
07/06/08 03:00
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
No, don't call it straight away in the action. When you pick up a certain weapon, set the gun_number and then call the check function.
Last edited by DJBMASTER; 07/06/08 03:01.
|
|
|
Re: Panel Fading Problems
[Re: DJBMASTER]
#214652
07/06/08 05:41
07/06/08 05:41
|
Joined: Dec 2005
Posts: 116
tD_Datura_v
Member
|
Member
Joined: Dec 2005
Posts: 116
|
An icky alternative, for those that don't want it (probably most).
var gun_id = 0;
define guns_max = 8; // only 8 guns in this game
TEXT gun_strs {
pos_x = 0;
pos_y = 0;
strings = guns_max;
string = "Mental Manni's Middle Finger";
string = "Machine Gun";
string = "Shotgun";
string = "Rocket Launcher";
string = "Granny Panties";
string = "Bear Trap";
string = "Rolling Papers";
string = "Bob Saget's Decapitated Head";
}
// add to above
TEXT gun_display {
pos_x = 0;
pos_y = 0;
strings = 1;
}
function gun_show(gunn_id) {
gunn_id %= guns_max;
str_cpy(gun_display.string[0], gun_strs.string[gunn_id]);
return(gunn_id);
}
function gun_next() {
gun_id += 1; gun_id = gun_show(gun_id);
}
function gun_prev() {
gun_id -= 1; gun_id = gun_show(gun_id);
}
define _gun_id, skill?;
function gun_grab_event() {
my.event_impact = NULL;
gun_show(my._gun_id);
my._gun_id = -1;
}
function gun_spawn(gunn_id);
my._gun_id = gunn_id;
my.enable_impact = on;
my.event_impact = gun_grab_event;
while(ME != NULL) {
if (my._gun_id <= -1) {
break;
}
wait(1);
}
ent_remove(me);
}
Just ignore that, if appropriate.
|
|
|
|