Raised This Month: $32 Target: $400
 8% 

Remove player body if slayed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
krikus62
Senior Member
Join Date: Jan 2015
Old 05-20-2018 , 08:26   Remove player body if slayed
Reply With Quote #1

As title suggest I need a plugin that would remove players dead body, if the player is slayed by an admin.
__________________
My plugins:
Spoiler
krikus62 is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 05-21-2018 , 07:58   Re: Remove player body if slayed
Reply With Quote #2

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#pragma semicolon 1
#pragma newdecls required

bool gB_Slayed[MAXPLAYERS 1] = {false, ...};

public 
void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
HookEvent("player_death"Event_PlayerDeath);
    
    
AddCommandListener(CL_Kill"kill");
    
AddCommandListener(CL_Kill"explode");
}

public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamageAliveOnTakeDamage);    
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype
{
    if (
IsValidClient(victim) && GetClientHealth(victim) <= RoundToFloor(damage))
        
gB_Slayed[victim] = false;
}

public 
void Event_PlayerSpawn(Event hEvent, const char[] sEventNamebool bDontBroadcast)
{
    
int client GetClientOfUserId(hEvent.GetInt("userid"));
    
    if (
IsValidClient(client))
        
gB_Slayed[client] = true;
}

public 
void Event_PlayerDeath(Event hEvent, const char[] sEventNamebool bDontBroadcast)
{
    
int client GetClientOfUserId(hEvent.GetInt("userid"));
    
    if (
IsValidClient(client) && gB_Slayed[client])
    {
        
int iRagdoll GetEntPropEnt(clientProp_Send"m_hRagdoll");
        if (
IsValidEdict(iRagdoll)) AcceptEntityInput(iRagdoll"Kill");
    }
}

public 
Action CL_Kill(int client, const char[] sCmdint args)
{
    if (
IsValidClient(client) && IsPlayerAlive(client))
        
gB_Slayed[client] = false;
}

bool IsValidClient(int client)
{
    if (!(
client <= MaxClients) || !IsClientInGame(client))
        return 
false;
    return 
true;

Try this.
__________________

Last edited by LenHard; 05-21-2018 at 08:07.
LenHard is offline
krikus62
Senior Member
Join Date: Jan 2015
Old 05-23-2018 , 15:37   Re: Remove player body if slayed
Reply With Quote #3

It doesn't quite work for everyone, it seems that some people don't see the body, and some do, hard to explain since I got no errors.

it might be conflicting with a revive plugin I use, and this might have been a request as an extension to this plugin:
https://forums.alliedmods.net/showth...=306093&page=4
__________________
My plugins:
Spoiler
krikus62 is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 05-24-2018 , 01:23   Re: Remove player body if slayed
Reply With Quote #4

Added a Timer since the revive plugin you use creates a ragdoll while I kill it.
Attached Files
File Type: sp Get Plugin or Get Source (Ragdoll-Remover.sp - 287 views - 2.0 KB)
__________________

Last edited by LenHard; 05-24-2018 at 01:24.
LenHard is offline
krikus62
Senior Member
Join Date: Jan 2015
Old 05-24-2018 , 15:59   Re: Remove player body if slayed
Reply With Quote #5

Tested it out tonight, it seems that it totally disables the revive plugin. If it is too hard to do, perhaps I will ask the plugin author to add feature that if player is slayed he cannot be respawned.
__________________
My plugins:
Spoiler
krikus62 is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 05-24-2018 , 20:56   Re: Remove player body if slayed
Reply With Quote #6

Quote:
Originally Posted by krikus62 View Post
Tested it out tonight, it seems that it totally disables the revive plugin. If it is too hard to do, perhaps I will ask the plugin author to add feature that if player is slayed he cannot be respawned.
Attached Files
File Type: sp Get Plugin or Get Source (revive.sp - 267 views - 12.0 KB)
__________________
LenHard is offline
krikus62
Senior Member
Join Date: Jan 2015
Old 05-25-2018 , 05:57   Re: Remove player body if slayed
Reply With Quote #7

Okay, so it seems that the body disappearing works when they are killed by slay command. But if a player dies regular death its not possible to revive them. It does show the "Starting revive" message in chat, but it does not actually display "Countdown (defuser timer in middle of screen)".
__________________
My plugins:
Spoiler
krikus62 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 05-25-2018 , 06:33   Re: Remove player body if slayed
Reply With Quote #8

Quote:
Originally Posted by krikus62 View Post
Okay, so it seems that the body disappearing works when they are killed by slay command. But if a player dies regular death its not possible to revive them. It does show the "Starting revive" message in chat, but it does not actually display "Countdown (defuser timer in middle of screen)".
https://forums.alliedmods.net/showthread.php?t=307727
__________________
8guawong is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 05-25-2018 , 10:21   Re: Remove player body if slayed
Reply With Quote #9

added LenHard's modifcations to respawn plugin
not tested

PHP Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "R3TROATTACK"
#define PLUGIN_VERSION "1.2"

#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma newdecls required

EngineVersion g_Game;

ConVar g_cReviveMode null;
ConVar g_cReviveDist null;
ConVar g_cReviveDelay null;
ConVar g_cReviveTimerDelay null;
ConVar g_cReviveCostMode null;
ConVar g_cReviveCost null;
ConVar g_cReviveHealth null;
ConVar g_cReviveLimitMode null;
ConVar g_cReviveLimit null;

float g_fLastRevive[MAXPLAYERS 1];
Handle g_hReviving[MAXPLAYERS 1];
int g_iRevivingTarget[MAXPLAYERS 1];
float g_fTimeOfDeath[MAXPLAYERS 1];
int g_iReviveCount[MAXPLAYERS 1];
bool g_bLimitReach[MAXPLAYERS 1];
bool gB_Slayed[MAXPLAYERS 1] = {false, ...};
int g_iAccount = -1;

public 
Plugin myinfo 
{
    
name "Revive"
    
author PLUGIN_AUTHOR
    
description "Revives a player by pressing +use"
    
version PLUGIN_VERSION
    
url "http://steamcommunity.com/profiles/76561198045363076/"
};

public 
void OnPluginStart()
{
    
g_Game GetEngineVersion();
    if (
g_Game != Engine_CSGO && g_Game != Engine_CSS)
    {
        
SetFailState("This plugin is for CSGO/CSS only.");
    }
    
g_cReviveMode CreateConVar("revive_mode""0""-1 = disabled, 0 = revive anyone, 1 = revive team");
    
g_cReviveDist CreateConVar("revive_distance""150.0""How close do you need to be to revive someone");
    
g_cReviveDelay CreateConVar("revive_delay""15.0""Time between revives");
    
g_cReviveTimerDelay CreateConVar("revive_timer_delay""5.0""How long must the player hold +use on the body for?");
    
g_cReviveCostMode CreateConVar("revive_cost_mode""0""0 - free, 1 - health, 2 - money");
    
g_cReviveCost CreateConVar("revive_cost""10""How much does it cost to revive someone");
    
g_cReviveHealth CreateConVar("revive_health""100""What health does the player revive on?");
    
g_cReviveLimitMode CreateConVar("revive_limit_mode""0""0 - Ignore this, 1 - time limit, 2 - revive limit");
    
g_cReviveLimit CreateConVar("revive_limit""30.0""The limit based on \"revive_limit_mode\"");
    
AutoExecConfig(true"revive");
    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("round_end"Event_RoundEnd);
    
    
AddCommandListener(CL_Kill"kill");
    
AddCommandListener(CL_Kill"explode");
}

public 
void OnMapStart()
{
    
g_iAccount FindSendPropInfo("CCSPlayer""m_iAccount");
    if (
g_iAccount == -1)
        
SetFailState("Unable to find 'm_iAccount' in class 'CCSPlayer'");
}

public 
void OnClientPostAdminCheck(int client)
{
    
g_fLastRevive[client] = GetGameTime();
    if (
g_hReviving[client] != null) {
        
CloseHandle(g_hReviving[client]);
        
g_hReviving[client] = null;
    }
    
g_iRevivingTarget[client] = -1;
    
g_fTimeOfDeath[client] = 0.0;
    
g_iReviveCount[client] = 0;
    
g_bLimitReach[client] = false;
    
gB_Slayed[client] = false;
}

public 
void OnClientDisconnect(int client)
{
    if (
g_hReviving[client] != null) {
        
CloseHandle(g_hReviving[client]);
        
g_hReviving[client] = null;
    }
    
g_iRevivingTarget[client] = -1;
    
g_fTimeOfDeath[client] = 0.0;
    
g_fLastRevive[client] = 0.0;
    
g_iReviveCount[client] = 0;
    
g_bLimitReach[client] = false;
    
gB_Slayed[client] = false
}

public 
void Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
g_hReviving[i] != null) {
            
CloseHandle(g_hReviving[i]);
            
g_hReviving[i] = null;
        }
        
g_iRevivingTarget[i] = -1;
        
g_fLastRevive[i] = GetGameTime();
        
g_fTimeOfDeath[i] = 0.0;
        
g_iReviveCount[i] = 0;
        
g_bLimitReach[i] = false;
        
gB_Slayed[i] = false;
    }
}

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    if (
g_cReviveMode.IntValue == -1)
        return;
    
int victim GetClientOfUserId(event.GetInt("userid"));
    if (!
IsValidClient(victim) || gB_Slayed[client])
        return;
    
int deathBody GetEntPropEnt(victimProp_Send"m_hRagdoll");
    if (
deathBody 0)
        
