Поиск Показать пользователя, который нанес последний удар

Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
kralik43, yes, but change %s to %n and use post hook (0 -> 1) at RegisterHookChain. And you need to check attacker is player, for example with is_user_connected.
 
Сообщения
43
Реакции
1
Oh thank you so much!
I did this way, is there anything I need to edit. Are there any bugs to use on a 32-person server.

If nobody hits the player, the output is like this.
( Last hit player: Console )

How can I turn them off when I fall down or get damaged?
When I got damaged from these, it came out in Last hit player: Console form.
fl0wer
Код:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <reapi>


#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new lasthitplayer[33];

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
  
    register_clcmd("say /lasthit","lasthitshow");
    RegisterHookChain(RG_CBasePlayer_TakeDamage, "playerdamage", 1)
}
public playerdamage(const victim, inflictor, const attacker, Float:damage)
{
    if(!is_user_connected(victim))
        return
      
    lasthitplayer[victim] = attacker;
}
public lasthitshow(const id)
{
    client_print_color(id,id,"^4Last hit player: ^3%n",lasthitplayer[id])
}
 
Последнее редактирование:
Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
I don't remember that attacker equal when damage by fall, it's victim == attacker or victim == 0. Or just check damagebits (5 arg) & DMG_FALL.
 
Сообщения
43
Реакции
1
fl0wer Finally, I realized something, when the player who attacked you leaves the game, she only shows your name, how can we prevent her.
 
Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
kralik43, there many ways are clear attacker for all players in loop at attacker disconnect, check connection attacker in show function or save name of attacker in takedamage.
 
Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
kralik43, these are 3 diffrent ways.
 
Сообщения
43
Реакции
1
Good Morning!

How can I reset the lasthitplayer[id] value when the player leaves the game?
Sample;
client_disconnected(id)
{
lasthitplayer[id] = 0
}
fl0wer
 
Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
Код:
for (new i = 1; i <= MaxClients; i++)
{
if (lasthitplayer[i] != id)
continue;

lasthitplayer[i] = 0;
}
 
Последнее редактирование:
Сообщения
278
Реакции
137
What about that?

Код:
#pragma semicolon 1

#include <amxmodx>
#include <reapi>

new g_iLastHitPerson[MAX_CLIENTS + 1];

public plugin_init() {
    register_plugin("Last Hit", "1.0", "PurposeLess");

    register_clcmd("say /lasthit", "@clcmd_lasthit");

    RegisterHookChain(RG_CBasePlayer_TakeDamage, "@CBasePlayer_TakeDamage_Post", .post = true);
    RegisterHookChain(RG_CBasePlayer_Spawn, "@CBasePlayer_Spawn_Post", .post = true);
}

@clcmd_lasthit(const pPlayer) {
    if(g_iLastHitPerson[pPlayer]) {
        client_print_color(pPlayer, pPlayer, "Last hit from %n", g_iLastHitPerson[pPlayer]);
    }
    else {
        client_print_color(pPlayer, pPlayer, "You haven't taken any damage yet.");
    }
    return PLUGIN_HANDLED;
}

@CBasePlayer_Spawn_Post(const pPlayer) {
    if(!is_user_alive(pPlayer)) {
        return;
    }

    g_iLastHitPerson[pPlayer] = 0;
}

@CBasePlayer_TakeDamage_Post(const pVictim, pInflictor, pAttacker, Float:flDamage, bitsDamageType) {
    if(pVictim == pAttacker || !is_user_connected(pAttacker)) {
        return;
    }

    g_iLastHitPerson[pVictim] = pAttacker;
}
 
Последнее редактирование:
Сообщения
594
Реакции
350
Предупреждения
1
Помог
9 раз(а)
Не аргументированная критика
PurposeLess, shit
// for admins dev-cs: cuz he is a copy paster
 
Последнее редактирование:
Сообщения
594
Реакции
350
Предупреждения
1
Помог
9 раз(а)
PurposeLess, what do u mean?
g_iLastHitPerson[pPlayer] = EOS;
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу