AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   what best method detect triple kill per time? (https://forums.alliedmods.net/showthread.php?t=234093)

login_xcvop 01-25-2014 05:49

what best method detect triple kill per time?
 
what best method detect triple kill per time?

i can't search forum this !

CyberStars 01-25-2014 07:27

Re: what best method detect triple kill per time?
 
You can register event for "DeathMsg" and calculate how many enemies the player kills during some period of time.

^SmileY 01-25-2014 09:01

Re: what best method detect triple kill per time?
 
Quote:

Originally Posted by login_xcvop (Post 2090654)
what best method detect triple kill per time?

i can't search forum this !

See the MiscStats for this, or StatsX, this has double kill feature and you can perfectly add to check the Triple Kill :3

login_xcvop 01-25-2014 11:15

Re: what best method detect triple kill per time?
 
Quote:

Originally Posted by CyberStars (Post 2090674)
You can register event for "DeathMsg" and calculate how many enemies the player kills during some period of time.


show

CyberStars 01-29-2014 02:46

Re: what best method detect triple kill per time?
 
Quote:

Originally Posted by login_xcvop (Post 2090764)
show

Code:

new times[33] = {0, ...};
new killCount[33] = {0, ...};

public plugin_init()
{
          register_event("DeathMsg", "PlayerKilled", "a");
          register_logevent("RoundStart",2,"1=Round_Start");
}

public RoundStart()
{
          for(new i=0; i<sizeof(times); i++) {
                  times[i] = get_systime();
                  killCount[i] = 0;
          }
}

public PlayerKilled()
{
        new killerIndx = read_data(1);
        if(0 < killerIndx) {
                if(0 < killCount[killerIndx]) {
                          new currTime = get_systime();
                          // Check if the kills interval is within 90 sec.
                          if(90 >= currTime - times[killerIndx]) {
                                    killCount[killerIndx]++;
                          } else {
                                    killCount[killerIndx] = 1;
                                    times[killerIndx] = currTime;
                          }
                } else {
                          killCount[killerIndx] = 1;
                          times[killerIndx] = get_systime();
                }

                if(3 <= killCount[killerIndx]) {
                          // Triple Kill within 90 sec.
                }
        }
}


login_xcvop 01-29-2014 03:16

Re: what best method detect triple kill per time?
 
if i wanna add double kill ? and reset killCount per 3seconds, set task ?
PHP Code:

        if(<= killCount[killerIndx]) 
        {
                          
// double
        
}

        if(
<= killCount[killerIndx]) 
        {
                          
// triple
        



CyberStars 01-29-2014 03:39

Re: what best method detect triple kill per time?
 
Quote:

Originally Posted by login_xcvop (Post 2092360)
if i wanna add double kill ? and reset killCount per 3seconds, set task ?
PHP Code:

        if(<= killCount[killerIndx]) 
        {
                          
// double
        
}

        if(
<= killCount[killerIndx]) 
        {
                          
// triple
        



If you want to calculate number of kills within 3 seconds, you should also change
Code:

if(3 >= currTime - times[killerIndx]) {
      killCount[killerIndx]++;
} else {
      killCount[killerIndx] = 1;
      times[killerIndx] = currTime;
}

For other part of code, yes, you're right.

login_xcvop 01-29-2014 03:50

Re: what best method detect triple kill per time?
 
where put set_task ?

PHP Code:

set_task(1.0"RoundStart"killer)


public 
RoundStart()
{
    for(new 
i=0i<sizeof(times); i++) 
    {
        
times[i] = get_systime();
        
killCount[i] = 0;
    }



CyberStars 01-29-2014 03:55

Re: what best method detect triple kill per time?
 
Why do you need "set_task"?

For round start event just use
Code:

register_logevent("RoundStart",2,"1=Round_Start");
like here
PHP Code:

public plugin_init()
{
          
register_event("DeathMsg""PlayerKilled""a");
      
register_logevent("RoundStart",2,"1=Round_Start");



login_xcvop 01-29-2014 04:10

Re: what best method detect triple kill per time?
 
i don't need reset "for round start"
need restart if double and triple done


All times are GMT -4. The time now is 10:04.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.