Forum

Death timer?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Death timer?

Postby redrum » Mon Feb 18, 2008 5:40 am

Guys once again I am in a bind.
I'm trying to get a timer started when the player dies and stops when the player respawns and grabs his first item.

In Clientobituary() I tried:

Code: Select all
targ.deathtimer = time + 3;    //(I want my actions to take place 3 seconds after death)

if (targ.deathtimer == time)
if (targ.netname == "redrum")
   stuffcmd(targ, "say nice shot!\n");


Stopping the timer would be easy, so I don't need help with that part.
Any suggestions?
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 Willem » Mon Feb 18, 2008 10:17 am

I'm new to QuakeC but would:

Code: Select all
if (targ.deathtimer >= time)


Be any more reliable? Checking for == with floats is often bad news in C based languages.
Willem
 
Posts: 73
Joined: Wed Jan 23, 2008 10:58 am

Postby Orion » Mon Feb 18, 2008 1:09 pm

ClientObituary() is only called after a player is killed... if you check for that in there it won't work properly.

Remove the time check but keep this line and add another after it:

Code: Select all
targ.deathtimer = time + 3;
targ.dontloop = 0;


and put this new one in PlayerPreThink():

Code: Select all
if (self.deathtimer < time)
if (damage_attacker != self)
if (!self.dontloop)
{
         self.dontloop = 1;
         stuffcmd (self, "say nice shot!\n");
}


And at the very top of the file, add this line:

Code: Select all
.float dontloop;


And it should work. :)
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil


Return to QuakeC Programming

Who is online

Users browsing this forum: Bing [Bot] and 1 guest