Post: Wait till you get a kill on someone else
01-30-2016, 09:29 PM #1
BullyWiiPlaza
Climbing up the ladder
(adsbygoogle = window.adsbygoogle || []).push({}); I need to wait till I get a kill on somebody else (so suicides should be excluded). I wrote a code so far that basically waits till some player gets a kill but it can't be used to check for specific players to get a kill. It basically waits till someone died and then triggers:
    waitTillSomePlayerDied()
{
level.playerKilledNotification = "playerKilled";

foreach(player in level.players)
{
player thread waitForDeath();
}

level waittill(level.playerKilledNotification);
}

waitForDeath()
{
level endon("game_ended");
level endon(level.playerKilledNotification);

self waittill("killed_player");

level notify(level.playerKilledNotification);
}

I wrote another script which waits till the player's kills amount increases so that I can tell that I got a kill but it doesn't work work well on Search & Destroy since kills sometimes don't increase and it's supposed to be used there mainly:
    // Waits till you killed another player but fails when kills on the scoreboard don't update
waitTillPlayerKilled()
{
self endon("disconnect");

oldKillsCount = self.pers["kills"];

while(true)
{
updatedKillsCount = self.pers["kills"];

if(updatedKillsCount > oldKillsCount)
{
return;
}

wait 0.05;
}
}

Both of them are not perfect so I'm wondering what could be done to fix the mentioned problems. I need this for an end game trickshot.

Thanks Kryptus
01-31-2016, 01:37 PM #11
jwm614
NextGenUpdate Elite
Originally posted by BullyWiiPlaza View Post
Alright but this waits till the calling entity dies, right? This is like my first example code since it can only tell that someone specific died but not that someone specific got a kill. This is a significant difference.


The use damage and attacker

The following user thanked jwm614 for this useful post:

BullyWiiPlaza
01-31-2016, 04:05 PM #12
BullyWiiPlaza
Climbing up the ladder
Originally posted by jwm614 View Post
The use damage and attacker

Good suggestion but it's not working though, here's my code:
    waitTillWeKilledAnotherPlayer()
{
self endon("disconnect");

while(true)
{
foreach(player in level.players)
{
// We don't care about damage to us
if(player == self)
{
continue;
}

if(!isDefined(player.waitingToBeKilled))
{
player.waitingToBeKilled = true;
thread waitToBeKilled(self);
}
}

wait 0.1;
}
}

waitToBeKilled(targetKiller)
{
self endon("disconnect");

while(true)
{
self waittill("damage", amount, attacker, direction, point, method);

if(attacker == targetKiller)
{
return;
}
}
}

Basically, the condition doesn't trigger when I damage/kill somebody.
01-31-2016, 04:46 PM #13
jwm614
NextGenUpdate Elite
Originally posted by BullyWiiPlaza View Post
Good suggestion but it's not working though, here's my code:
    waitTillWeKilledAnotherPlayer()
{
self endon("disconnect");

while(true)
{
foreach(player in level.players)
{
// We don't care about damage to us
if(player == self)
{
continue;
}

if(!isDefined(player.waitingToBeKilled))
{
player.waitingToBeKilled = true;
thread waitToBeKilled(self);
}
}

wait 0.1;
}
}

waitToBeKilled(targetKiller)
{
self endon("disconnect");

while(true)
{
self waittill("damage", amount, attacker, direction, point, method);

if(attacker == targetKiller)
{
return;
}
}
}

Basically, the condition doesn't trigger when I damage/kill somebody.




    
/*
* Jwm614 Black Ops 2 GSC Modifier
*
* Creator : JOE
* Project : killed
* Mode : Multiplayer
* Date : 11:40:17 AM
*
*/

#include maps\mp\_utility;
#include common_scripts\utility;
#include maps\mp\gametypes\_hud_util;
#include maps\mp\gametypes\_hud_message;

init()
{
level thread onPlayerConnect();
}

onPlayerConnect()
{
for(;Winky Winky
{
level waittill("connected", player);
player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
for(;Winky Winky
{
self waittill("spawned_player");

self thread waitToBeKilled();
// Will appear each time when the player spawns, just an exemple.
self iprintln("^1Jwm614 Black Ops 2 - GSC Modifier | Project : killed");
}
}



waitToBeKilled()
{
self endon("disconnect");
self endon("death");
level endon("game_ended");

for(;Winky Winky
{
self waittill( "damage", damage, attacker );
if(self.health <= damage)
attacker thread killedplayer(self);
}
}

killedplayer(player)
{
self iprintln("^1" + self.name + " ^7killed: ^1" + player.name);
}
Last edited by jwm614 ; 01-31-2016 at 05:42 PM.

The following user thanked jwm614 for this useful post:

BullyWiiPlaza
02-01-2016, 03:31 PM #14
BullyWiiPlaza
Climbing up the ladder
Originally posted by jwm614 View Post
...

Thanks but I guess I found the error I made in my code. It should be
    player thread waitToBeKilled(self);

instead of
    thread waitToBeKilled(self);

It definitely works now Happy
Last edited by BullyWiiPlaza ; 02-01-2016 at 03:39 PM.
02-01-2016, 05:07 PM #15
jwm614
NextGenUpdate Elite
Originally posted by BullyWiiPlaza View Post
Thanks but I guess I found the error I made in my code. It should be
    player thread waitToBeKilled(self);

instead of
    thread waitToBeKilled(self);

It definitely works now Happy


U should still check if the players dead it will run if you damage the player a little
02-01-2016, 05:29 PM #16
BullyWiiPlaza
Climbing up the ladder
Originally posted by jwm614 View Post
U should still check if the players dead it will run if you damage the player a little

Agreed

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo