Forum

"You've got the lead"

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Postby redrum » Mon Nov 19, 2007 1:35 am

Thanks guys, I'll give it a shot! :)
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby daemon » Mon Nov 19, 2007 3:53 am

This is what I had in mind, but you can use whatever works for you:

Code: Select all
void(entity ent, float amount)Frag =
{
   local entity oldleader;
   local float tie;
   oldleader = leader;
   ent.frags = ent.frags + amount;

   if(!deathmatch)
      return;

   head = nextent(world);
   while(head)
   {
      if(head.flags & FL_CLIENT)
      {
         if(head.frags == leader.frags)
            tie = TRUE;
         else
         if(head.frags > leader.frags)
         {
            leader = head;
            tie = FALSE;
         }
      }
      head = nextent(head);       
   }

   if(tie)
   {
      head = nextent(world);
      while(head)
      {
         if(head.flags & FL_CLIENT && head.frags == leader.frags)
            sprint(head, "You're tied for the lead.\n");
         head = nextent(head);
      }
   }
   else
   if(leader != oldleader)
   {
      sprint(leader, "You've got the lead.\n");
      if(oldleader.flags & FL_CLIENT)
         sprint(oldleader, "You've lost the lead.\n");
   }
};
-daemon [ daemonforge.org ]
User avatar
daemon
 
Posts: 63
Joined: Wed Nov 07, 2007 11:10 pm

Postby redrum » Mon Nov 19, 2007 7:07 am

Thanks for your help Daemon. It helped me learn!
Thats what I need. I still didn't grasp the whole thing though but thats ok. I got it working fairly well. I'll implement your code and let you know how it goes. I'm leaving for vacation in the morning, so it'll be awhile until I can test it.
Thanks again :D
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Previous

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest