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

Solved CS:GO Invalid entity index 57 for weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 04-07-2019 , 17:09   CS:GO Invalid entity index 57 for weapon
Reply With Quote #1

Hello, I am using either CSWeapon_HEALTHSHOT or 57 for the function SDKHooks_TakeDamage(); and I get this error in console which breaks the plugin: Invalid entity index 57 for weapon.

The whole function is:

PHP Code:
SDKHooks_TakeDamage(clientwhovenin[client], whovenin[client], 450.0DMG_NERVEGASCSWeapon_HEALTHSHOT); 
I hope you can help me

EDIT: What I actually want is to make it show that he got killed by the syringe. I tried to put glock and 0 as well, but doesn't seem to work (no errors for these).

__________________
Steam - https://steamcommunity.com/id/sniperheroofficialu/
Discord - SniperHero#8545

Last edited by cristian20042; 04-11-2019 at 11:09.
cristian20042 is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 04-07-2019 , 19:23   Re: CS:GO Invalid entity index 57 for weapon
Reply With Quote #2

You can try to prehook player_death and change the weapon in it to the healthshot.
CliptonHeist is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 04-08-2019 , 11:36   Re: CS:GO Invalid entity index 57 for weapon
Reply With Quote #3

Thanks, any ideas how that will work? Just a brief explaination or a little code
__________________
Steam - https://steamcommunity.com/id/sniperheroofficialu/
Discord - SniperHero#8545
cristian20042 is offline
Kellan123
AlliedModders Donor
Join Date: Aug 2012
Old 04-08-2019 , 11:45   Re: CS:GO Invalid entity index 57 for weapon
Reply With Quote #4

IsValidEntity ?
Kellan123 is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 04-08-2019 , 17:26   Re: CS:GO Invalid entity index 57 for weapon
Reply With Quote #5

Quote:
Originally Posted by cristian20042 View Post
Thanks, any ideas how that will work? Just a brief explaination or a little code
Something like this:
PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre)
}

public 
Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int victim GetClientOfUserId(event.GetInt("userid"));
    
int attacker GetClientOfUserId(event.GetInt("attacker"));

    if(!
IsValidClient(victim) || !IsValidClient(attacker)) return Plugin_Continue;

    
event.SetString("weapon""weapon_healthshot");
    return 
Plugin_Changed;
}

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

Although what you were doing with the takedamage thing might work too, just need to pass a valid instance of a healthshot entity.
CliptonHeist is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 04-09-2019 , 16:37   Re: CS:GO Invalid entity index 57 for weapon
Reply With Quote #6

It works for me perfectly, tested today.

PHP Code:

#if !defined DMG_GENERIC

#define DMG_GENERIC                    0
#define DMG_CRUSH                      (1 << 0)
#define DMG_BULLET                     (1 << 1)
#define DMG_SLASH                      (1 << 2)
#define DMG_BURN                       (1 << 3)
#define DMG_VEHICLE                    (1 << 4)
#define DMG_FALL                       (1 << 5)
#define DMG_BLAST                      (1 << 6)
#define DMG_CLUB                       (1 << 7)
#define DMG_SHOCK                      (1 << 8)
#define DMG_SONIC                      (1 << 9)
#define DMG_ENERGYBEAM                 (1 << 10)
#define DMG_PREVENT_PHYSICS_FORCE      (1 << 11)
#define DMG_NEVERGIB                   (1 << 12)
#define DMG_ALWAYSGIB                  (1 << 13)
#define DMG_DROWN                      (1 << 14)
#define DMG_PARALYZE                   (1 << 15)
#define DMG_NERVEGAS                   (1 << 16)
#define DMG_POISON                     (1 << 17)
#define DMG_RADIATION                  (1 << 18)
#define DMG_DROWNRECOVER               (1 << 19)
#define DMG_ACID                       (1 << 20)
#define DMG_SLOWBURN                   (1 << 21)
#define DMG_REMOVENORAGDOLL            (1 << 22)
#define DMG_PHYSGUN                    (1 << 23)
#define DMG_PLASMA                     (1 << 24)
#define DMG_AIRBOAT                    (1 << 25)
#define DMG_DISSOLVE                   (1 << 26)
#define DMG_BLAST_SURFACE              (1 << 27)
#define DMG_DIRECT                     (1 << 28)
#define DMG_BUCKSHOT                   (1 << 29)

#endif


<somewhere>
{
    ...
    
DoPointhurtDamage(victimattackerdamage"weapon_healthshot");//or any other weapon
}
void DoPointhurtDamage(int victimint attackerint damage, const char[] weaponint damage_type DMG_GENERIC DMG_PREVENT_PHYSICS_FORCE)
{
    if(
victim && victim <= MaxClients && IsClientConnected(victim) && IsClientInGame(victim) && IsPlayerAlive(victim))
    {
        
int pointHurt CreateEntityByName("point_hurt");
        if(
pointHurt)
        {
            
char dmg_str[5];
            
IntToString(damagedmg_strsizeof(dmg_str));
            
            
char dmgtype_str[5];
            
IntToString(damage_typedmgtype_strsizeof(dmgtype_str));
            
            
DispatchKeyValue(victim,"targetname""hurtme"); //set victim as the target for damage
            
DispatchKeyValue(pointHurt,"Damagetarget""hurtme");
            
DispatchKeyValue(pointHurt,"Damage"dmg_str);
            
DispatchKeyValue(pointHurt,"DamageType"dmgtype_str);
            
DispatchKeyValue(pointHurt,"classname"weapon);
            
DispatchSpawn(pointHurt);
            
AcceptEntityInput(pointHurt,"Hurt",(attacker && attacker <= MaxClients && IsClientConnected(attacker) && IsClientInGame(attacker)) ? attacker : -1);
            
DispatchKeyValue(victim,"targetname","donthurtme"); //unset the victim as target for damage
            
RemoveEdict(pointHurt);
        }
    }

__________________

Last edited by impossible_cc; 04-09-2019 at 16:40.
impossible_cc is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 04-10-2019 , 14:08   Re: CS:GO Invalid entity index 57 for weapon
Reply With Quote #7

Thank you, impossible Works very smooth
__________________
Steam - https://steamcommunity.com/id/sniperheroofficialu/
Discord - SniperHero#8545
cristian20042 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 05:29.


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