Jump to content
SubSpace Forum Network

Recommended Posts

Posted

Ok, im trying to add something so that if your losses is at 3, you get specced. I looked at player.h and it has losses, so i did this:

 

if (p->losses == 3) sendPublic("*arena " +(String)p->name +" is eliminated");

 

But, thats giving me some screwed up error, saying that "losses" isnt a m ember of player..

 

Someone wanna help me out?

 

Thanks -DeadlySoldier!!

Posted

in player.h under external dependencies you can add "int deaths" to the player struct

 

struct Player

{

Uint16 ident;

Operator_Level access;

Player *turret;



Uint16 flagCount;



Uint32 lastPositionUpdate;

bool acceptsAudio;



>>>>> int deaths; <<<<<



char name[20];

char squad[20];

BYTE banner[96];



BYTE ship;

BYTE d;



Uint16 bounty;

Uint16 energy;



Uint16 timer;

Uint16 S2CLag;



Vector tile, pos, work, vel;



bool stealth, cloak, xradar, awarp, ufo, flash, safety;



bool shields, supers;

BYTE burst, repel, thor, brick, decoy, rocket, portal;



Uint16 team;



Score score;



bool koth;



void setBanner(char *bbanner);



void clone(Player *p);

void move(Sint32 x, Sint32 y, Sint32 vx, Sint32 vy);

void move(Sint32 x, Sint32 y);

void move(Sint32 time);



Player(Uint16 iident, char *nname, char *ssquad, Uint32 fflagPoints, Uint32 kkillPoints, Uint16 tteam, Uint16 wwins, Uint16 llosses, BYTE sship, bool aacceptsAudio, Uint16 fflagCount);

};

 

to initialize the variable to 0, put this in under EVENT_PlayerEntering

 

case EVENT_PlayerEntering:

{

   Player *p = (Player*)event.p[0];

   

   p->deaths = 0;



break;

}

 

 

 

 

now in spawn.cpp goto "EVENT_PlayerDeath"

and insert this code under it;

 

case EVENT_PlayerDeath:

{

   Player *p = (Player*)event.p[0],

  *k = (Player*)event.p[1];

   Uint16 bounty = (Uint16)event.p[2];



   p->deaths = p->deaths + 1; /* increases players death count by 1 */



   if (p->deaths == 3)

   {

   p->deaths = 0; /* resets players deaths so when they are unspecced they won't be specced automatically*/



   sendPrivate(p, "*spec");

   sendPrivate(p, "You have been killed 3 times, you will now be placed    in spectator mode");



   sendPublic("*arena "+(String)p->name+ " has been eliminated");

   }

break;

}

 

 

Hope this helps, and if there is a easier way, feel free to correct me :D

Posted

Nope, even easier. Notice the subclass score in class Player. In there you will find wins, losses, etc.

 

You want p->score.wins, p->score.losses

 

 

 

Also, youre not initiallizing in the way you want. In the constructor, you will want to have "kills = 0;" The constructor is (for your purposes) a type-less function with the same name as the class. ie Player::Player(); In this case, the constructor takes a -*BAD WORD*-load more arguements, but you get the gist.

 

Rock on.

Posted

Two things:

 

1. You can do p->deaths++ to increment by 1. This is very useful for readability and to avoid typos in longer expressions like:

 

alongptrname->alongarrayname[alongvarname].alongmembername = alongptrname->alongarrayname[alongvarname].longmembername + 1;

 

2. If you send a player a single *spec, they are locked in spec until they quit and come back. If your arena is locked for the duration of the game, you should probably send *spec twice when you spec them. That will put them in spec, but unlock them.

Posted

Well then, Ekteds and Nexus are right.

You can try to sendPublic("*scorereset"); to use p->score.losses, and since this only resets those in the arena, lock it, and make sure to only check those in-ships. If a spectator enters with 30deaths he may be royaly screwed.

 

Also, if you just want a death count for this one plugin, use player tags. ITs already in merv plugins, and they reset as players leave and such, to prevent it from getting too big.

set_tag(Player *p, int TagNumber, int Value);

//stores info to a player tag for retrieval.

get_tag(Player *p, int TagNUmber);

//Retruns the value of Value for the tag number.  If the player doesnt exist, there is no tag !@#$%^&*igned that number, or there is no value stored, it returns 0

 

ie:

EVENT_PlayerDeath

{

set_tag(p,1,get_tag(p,1)+1);



if(get_tag(p,1)>=5)

{

  .....

  //eliminated.

}

};

break;

Guest
This topic is now closed to further replies.
×
×
  • Create New...