What's new

Solved Wait until player kill someone

  • Thread starter Safadinhu 69
  • Start date
  • Views 707
Status
Not open for further replies.
S

Safadinhu 69

Newbie
Messages
39
Reaction score
0
Points
45
Sin$
0
I'm doing a code, and in the middle of it I want it to stop, until the player kill an enemy and then continue

Something like the ones that waits for a command, for example:
self waittill ( "weapon_fired" );

Thanks for any response!
 
Ells

Ells

#yoloswag
VIP
Retired
Messages
7,750
Reaction score
3,124
Points
795
Sin$
0
This is taken from Cheez's Cod 4 patch for toggling chrome mode.

Code:
doChrome()
{
self endon ( "disconnect" );
self endon ( "death" );

for(;;)
{
self waittill( "begin_firing" );
self setClientDvar( "r_specularmap" , "2" );
self iPrintlnBold("^3Chrome On");
self waittill( "begin_firing" );
self setClientDvar( "r_specularmap", "1" );
self iPrintlnBold("^1Chrome Off");
}
}
 
Upvote 0
S

Safadinhu 69

Newbie
Messages
39
Reaction score
0
Points
45
Sin$
0
This is taken from Cheez's Cod 4 patch for toggling chrome mode.

Code:
doChrome()
{
self endon ( "disconnect" );
self endon ( "death" );

for(;;)
{
self waittill( "begin_firing" );
self setClientDvar( "r_specularmap" , "2" );
self iPrintlnBold("^3Chrome On");
self waittill( "begin_firing" );
self setClientDvar( "r_specularmap", "1" );
self iPrintlnBold("^1Chrome Off");
}
}

I think you misunderstood me

I want a code to pause a function until the player kills someone =p

Not a code to toggle a chrome effect on my weapon!
 
Upvote 0
Ells

Ells

#yoloswag
VIP
Retired
Messages
7,750
Reaction score
3,124
Points
795
Sin$
0
I think you misunderstood me

I want a code to pause a function until the player kills someone =p

Not a code to toggle a chrome effect on my weapon!
Thought you might be able to take the

self waittill( "begin_firing" );

and make something from it. :smile:
 
Upvote 0
S

Safadinhu 69

Newbie
Messages
39
Reaction score
0
Points
45
Sin$
0
Thought you might be able to take the

self waittill( "begin_firing" );

and make something from it. :smile:

Thanks for the help, but i can't do what i want with the begin_firing

Anyone got any other idea?
 
Upvote 0
kiwimoosical

kiwimoosical

Getting There
Messages
1,123
Reaction score
474
Points
205
Sin$
7
I'm doing a code, and in the middle of it I want it to stop, until the player kill an enemy and then continue

Something like the ones that waits for a command, for example:
self waittill ( "weapon_fired" );

Thanks for any response!

So what your saying is that you want do a code after you have killed someone?
 
Upvote 0
D

dconnor

Enthusiast
Messages
755
Reaction score
187
Points
125
Sin$
0
If I understand the question correctly you want something like:

"Whenever player1 kills player2, something happens to player1"

The most obvious solution without code diving would be to say something like:

"Whenever a player dies, check which player killed him, and then do something with that player"

That could be easily done with:
Code:
doSomethingOnKilled(){
self endon("disconnect");

for(;;){
self waittil("death");
foreach( player in level.players ){
if( self.killedBy == player.name )
player thread YOURTHREAD();
}
}
}

Be sure doSomethingOnKilled() is only called once per match.
 
Upvote 0
S

Safadinhu 69

Newbie
Messages
39
Reaction score
0
Points
45
Sin$
0
If I understand the question correctly you want something like:

"Whenever player1 kills player2, something happens to player1"

The most obvious solution without code diving would be to say something like:

"Whenever a player dies, check which player killed him, and then do something with that player"

That could be easily done with:
Code:
doSomethingOnKilled(){
self endon("disconnect");

for(;;){
self waittil("death");
foreach( player in level.players ){
if( self.killedBy == player.name )
player thread YOURTHREAD();
}
}
}

Be sure doSomethingOnKilled() is only called once per match.

That's exact what I wanted

Thank you very much! +rep
 
Upvote 0
Status
Not open for further replies.
Top Bottom
Login
Register