Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Plugin generated by AMXX-Studio */
- #pragma semicolon 1
- #define TIMEDELAY_RESET 1.0
- #define TAKEDAMAGE_CHANNEL 2
- #define DEALDAMAGE_CHANNEL 3
- #include "amxmodx.inc"
- #include "hamsandwich.inc"
- #include "cstrike.inc"
- #include "engine.inc"
- new Float: g_flTime[MAX_PLAYERS][MAX_PLAYERS];
- new Float: g_flDamage[MAX_PLAYERS][MAX_PLAYERS];
- new g_pFriendlyFire;
- public plugin_init()
- {
- register_plugin("Damage Taken", "V1.0", "Yannay"); // for faggot yuval -- from 2014
- RegisterHamPlayer(Ham_TakeDamage, "Ham_TakeDamage_Post", 1);
- g_pFriendlyFire = get_cvar_pointer("mp_friendlyfire");
- }
- public Ham_TakeDamage_Post(const iVictim, const iInflictor, const iAttacker, Float: flDamage)
- {
- if(!(1 <= iVictim <= MaxClients) || !(1 <= iAttacker <= MaxClients))
- {
- return HAM_IGNORED;
- }
- if(cs_get_user_team(iVictim) == cs_get_user_team(iAttacker))
- {
- if(get_pcvar_num(g_pFriendlyFire)) {
- flDamage /= 3.0;
- }
- else
- {
- return HAM_IGNORED;
- }
- }
- if(halflife_time() - g_flTime[iVictim - 1][iAttacker - 1] >= TIMEDELAY_RESET)
- {
- g_flDamage[iVictim - 1][iAttacker - 1] = 0.0;
- }
- g_flTime[iVictim - 1][iAttacker - 1] = halflife_time();
- g_flDamage[iVictim - 1][iAttacker - 1] += flDamage;
- if(g_flDamage[iVictim - 1][iAttacker - 1] >= 1.0) {
- static iSpectatingIndex;
- for(new i = 1; i <= MaxClients; i++) {
- if(!is_user_connected(i) || is_user_alive(i) || i == iVictim || i == iAttacker) // is our player a spectator?
- {
- continue;
- }
- iSpectatingIndex = entity_get_int(i, EV_INT_iuser2); // figure out which player the index that we are looking at is spectating
- if(!(1 <= iSpectatingIndex <= MaxClients))
- {
- continue;
- }
- if(iSpectatingIndex == iVictim) {
- set_hudmessage(255, 0, 0, 0.45, 0.55, 0, 0.0, 1.5, .channel=TAKEDAMAGE_CHANNEL);
- show_hudmessage(i, "%i", floatround(g_flDamage[iVictim - 1][iAttacker - 1]));
- continue;
- }
- if(iSpectatingIndex == iAttacker) {
- set_hudmessage(0, 127, 255, 0.55, 0.45, 0, 0.0, 1.5, .channel=DEALDAMAGE_CHANNEL);
- show_hudmessage(i, "%i", floatround(g_flDamage[iVictim - 1][iAttacker - 1]));
- continue;
- }
- }
- set_hudmessage(255, 0, 0, 0.45, 0.55, 0, 0.0, 1.5, .channel=TAKEDAMAGE_CHANNEL);
- show_hudmessage(iVictim, "%i", floatround(g_flDamage[iVictim - 1][iAttacker - 1]));
- set_hudmessage(0, 127, 255, 0.55, 0.45, 0, 0.0, 1.5, .channel=DEALDAMAGE_CHANNEL);
- show_hudmessage(iAttacker, "%i", floatround(g_flDamage[iVictim - 1][iAttacker - 1]));
- }
- return HAM_IGNORED;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement