Forum

putclientinserver ?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

putclientinserver ?

Postby ceriux » Mon Mar 28, 2011 2:16 am

okay i know you can make a special putclientinserver function for an observer, but is it possible to do it for seperate classes? or would it be easier to do a "if (self.pclass == #) and change the load out before hand and have it just spawn the client in as a normal put client in server. my mod will be coop and not have teams if that helps any.

also in the future to mention. ill also be having each class have it's own model.

what would be the smartest way to go about this?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby DusterdooSmock » Mon Mar 28, 2011 3:28 am

Well, PutClientInServer is called by the engine...so for different classes, you would have to have a check in PutClientInServer.
Something like this:
Code: Select all
void() PutClientInServer =
{
      if(self.pclass == CLASS1)
            PutClass1PlayerInServer();
      else if(self.pclass == CLASS2)
            PutClass2PlayerInServer();
};
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby Mexicouger » Mon Mar 28, 2011 3:38 am

I did something similar like this for gametypes. I just made a switch statement like this:

Code: Select all
void() Setup_Gametypes =
{
switch (deathmatch)
{
case 1:
self.health = 100;
self.view_ofs = '0 0 24';
etc
break;
case 2:
more stuff;
}
};

void() PutClientInServer =
{
Setup_Gametypes();
};
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby ceriux » Mon Mar 28, 2011 5:37 am

would it be easier to do something like this?

Code: Select all
void() SetNewParms =
{
        if (!self.pclass)

        parm1 = 0;

   if (self.plass ==1)
        {
        parm1 = IT_SHOTGUN | IT_AXE;
        }
        if (self.plass ==2)
        {
        parm1 = IT_SHOTGUN | IT_AXE;
        }
        if (self.plass ==1)
        {
        parm1 = IT_SHOTGUN | IT_AXE;
        }
   parm2 = 100;
   parm3 = 0;
   parm4 = 25;
   parm5 = 0;
   parm6 = 0;
   parm7 = 0;
   parm8 = 1;
   parm9 = 0;
};


or would that not even work?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Spike » Mon Mar 28, 2011 12:29 pm

Any occurence of 'self' inside SetNewParms is a bug. The engine will not set it, and you'll get a 'random' entity instead of the player.

If required, store a null class's fields in there, and set the actual defaults on actual initial spawn.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby ceriux » Mon Mar 28, 2011 6:15 pm

meh, the putclientinserver way is the best way hah lol. ill just change the weapon setup with the menu...
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby ceriux » Tue Mar 29, 2011 5:15 am

okay so my observer isnt working.

i have "self.pclass = 0;" in client connect and this is my observer and player code.

why is my player still spawning as a normal player?


Code: Select all
void() PutGhostInServer =
{
   local   entity spot;

   spot = SelectSpawnPoint ();

   self.classname = "player";
   self.health = 100;
   self.takedamage = DAMAGE_NO;
   self.solid = SOLID_SLIDEBOX;
   self.movetype = MOVETYPE_NONE;
   self.show_hostile = 0;
   self.max_health = 100;
   self.flags = FL_CLIENT;
   self.air_finished = time + 12;
   self.dmg = 2;         // initial water damage
   self.super_damage_finished = 0;
   self.radsuit_finished = 0;
   self.invisible_finished = 0;
   self.invincible_finished = 0;
   self.effects = 0;
   self.invincible_time = 0;
   self.pclass = self.pclass;

   DecodeLevelParms ();
   
   W_SetCurrentAmmo ();

   self.attack_finished = time;
   self.th_pain = player_pain;
   self.th_die = PlayerDie;
   
   self.deadflag = DEAD_NO;
// paustime is set by teleporters to keep the player from moving a while
   self.pausetime = 0;
   
//   spot = SelectSpawnPoint ();

//   self.origin = spot.origin + '0 0 1';
   self.origin = self.oldorigin = spot.origin + '0 0 1';   // 1998-07-21 Respawning where player died fix by Robert Field
   self.angles = spot.angles;
   self.fixangle = TRUE;      // turn this way immediately

// oh, this is a hack!
   setmodel (self, "progs/eyes.mdl");
   modelindex_eyes = self.modelindex;

   setmodel (self, "progs/eyes.mdl");
   modelindex_player = self.modelindex;

   setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
   
   self.view_ofs = '0 0 22';
   
   self.velocity = '0 0 0';   // 1998-07-21 Player moves after respawn fix by Xian

   self.items = self.items - (self.items &
   (IT_AXE | IT_SHOTGUN | IT_SUPER_SHOTGUN | IT_NAILGUN | IT_SUPER_NAILGUN | IT_GRENADE_LAUNCHER | IT_ROCKET_LAUNCHER | IT_LIGHTNING| IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );

   player_stand1 ();
   
   if (deathmatch || coop)
   {
      makevectors(self.angles);
      spawn_tfog (self.origin + v_forward*20);
   }

   spawn_tdeath (self.origin, self);
};


void() PutClientInServer =
{
   
   local   entity spot;

   spot = SelectSpawnPoint ();
   
   
   if (self.pclass < 1)
   {
      PutGhostInServer();
   }

   self.classname = "player";
   self.health = 100;
   self.takedamage = DAMAGE_AIM;
   self.solid = SOLID_SLIDEBOX;
   self.movetype = MOVETYPE_WALK;
   self.show_hostile = 0;
   self.max_health = 100;
   self.flags = FL_CLIENT;
   self.air_finished = time + 12;
   self.dmg = 2;         // initial water damage
   self.super_damage_finished = 0;
   self.radsuit_finished = 0;
   self.invisible_finished = 0;
   self.invincible_finished = 0;
   self.effects = 0;
   self.invincible_time = 0;
   self.pclass = self.pclass;

   DecodeLevelParms ();
   
   W_SetCurrentAmmo ();

   self.attack_finished = time;
   self.th_pain = player_pain;
   self.th_die = PlayerDie;
   
   self.deadflag = DEAD_NO;
// paustime is set by teleporters to keep the player from moving a while
   self.pausetime = 0;
   
//   spot = SelectSpawnPoint ();

//   self.origin = spot.origin + '0 0 1';
   self.origin = self.oldorigin = spot.origin + '0 0 1';   // 1998-07-21 Respawning where player died fix by Robert Field
   self.angles = spot.angles;
   self.fixangle = TRUE;      // turn this way immediately

// oh, this is a hack!
   setmodel (self, "progs/eyes.mdl");
   modelindex_eyes = self.modelindex;

   setmodel (self, "progs/player.mdl");
   modelindex_player = self.modelindex;

   setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
   
   self.view_ofs = '0 0 22';
   
   self.velocity = '0 0 0';   // 1998-07-21 Player moves after respawn fix by Xian

   player_stand1 ();
   
   if (deathmatch || coop)
   {
      makevectors(self.angles);
      spawn_tfog (self.origin + v_forward*20);
   }

   spawn_tdeath (self.origin, self);
};


edit: got it to work half way with this

Code: Select all
void() PutClientInServer =
{
   
   
   if (self.pclass == 0)
   {
      PutGhostInServer();
   }
   
   if (self.pclass == 1)
   {
      PutClass1InServer();
   }

};


just need to find a way to remove all weps from the 'ghost.'
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby r00k » Tue Mar 29, 2011 8:53 am

there's alot of unnecessary duplicate code there.

Code: Select all
self.takedamage    = DAMAGE_NO;
   self.solid       = SOLID_NOT;
   self.effects       = 0;
   // status bar stuff
   self.health      = 1000;
   self.items = self.items - (self.items & (IT_SHOTGUN | IT_SUPER_SHOTGUN | IT_NAILGUN | IT_SUPER_NAILGUN | IT_GRENADE_LAUNCHER | IT_ROCKET_LAUNCHER | IT_LIGHTNING | IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3));
   self.armorvalue    = 0;
   self.ammo_shells    = 0;
   self.ammo_nails    = 0;
   self.ammo_rockets    = 0;
   self.ammo_cells    = 0;
   self.currentammo    = 0;
   self.show_hostile    = 0;

   // model and view offset
   setmodel(self, "progs/eyes.mdl");
   setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);

   self.model       = string_null;
   self.mdl      = string_null;
   self.nextthink      = -1;
   self.think       = SUB_Null;

   self.weaponmodel    = string_null;
   self.weapon       = 0;
   setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
   self.view_ofs       = '0 0 22';
   self.flags = self.flags - (self.flags & FL_INWATER);
   



http://www.quakeone.com/qrack/elohim22.zip <-- is a basic dm mod with a decent observer mode and full comments. It might help as a guide...
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby DusterdooSmock » Tue Mar 29, 2011 12:57 pm

r00k wrote:there's alot of unnecessary duplicate code there.

Yeah, the best way to do it would be to have all of the stats that will be the same set in putclientinserver, then you add a check to putclientinserver for the player's class, if the player is a certain class, then it sets the stats that are specific to him.

Hope that helped a little bit. :D
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby r00k » Wed Mar 30, 2011 11:04 am

the code i posted was a generic way to spawn just a pair of eyes with nothing on the status bar, though a MOVETYPE_WALK would be the next step. (no pun intended)...
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby ceriux » Wed Mar 30, 2011 4:04 pm

i dont want him to walk. question though is there a way to get the same effect, with out having to have a power up? the screen's always blue now.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest