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

What's wrong with the code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alexmy
Senior Member
Join Date: Oct 2014
Location: Russian Federation
Old 08-16-2018 , 09:16   What's wrong with the code?
Reply With Quote #1

Why is there an error?
PHP Code:
L 08/14/2018 20:29:38: [SMException reportedEntity 194 (194is invalid
L 08
/14/2018 20:29:38: [SMBlamingL4DGore.smx
L 08
/14/2018 20:29:38: [SMCall stack trace:
L 08/14/2018 20:29:38: [SM]   [0FindDataMapInfo
L 08
/14/2018 20:29:38: [SM]   [1Line 519E:\left4dead\left4dead\addons\sourcemod\scripting\include\entity.inc::HasEntProp
L 08
/14/2018 20:29:38: [SM]   [2Line 122E:\left4dead\left4dead\addons\sourcemod\scripting\L4DGore.sp::EventDeathInfected
L 08
/14/2018 20:55:13Error log file session closed
the actual code:
PHP Code:
public void EventDeathInfected(Event event, const char [] Namebool Broadcast)
{
    if (
BloodConfig[5] != 1)
        return;
    
    
int Death GetClientOfUserId(event.GetInt("attacker"));
    if (!
Death || !IsValidEntity(Death) || !IsValidEdict(Death) || !IsClientInGame(Death))
        return;
    
    if (
FloatAbs(Headshot[Death] - GetGameTime()) >= 1.0)
        return;
    
    if (
HasEntProp(GlobalEnt[Death], Prop_Data"m_nBody"))
        
SetEntProp(GlobalEnt[Death], Prop_Data"m_nBody"19);
    if (
HasEntProp(GlobalEnt[Death], Prop_Send"m_gibbedLimbs"))
        
SetEntProp(GlobalEnt[Death], Prop_Send"m_gibbedLimbs"16);

Alexmy is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-16-2018 , 09:30   Re: What's wrong with the code?
Reply With Quote #2

https://sm.alliedmods.net/new-api/cl...ClientOfUserId
GetClientOfUserId: Returns 0 if invalid userid.

PHP Code:

public void EventDeathInfected(Event event, const char [] Namebool Broadcast

    if (
BloodConfig[5] != 1
        return; 
     
    
int Death GetClientOfUserId(event.GetInt("attacker")); 
    if (!
Death// if the client is not in game, his userid becomes invalid. or if the attacker is an entity and not a client.
        
return; 
     
    if (
FloatAbs(Headshot[Death] - GetGameTime()) >= 1.0
        return; 
     
    if (
HasEntProp(GlobalEnt[Death], Prop_Data"m_nBody")) 
        
SetEntProp(GlobalEnt[Death], Prop_Data"m_nBody"19); 
    if (
HasEntProp(GlobalEnt[Death], Prop_Send"m_gibbedLimbs")) 
        
SetEntProp(GlobalEnt[Death], Prop_Send"m_gibbedLimbs"16); 

edit:
your problem is with GlobalEnt[Death].
__________________

Last edited by Ilusion9; 08-16-2018 at 09:31.
Ilusion9 is offline
Alexmy
Senior Member
Join Date: Oct 2014
Location: Russian Federation
Old 08-16-2018 , 09:45   Re: What's wrong with the code?
Reply With Quote #3

Thank you, I'll try as you showed.
Alexmy is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-16-2018 , 09:58   Re: What's wrong with the code?
Reply With Quote #4

Quote:
Originally Posted by Alexmy View Post
Thank you, I'll try as you showed.
your problem is with GlobalEnt[Death]
show the code where you assign a value to globalent[death]

or you should change your code with:

PHP Code:
SetEntProp(DeathProp_Data"m_nBody"19);
SetEntProp(DeathProp_Send"m_gibbedLimbs"16); 
__________________
Ilusion9 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 08-16-2018 , 10:17   Re: What's wrong with the code?
Reply With Quote #5

Make sure you check if GlobalEnt[Death] is a valid entity, and actually make sure you're using an entity reference, instead of storing an entity index and checking if the reference is valid each time.
Mitchell 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 16:05.


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