Kill messages
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
Kill messages
In ClientObit(), how would you call the players that are not involved in the kill?
I'm trying to centerprint to the "other" players informing them of the kill.
I tried: centerprint (other, "blah, blah, blah")
It compiles with no error, but it doesn't work?
Any suggestions?
I'm trying to centerprint to the "other" players informing them of the kill.
I tried: centerprint (other, "blah, blah, blah")
It compiles with no error, but it doesn't work?
Any suggestions?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
self is the person who died, and self.enemy is the person who killed
them, maybe run a loop thru the player entities, and if not self and not self.enemy then print the message.
you can actually call this function from
them, maybe run a loop thru the player entities, and if not self and not self.enemy then print the message.
- Code: Select all
void (entity killer, entity victim) obit_notify_players =
{
local entity oldself;
oldself = self;
self = find(world, classname, "player");
while (self)
{
if ((self != killer) && (self != victim))
centerprint4(self,killer.name," has fragged ",victim.name,"\n");
self = find(self, classname, "player");
}
self = oldself;
};
you can actually call this function from
- Code: Select all
void(entity targ, entity attacker) Killed =
{
...
self.enemy = attacker;
obit_notify_players(self.enemy,self);
...
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
In your case you might not need if unless you add more stats or entity functions in that loop.
Here's an example of how I use it more effectively:
Some functions passed thru "dofunc" specifically alter the self global, so we just need to save it out.
then if i call elsewhere:
it will execute void () arena_refresh_player for every player in the arena.
in all passing thru functions like that it's best to preserve the last "self" as it's a global entity that's used quite often.
here's a piece of code by J.P.Grossman that is very entertaining,
this allows you to schedule the execution of loading configs, or setting off triggers or effects etc.. quite useful. one note though, in the think function it needs to remove(self) of the local entity "temp" as this will create an overflow eventually.
Here's an example of how I use it more effectively:
Some functions passed thru "dofunc" specifically alter the self global, so we just need to save it out.
- Code: Select all
void (void () dofunc) utils_do_arena_players =
{
local entity oldself;
oldself = self;
self = find(world, classname, "player");
while (self)
{
if ((self.style & CA_CONNECTED) && (self.next_team))
dofunc ();
self = find(self, classname, "player");
}
self = oldself;
};
then if i call elsewhere:
- Code: Select all
utils_do_arena_players(arena_refresh_player);
it will execute void () arena_refresh_player for every player in the arena.
in all passing thru functions like that it's best to preserve the last "self" as it's a global entity that's used quite often.
here's a piece of code by J.P.Grossman that is very entertaining,
- Code: Select all
entity (void() think_function, float think_time) utils_make_scheduled_event =
{
local entity temp;
temp = spawn();
temp.classname = "scheduled_event";
temp.owner = self;
temp.nextthink = time + think_time;
temp.think = think_function;
return temp;
};
this allows you to schedule the execution of loading configs, or setting off triggers or effects etc.. quite useful. one note though, in the think function it needs to remove(self) of the local entity "temp" as this will create an overflow eventually.
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest