Raised This Month: $12 Target: $400
 3% 

[L4D2] Remove survivor dead body


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 02-25-2018 , 13:21   [L4D2] Remove survivor dead body
Reply With Quote #1

I would like to remove a survivor's dead body with a simple condition: It can be done at any time, without a warning, not only after the dead or in dead_survivor_visible event.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 03-05-2018 , 04:58   Re: [L4D2] Remove survivor dead body
Reply With Quote #2

I tried to extract the dead body with an SDKCall which I searched in pseudo code, 0 success since it uses a method I fail to understand to retrieve it.
Code:
CBaseEntity *__cdecl CItemDefibrillator::OnActionComplete(CItemDefibrillator *this, CTerrorPlayer *a2, CBaseEntity *a3)
{
  CBaseEntity *result; // eax@1
  CSurvivorDeathModel *v4; // ebx@2
  CBaseEntity *v5; // edi@3
  CBaseEntity *v6; // ebx@4
  void (__cdecl *v7)(CBaseEntity *, const char *, int); // ST1C_4@5
  int v8; // eax@5
  void (__cdecl *v9)(CBaseEntity *, char *, int); // esi@5
  int v10; // eax@5

  result = a3;
  if ( a3 )
  {
    result = (CBaseEntity *)_dynamic_cast(a3, &`typeinfo for'CBaseEntity, &`typeinfo for'CSurvivorDeathModel, 0);
    v4 = result;
    if ( result )
    {
      result = (CBaseEntity *)CTerrorPlayer::GetPlayerByCharacter(*((_DWORD *)result + 1526));
      v5 = result;
      if ( result )
      {
        CTerrorPlayer::OnRevivedByDefibrillator(result, a2, v4);
        CBasePlayer::RumbleEffect(a2, 33, 0, 4);
        result = (CBaseEntity *)(*(int (__cdecl **)(CCSPlayer *, const char *, _DWORD, _DWORD))(*(_DWORD *)gameeventmanager
                                                                                              + 28))(
                                  gameeventmanager,
                                  "defibrillator_used",
                                  0,
                                  0);
        v6 = result;
        if ( result )
        {
          v7 = *(void (__cdecl **)(CBaseEntity *, const char *, int))(*(_DWORD *)result + 48);
          v8 = (*(int (__cdecl **)(CBaseEntity *, _DWORD))(*(_DWORD *)engine + 64))(engine, *((_DWORD *)a2 + 12));
          v7(v6, "userid", v8);
          v9 = *(void (__cdecl **)(CBaseEntity *, char *, int))(*(_DWORD *)v6 + 48);
          v10 = (*(int (__cdecl **)(CBaseEntity *, _DWORD))(*(_DWORD *)engine + 64))(engine, *((_DWORD *)v5 + 12));
          v9(v6, "subject", v10);
          result = (CBaseEntity *)(*(int (__cdecl **)(_DWORD, _DWORD, _DWORD))(*(_DWORD *)gameeventmanager + 32))(
                                    gameeventmanager,
                                    v6,
                                    0);
        }
      }
    }
  }
  return result;
}
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
spumer
Senior Member
Join Date: Aug 2011
Old 03-05-2018 , 07:19   Re: [L4D2] Remove survivor dead body
Reply With Quote #3

I add function to replace deathmodel for revive fix in post https://forums.alliedmods.net/showpo...&postcount=184

You can try to modify extension and add function for deleting deathmodel entity.
__________________
spumer is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 03-05-2018 , 07:27   Re: [L4D2] Remove survivor dead body
Reply With Quote #4

Quote:
Originally Posted by spumer View Post
I add function to replace deathmodel for revive fix in post https://forums.alliedmods.net/showpo...&postcount=184

You can try to modify extension and add function for deleting deathmodel entity.
I know nothing about scripting extensions, does your posted extension solve my issue?

Maybe you can add a native to retrieve the deathmodel entity in your extension?
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 03-07-2018 , 08:00   Re: [L4D2] Remove survivor dead body
Reply With Quote #5

Quote:
Originally Posted by eyal282 View Post
I know nothing about scripting extensions, does your posted extension solve my issue?

Maybe you can add a native to retrieve the deathmodel entity in your extension?
I still don't really understand what your trying to do, however maybe my forward in LMC could help

PHP Code:
/**
*    This is called when lmc_hide_defib_model > -1 cvar
*
*    @param     iClient        Client Index who died.
*    @param     iEntity        Entity Index of Deathmodel for client who died
*    @param    iOverlayModel     Entity Index of Deathmodel overlaymodel -1 if don't exist
*    @no return
*/
forward void LMC_OnClientDeathModelCreated(int iClientint iDeathModelint iOverlayModel); 
https://github.com/LuxLuma/-L4D2-Lef....inc#L143-L151


Can't you check your conditions for removal of deathmodel in sourcemod?
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 03-08-2018 at 12:37.
Lux is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 03-07-2018 , 08:26   Re: [L4D2] Remove survivor dead body
Reply With Quote #6

PHP Code:
int iDeathModel = -1;
while ((
iDeathModel FindEntityByClassname(iDeathModel"survivor_death_model")) != -1)
{
    
/* Some people forget to check if all the death models present are valid. */
    /* Hence, resulting to untimely random game/server crashes. */
    
if (!IsValidEntity(iDeathModel) || !IsValidEdict(iDeathModel))
    {
        continue;
    }
    
    
// do what you want here. :)

cravenge is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 03-07-2018 , 08:37   Re: [L4D2] Remove survivor dead body
Reply With Quote #7

Quote:
Originally Posted by cravenge View Post
PHP Code:
    /* Some people forget to check if all the death models present are valid. */
    /* Hence, resulting to untimely random game/server crashes. */


This is untrue. Sourcemod's Native FindEntityByClassname already checks if the entity is valid internally.
If the entity is not valid, FindEntityByClassname reports -1. The while loop specificly only checks for valid entities (return value >= 0)

Edit: To clarify. If you check that the return value of FindEntityByClassname is >= 0 on the entity, (which is done in this while loop), you don't
have to add any aditonal IsValidEdict or IsValidEntity checks. To avoid crashes, always check the return value and don't remove the entity with RemoveEdict.

Example on how to use it on a single entity.
Code:
int entity = FindEntityByClassname(-1, "this_entities_name");
if (entity != -1) AcceptEntityInput(entity, "kill");  // this is perfectly fine on a perfectly validated entity.

Last edited by Visual77; 03-07-2018 at 09:20.
Visual77 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 03-07-2018 , 09:22   Re: [L4D2] Remove survivor dead body
Reply With Quote #8

There are times when the entity is valid and invalid at the same time. This is due to said entity being in the process of removal.

Example: Deleting an entity that is about to be removed automatically from the map.
PHP Code:
int entity FindEntityByClassname(-1"survivor_death_model");
if (
entity != -1)
{
    
AcceptEntityInput(entity"Kill"); // In case this happens, the entity here is being removed twice which leads to a crash.
}

/* unless... */

int entity FindEntityByClassname(-1"survivor_death_model");
if (
entity != -1)
{
    if (!
IsValidEntity(entity)) // Here, we delay the process to actually confirm that the entity is still valid.
    
{
        return;
    }
    
    
AcceptEntityInput(entity"Kill"); // Plugin can safely delete the entity with no chances of the game/server crashing.


Last edited by cravenge; 03-07-2018 at 09:22.
cravenge is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 03-07-2018 , 09:31   Re: [L4D2] Remove survivor dead body
Reply With Quote #9

Quote:
Originally Posted by cravenge View Post
Example: Deleting an entity that is about to be removed automatically from the map.
Then this must be one of those rare cases then. Aren't entities only wiped automatically on two conditions: 1. Mapchange. 2 New round?

What happens if we have 2 plugins trying to delete the exact same entity model at the same time? Would it still delete the entity on pluginA and pluginB would maybe just ignore it? Or does the server crash?

Last edited by Visual77; 03-07-2018 at 09:36.
Visual77 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 03-07-2018 , 09:34   Re: [L4D2] Remove survivor dead body
Reply With Quote #10

Quote:
Originally Posted by Visual77 View Post
[...]
Unless there are other plugins installed that forces entity removal, yes, those are the only two.

But if eyal is using a repeating timer, he might need to do that or... stop the timer during OnMapEnd and restart it on OnMapStart.

Quote:
Originally Posted by Visual77 View Post
[...]
Definitely a server crash is to be expected. I experienced it using Coder's Edict Overflow Prevention plugin and my own Ragdolls Remover.

Manually spawned ragdolls before game crashed when it reached 10-20 total.

Last edited by cravenge; 03-07-2018 at 09:43.
cravenge is offline
Reply


Thread Tools
Display Modes

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 11:07.


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