AcceptEntityInput(deathBody"kill"00);
    
    
int ent CreateEntityByName("prop_ragdoll");
    
char sModel[PLATFORM_MAX_PATH];
    
GetClientModel(victimsModelsizeof(sModel));
    
DispatchKeyValue(ent"model"sModel);
    
    
SetEntPropEnt(entProp_Send"m_hOwnerEntity"victim);
    
SetEntProp(entProp_Data"m_nSolidType"6);
    
SetEntProp(entProp_Data"m_CollisionGroup"5);
    
    
ActivateEntity(ent);
    
    if (
DispatchSpawn(ent))
    {
        
float origin[3], angles[3], velocity[3];
        
        
GetClientAbsOrigin(victimorigin);
        
GetClientAbsAngles(victimangles);
        
GetEntPropVector(victimProp_Data"m_vecAbsVelocity"velocity);
        
float speed GetVectorLength(velocity);
        if (
speed >= 500)
        {
            
TeleportEntity(entoriginanglesNULL_VECTOR);
        }
        else
        {
            
TeleportEntity(entoriginanglesvelocity);
        }
        
g_fTimeOfDeath[victim] = GetGameTime();
    }
    
SetEntProp(entProp_Data"m_CollisionGroup"2);
}

public 
Action OnPlayerRunCmd(int clientint &buttons)
{
    if (
g_cReviveMode.IntValue == -1)
        return 
Plugin_Continue;
    if (!
IsValidClient(client))
        return 
Plugin_Continue;
    if (!
IsPlayerAlive(client))
        return 
Plugin_Continue;
    if (!(
buttons IN_USE) && g_hReviving[client] != null)
    {
        
ClearReviveStuff(client" \x06[Revive] \x01You have stopped reviving your target.");
    }
    if (
buttons IN_USE)
    {
        
int aim GetClientAimTarget(clientfalse);
        if (
aim MaxClients)
        {
            if (
aim != g_iRevivingTarget[client]) {
                if (
g_hReviving[client] != null) {
                    
ClearReviveStuff(client" \x06[Revive] \x01You have stopped looking at your target, reviving stopped.");
                }
            }
            
char class[128];
            
GetEntityClassname(aim, class, sizeof(class));
            if (!
StrEqual(class, "prop_ragdoll"false)) {
                if (
g_hReviving[client] != null) {
                    
ClearReviveStuff(client" \x06[Revive] \x01You are no longer looking at a valid target to revive, reviving stopped.");
                }
                return 
Plugin_Continue;
            }
            
            
float eyePos[3];
            
GetClientEyePosition(clienteyePos);
            
float bodyLoc[3];
            
GetEntPropVector(aimProp_Data"m_vecOrigin"bodyLoc);
            
float vec[3];
            
MakeVectorFromPoints(eyePosbodyLocvec);
            if (
GetVectorLength(vec) > g_cReviveDist.FloatValue) {
                
                if (
g_hReviving[client] != null) {
                    
ClearReviveStuff(client" \x06[Revive] \x01You have moved too far away from your target reviving stopped.");
                }
                return 
Plugin_Continue;
            }
            
            
int owner GetEntPropEnt(aimProp_Send"m_hOwnerEntity");
            if (
IsValidClient(owner))
            {
                switch(
g_cReviveLimitMode.IntValue)
                {
                    case 
1:
                    {
                        
float expire g_fTimeOfDeath[owner] + g_cReviveLimit.FloatValue;
                        
float fin GetGameTime() + g_cReviveTimerDelay.FloatValue;
                        if(
fin expire)
                        {
                            if(!
g_bLimitReach[client])
                                
PrintToChat(client" \x06[Revive] \x01You will not be able to revive \x04%N \x01in time."owner);
                            
g_bLimitReach[client] = true;
                            return 
Plugin_Continue;
                        }
                    }
                    case 
2:
                    {
                        if(
g_iReviveCount[owner] >= g_cReviveLimit.IntValue)
                        {
                            if(!
g_bLimitReach[client])
                                
PrintToChat(client" \x06[Revive] \x04%N has hit the maximum amount of times he could be revived this round."owner);
                            
g_bLimitReach[client] = true;
                            return 
Plugin_Continue;
                        }
                    }
                }
                if (((
g_cReviveMode.IntValue == && GetClientTeam(owner) == GetClientTeam(client)) || g_cReviveMode.IntValue == 0) && (GetGameTime() - g_fLastRevive[client] >= g_cReviveDelay.FloatValue) && g_hReviving[client] == null)
                {
                    
g_iRevivingTarget[client] = aim;
                    
g_hReviving[client] = CreateTimer(g_cReviveTimerDelay.FloatValueTimer_ReviveGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
                    
SetEntPropFloat(clientProp_Send"m_flProgressBarStartTime"GetGameTime());
                    
SetEntProp(clientProp_Send"m_iProgressBarDuration"g_cReviveTimerDelay.IntValue);
                    
PrintToChat(client" \x06[Revive] \x01You have started to revive \x04%N\x01."owner);
                }
            }
        }
    }
    return 
Plugin_Continue;
}

public 
void ClearReviveStuff(int client, const char[] formatany ...)
{
    if(
g_hReviving[client] != null){
        
CloseHandle(g_hReviving[client]);
        
g_hReviving[client] = null;
    }
    
g_iRevivingTarget[client] = -1;
    
SetEntPropFloat(clientProp_Send"m_flProgressBarStartTime"GetGameTime()-g_cReviveTimerDelay.FloatValue);
    
SetEntProp(clientProp_Send"m_iProgressBarDuration"0);
    
char sBuffer[128];
    
VFormat(sBuffersizeof(sBuffer), format3);
    
PrintToChat(clientsBuffer);
}

public 
Action Timer_Revive(Handle timerany userid)
{
    
int client GetClientOfUserId(userid);
    if (!
IsValidClient(client))
        return 
Plugin_Handled;
    
g_hReviving[client] = null;
    
SetEntPropFloat(clientProp_Send"m_flProgressBarStartTime"GetGameTime()-g_cReviveTimerDelay.FloatValue);
    
SetEntProp(clientProp_Send"m_iProgressBarDuration"0);
    
    
int ent g_iRevivingTarget[client];
    
g_iRevivingTarget[client] = -1;
    if (!
IsValidEntity(ent))
        return 
Plugin_Handled;
    
    
int aim GetClientAimTarget(clientfalse);
    if (
ent != aim)
        return 
Plugin_Handled;
    
    
float eyePos[3];
    
GetClientEyePosition(clienteyePos);
    
float bodyLoc[3];
    
GetEntPropVector(entProp_Data"m_vecOrigin"bodyLoc);
    
float vec[3];
    
MakeVectorFromPoints(eyePosbodyLocvec);
    if (
GetVectorLength(vec) > g_cReviveDist.FloatValue) {
        
PrintToChat(client" \x06[Revive] \x01You have moved too far away from your target reviving stopped.");
        return 
Plugin_Handled;
    }
    
    
int target GetEntPropEnt(entProp_Send"m_hOwnerEntity");
    if (!
IsValidClient(target))
        return 
Plugin_Handled;
    
    switch (
g_cReviveCostMode.IntValue)
    {
        case 
1:
        {
            
int cost g_cReviveCost.IntValue;
            
int health GetClientHealth(client);
            if (
health cost 0)
            {
                
SetEntityHealth(clienthealth cost);
                
PrintToChat(client" \x06[Revive] \x01You have been charged \x02%d\x01hp to revive \x04%N\x01."costtarget);
            } else {
                
PrintToChat(client" \x06[Revive] \x01You do not have enough health to revive \x04%N\x01."target);
                return 
Plugin_Handled;
            }
        }
        case 
2:
        {
            
int cost g_cReviveCost.IntValue;
            
int money GetEntData(clientg_iAccount);
            if (
money cost >= 0)
            {
                
SetEntData(clientg_iAccountmoney cost);
                
PrintToChat(client" \x06[Revive] \x01You have been charged $\x02%d\x01 to revive \x04%N\x01."costtarget);
            } else {
                
PrintToChat(client" \x06[Revive] \x01You do not have enough health to revive \x04%N\x01."target);
                return 
Plugin_Handled;
            }
        }
        default:
        {
            
PrintToChat(client" \x06[Revive] \x01You have revived \x04%N\x01."target);
        }
    }
    
    
CS_RespawnPlayer(target);
    
TeleportEntity(targetbodyLocNULL_VECTORNULL_VECTOR);
    
SetEntityHealth(targetg_cReviveHealth.IntValue);
    
g_iReviveCount[target]++;
    if (
IsValidEntity(ent))
        
AcceptEntityInput(ent"kill"00);
    
g_fLastRevive[client] = GetGameTime();
    
PrintToChat(target" \x06[Revive] \x04%N \x01has revived you."client);
    return 
Plugin_Handled;
}

stock bool IsValidClient(int clientbool bots false)
{
    if (
client <= || client MaxClients)
        return 
false;
    if (!
IsValidEntity(client))
        return 
false;
    if (!
IsClientInGame(client))
        return 
false;
    if (!
IsClientConnected(client))
        return 
false;
    if (
bots && IsFakeClient(client))
        return 
false;
    return 
true;


public 
Action CL_Kill(int client, const char[] sCmdint args)
{
    if (
IsValidClient(client) && IsPlayerAlive(client))
        
gB_Slayed[client] = true;

__________________
8guawong is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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