What's new

Solved Wait until player kill someone

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

Safadinhu 69

Newbie
Messages
39
Reaction score
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!
 
E

Ells

#yoloswag
VIP
Retired
Messages
7,756
Reaction score
3,121
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");
}
}
 
S

Safadinhu 69

Newbie
Messages
39
Reaction score
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!
 
E

Ells

#yoloswag
VIP
Retired
Messages
7,756
Reaction score
3,121
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:
 
S

Safadinhu 69

Newbie
Messages
39
Reaction score
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?
 
K

kiwimoosical

Getting There
Messages
1,123
Reaction score
474
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?
 
D

dconnor

Enthusiast
Messages
755
Reaction score
187
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.
 
S

Safadinhu 69

Newbie
Messages
39
Reaction score
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
 
K

kiwimoosical

Getting There
Messages
1,123
Reaction score
474
nvm, didnt realize someone else solved haha, nvm
 
Status
Not open for further replies.
Top Bottom