AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Check the number of his murders and how many killed him. (https://forums.alliedmods.net/showthread.php?t=308759)

mewbie222 07-02-2018 14:40

Check the number of his murders and how many killed him.
 
And how to count the number of murders and how many times the player was killed and compare these values. If for example the player will kill more than it killed say 3 times (3 to 1) , he would be given some warning messages,kick or ban. Game Day of defeat source, here if you need an event https://wiki.alliedmods.net/Day_of_D..._Source_Events
Could someone write this ?
Sorry for bad English.

Ermert1992 07-04-2018 09:26

Re: Check the number of his murders and how many killed him.
 
No answers? Please help us. I´m interested, too.

mug1wara 07-04-2018 10:43

Re: Check the number of his murders and how many killed him.
 
PHP Code:

#include <sourcemod>

#pragma semicolon 1

int g_iKills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_Death);
}

public 
void OnMapEnd()
{
    for (
int i 1<= MaxClientsi++)
    {
        
g_iKills[i] = 0;
    }
}

public 
Action Event_Death(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
int iAttacker GetClientOfUserId(hEvent.GetInt("attacker"));
    
    if (
IsValidClient(iAttacker))
    {
        
g_iKills[iAttacker]++;
        
        if (
g_iKills[iAttacker] == DesiredAmountOfKills)
        {
            
/* Perform an action here */
        
}
    }
}

stock bool IsValidClient(int iClient)
{
    if (!(
iClient <= MaxClients) || !IsClientInGame(iClient) || IsFakeClient(iClient))
    {
        return 
false;
    }
    
    return 
true;



mewbie222 07-04-2018 11:37

Re: Check the number of his murders and how many killed him.
 
Quote:

Originally Posted by mug1wara (Post 2600974)
PHP Code:

#include <sourcemod>

#pragma semicolon 1

int g_iKills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_Death);
}

public 
void OnMapEnd()
{
    for (
int i 1<= MaxClientsi++)
    {
        
g_iKills[i] = 0;
    }
}

public 
Action Event_Death(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
int iAttacker GetClientOfUserId(hEvent.GetInt("attacker"));
    
    if (
IsValidClient(iAttacker))
    {
        
g_iKills[iAttacker]++;
        
        if (
g_iKills[iAttacker] == DesiredAmountOfKills)
        {
            
/* Perform an action here */
        
}
    }
}

stock bool IsValidClient(int iClient)
{
    if (!(
iClient <= MaxClients) || !IsClientInGame(iClient) || IsFakeClient(iClient))
    {
        return 
false;
    }
    
    return 
true;



Something does not understand where this variable identified with the DesiredAmountOfKills
And if I correctly understood your code, then the check occurs in a ratio of 1 to 1, that is, 1 time he killed 1 time it. It seems clear written in English , and how to do for example a test not immediately, but for example after 30 murders of enemies or 10 of your own deaths.
so thanks for the example, but I'm still not very much in SourcePawn.

added:
Everything is understood, you are simply in the process of counting the count of murders and who killed. And I would like the data on this to be taken from the table that appears after pressing the TAB key. Нere is a screenshot of the table http://expandedcs.com/uploads/posts/...css3v34v84.jpg
I just thought from this table it's not easier to take information, and only then do the calculations. Just say not after every murder and for example in 1-2 minutes.
Will the server be lagging too much because of your cat ?! (question out of curiosity)
And so once again thank you, we will try it .. but you count 1 to 1. I would like type 3 to 1.

Sorry for the bad English.


All times are GMT -4. The time now is 01:19.

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