sry for bugging you guys
Moderator: InsideQC Admins
3 posts
• Page 1 of 1
sry for bugging you guys
hi againg. i need help aging. This have been bugging me sometimes. i have entity mysery box and i want it to after use do sumthing here is my current state of code
void() mystery_buy =
{
if (other.classname != "player" && other.classname != "bot")
return;
other.buybox_time = time + 1;
};
void() usebox =
{
// THIS IS WHAT I NEED i know that self. blaah wont work beacause it would be for player not mystery box. and btw this function is caled else where if buybox time is bigger than time
void () mystery_box =
{
self.solid=SOLID_BBOX;
self.classname = "mystery";
setmodel (self, "progs/mystery.mdl");
precache_model ("progs/mystery.mdl");
setorigin(self, self.origin);
self.touch = mystery_buy;
};
coment explains what i need to know thx for help
void() mystery_buy =
{
if (other.classname != "player" && other.classname != "bot")
return;
other.buybox_time = time + 1;
};
void() usebox =
{
// THIS IS WHAT I NEED i know that self. blaah wont work beacause it would be for player not mystery box. and btw this function is caled else where if buybox time is bigger than time
void () mystery_box =
{
self.solid=SOLID_BBOX;
self.classname = "mystery";
setmodel (self, "progs/mystery.mdl");
precache_model ("progs/mystery.mdl");
setorigin(self, self.origin);
self.touch = mystery_buy;
};
coment explains what i need to know thx for help
- Jukki
- Posts: 214
- Joined: Wed Apr 07, 2010 4:59 am
What exactly are you trying to do? It's clear that you've created a new entity and that you're attempting to have it do something after a player (or bot) touches it, but it's not exactly clear what you want. Without more detail as to exactly what you're trying to accomplish, it's hard to provide very detailed help.
However, I'll try to provide what help I can based on what you've given so far. It seems that your main issue is that when usebox is called, you don't have a reference to the box you wish to manipulate handy. A simple way to fix this is to have mystery_buy set a field on other (the player) to point to itself. (Either add one or find one not used by players and bots.) Then in usebox, you can use self.whatever to get at the box.
However, there may a better way to do what you're trying to do, depending on how exactly you want the mystery box to function. So, once again, more details would be useful to provide better advice.
However, I'll try to provide what help I can based on what you've given so far. It seems that your main issue is that when usebox is called, you don't have a reference to the box you wish to manipulate handy. A simple way to fix this is to have mystery_buy set a field on other (the player) to point to itself. (Either add one or find one not used by players and bots.) Then in usebox, you can use self.whatever to get at the box.
However, there may a better way to do what you're trying to do, depending on how exactly you want the mystery box to function. So, once again, more details would be useful to provide better advice.
- Karatorian
- Posts: 31
- Joined: Tue Aug 17, 2010 4:26 am
- Location: Rindge, NH, USA
actualy never mind i got it working while ago but i have new problem. When i touch mbox and i type impulse 17 it activates mbox. It scrolls weapons and selects one by random. You must type impulse 17 againg in order to get that weapon BUT it pics it automaticaly (i dont want that feature) this is my code
and this is in impulse commands
- Code: Select all
void() mystery_buy;
$cd id1/models/mystery
$origin 0 0 24
$base base
$skin skin
$frame box1
void() resetbox =
{
self.frame = 0;
self.touch = mystery_buy;
self.boxopen = 0;
};
void() box_close1 =[ $box1, box_close2 ] { self.frame = 9;};
void() box_close2 =[ $box1, box_close3 ] { self.frame = 10;};
void() box_close3 =[ $box1, box_close4 ] { self.frame = 11;};
void() box_close4 =[ $box1, box_close5 ] { self.frame = 12;};
void() box_close5 =[ $box1, box_close6 ] { self.frame = 13;};
void() box_close6 =[ $box1, box_close7 ] { self.frame = 14;};
void() box_close7 =[ $box1, box_close8 ] { self.frame = 15;};
void() box_close8 =[ $box1, resetbox ] { self.frame = 16;};
void() closebox =
{
self = find (other, classname, "mystery");
box_close1 ();
};
void() takeboxweapon =
{
local float old;
old = self.weapon;
other = find (other, classname, "mystery");
if (other.boxweapon == 1)
{
if (self.weapons == 2)
{
self.boxweapon = 0;
self.items = self.items | IT_LIGHTNING - old;
self.weapon = IT_LIGHTNING;
self.rayclip = 20;
self.weapons = 2;
W_SetCurrentAmmo ();
}
else
self.boxweapon = 0;
{self.items = self.items | IT_LIGHTNING;}
sprint (self, "You got ray gun\n");
self.ammo_ray = 140;
self.rayclip = 20;
self.weapons = 2;
W_SetCurrentAmmo ();
}
else if (other.boxweapon == 2)
{
if (self.weapons == 2)
{
self.boxweapon = 0;
self.items = self.items | IT_SHOTGUN - old;
self.weapon = IT_SHOTGUN;
self.ammo_colt = 80;
self.pistolclip = 8;
W_SetCurrentAmmo ();
}
self.boxweapon = 0;
else
{self.items = self.items | IT_SHOTGUN;}
sprint (self, "You got colt gun\n");
self.ammo_colt = 80;
self.pistolclip = 8;
self.weapons = 2;
W_SetCurrentAmmo ();
self.boxweapon = 0;
}
};
void () SetBoxWeapon =
{
local entity old_self;
local float r;
newmis = spawn();
old_self = self;
self = newmis;
other = find (other, classname, "mystery");
r = random ();
self.solid=SOLID_NOT;
if (r < 0.5)
{
setmodel (self, "progs/g_ray.mdl");
other.boxweapon = 1;
}
else
{
setmodel (self, "progs/g_colt.mdl");
other.boxweapon = 2;
}
setorigin(self, other.origin + '0 0 38');
self.nextthink = time + 0.3;
self.think = SUB_Remove;
self = old_self;
};
void (vector high) Howermodel =
{
local entity old_self;
local float r;
newmis = spawn();
old_self = self;
self = newmis;
other = find (other, classname, "mystery");
r = random ();
self.solid=SOLID_NOT;
if (r < 0.5)
setmodel (self, "progs/g_ray.mdl");
else
setmodel (self, "progs/g_colt.mdl");
setorigin(self, other.origin + high);
self.nextthink = time + 0.3;
self.think = SUB_Remove;
self = old_self;
};
void() box_open1 =[ $box1, box_open2 ] { self.frame = 1; Howermodel('0 0 1');};
void() box_open2 =[ $box1, box_open3 ] { self.frame = 2; Howermodel('0 0 4');};
void() box_open3 =[ $box1, box_open4 ] { self.frame = 3; Howermodel('0 0 8');};
void() box_open4 =[ $box1, box_open5 ] { self.frame = 4; Howermodel('0 0 12');};
void() box_open5 =[ $box1, box_open6 ] { self.frame = 5; Howermodel('0 0 16');};
void() box_open6 =[ $box1, box_open7 ] { self.frame = 6; Howermodel('0 0 20');};
void() box_open7 =[ $box1, box_open8 ] { self.frame = 7; Howermodel('0 0 24');};
void() box_open8 =[ $box1, box_open9 ] { self.frame = 8; Howermodel('0 0 28');};
void() box_open9 =[ $box1, box_open10 ] { self.frame = 8; Howermodel('0 0 32');};
void() box_open10 =[ $box1, box_open11 ] { self.frame = 8; Howermodel('0 0 36');};
void() box_open11 =[ $box1, SetBoxWeapon ] { self.frame = 8;};
void() mystery_buy =
{
self = find (other, classname, "mystery");
if (other.classname != "player" && other.classname != "bot")
return;
if (self.boxweapon == 0)
other.buybox_time = time + 0.1;
else
other.takebox_time = time + 0.1;
};
void() usebox =
{
self = find (other, classname, "mystery");
if (self.boxopen == 1)
return;
self.boxopen = 1;
box_open1 ();
};
void () mystery_box =
{
self.solid=SOLID_TRIGGER;
self.classname = "mystery";
setmodel (self, "progs/mystery.mdl");
setorigin(self, self.origin);
self.touch = mystery_buy;
self.boxweapon = 0;
};
and this is in impulse commands
- Code: Select all
if (self.impulse == 17)
{
if (time < self.buykar_time && self.ammo_kar < 50)
if (self.weapon == IT_KAR)
Buykarammo ();
else
Buykar ();
else if (time < self.buybox_time)
usebox ();
else if (time < self.takebox_time)
takeboxweapon ();
}
- Jukki
- Posts: 214
- Joined: Wed Apr 07, 2010 4:59 am
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest