Raised This Month: $ Target: $400
 0% 

Invalid player id 0


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 12-20-2014 , 10:21   Invalid player id 0
Reply With Quote #1

Error:
Code:
L 12/20/2014 - 17:10:34: Invalid player id 0
L 12/20/2014 - 17:10:34: [AMXX] Displaying debug trace (plugin "test.amxx")
L 12/20/2014 - 17:10:34: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 12/20/2014 - 17:10:34: [AMXX]    [0] skill_system.sma::fw_PlayerTakeDamage (line 382)
and code from plugin:
PHP Code:
public fw_PlayerTakeDamage(thisidinflictoridattackerFloat:damagedamagebits)
{
    if(!
is_user_connected(idattacker) && !is_user_alive(idattacker) && this == idattacker)
        return 
HAM_IGNORED;
    
    if(
get_user_weapon(idattacker) != CSW_KNIFE
    { 
        
damage += 30
    
}
    else
    {
        
damage += 50
    
}
        
    
SetHamParamFloat(4damage);
    
    return 
HAM_IGNORED;

KiLLeR. is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-20-2014 , 10:24   Re: Invalid player id 0
Reply With Quote #2

Check to make sure idattacker is actually a player
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 12-20-2014 , 10:51   Re: Invalid player id 0
Reply With Quote #3

Sorry, but I didn't understood what should I do.
KiLLeR. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-20-2014 , 10:56   Re: Invalid player id 0
Reply With Quote #4

Check if 1 <= idattacker <= maxplayers
__________________

Last edited by HamletEagle; 12-20-2014 at 10:56.
HamletEagle is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 12-20-2014 , 10:57   Re: Invalid player id 0
Reply With Quote #5

Read the first check you wrote, that's where the problem lies.
@HamletEagle: is_user_connected is enough

Last edited by RateX; 12-20-2014 at 11:11.
RateX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-20-2014 , 12:12   Re: Invalid player id 0
Reply With Quote #6

Quote:
Originally Posted by RateX View Post
Read the first check you wrote, that's where the problem lies.
@HamletEagle: is_user_connected is enough
is_user_alive() checks valid player range (1 <-> maxplayers), connected status, and alive status all in one. You would not want to set damage to a connected but dead player.
PHP Code:
static cell AMX_NATIVE_CALL is_user_alive(AMX *amxcell *params/* 1 param */
{
    
int index params[1];
    
    if (
index || index gpGlobals->maxClients)
    {
        return 
0;
    }
    
    
CPlayerpPlayer GET_PLAYER_POINTER_I(index);

    if (
g_bmod_tfc)
    {
        
edict_t *pPlayer->pEdict;
        if (
e->v.flags FL_SPECTATOR || 
            (!
e->v.team || !e->v.playerclass))
        {
            return 
0;
        }
    }
    
    return ((
pPlayer->ingame && pPlayer->IsAlive()) ? 0);

I'm not sure what conditions you are checking, I just took a guess here.
PHP Code:
//If attacker is dead or attacker hurt himself, return.
if( !is_user_aliveidattacker ) || ( this == idattacker ) )
        return 
HAM_IGNORED
__________________

Last edited by Bugsy; 12-20-2014 at 12:15.
Bugsy is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 12-20-2014 , 12:43   Re: Invalid player id 0
Reply With Quote #7

@Bugsy: I was just talking about Hamlet's method of checking. Since the author's already check !is_user_connected, a connected player won't be out of 1 to maxplayers range.

Quote:
Originally Posted by Bugsy View Post
I'm not sure what conditions you are checking, I just took a guess here.
PHP Code:
//If attacker is dead or attacker hurt himself, return.
if( !is_user_aliveidattacker ) || ( this == idattacker ) )
        return 
HAM_IGNORED
Yep, that's what I was referring to.
Anyway, welcome back!
RateX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-20-2014 , 12:55   Re: Invalid player id 0
Reply With Quote #8

Quote:
Originally Posted by RateX View Post
@Bugsy: I was just talking about Hamlet's method of checking. Since the author's already check !is_user_connected, a connected player won't be out of 1 to maxplayers range.



Yep, that's what I was referring to.
Anyway, welcome back!
Thanks!

His ultimate issue is using AND's instead of OR's in his statement, is_user_connected is also a redundancy.

His if-statement could return true if a player tossed a grenade to hurt himself then immediately disconnected.
PHP Code:
if(!is_user_connected(idattacker) && !is_user_alive(idattacker) && this == idattacker)
IF ( ( 
ATTACKER NOT CONNECTED ) AND ( ATTACKER NOT ALIVE ) AND ( VICTIM=ATTACKER ) ) 
__________________
Bugsy is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 12-20-2014 , 12:50   Re: Invalid player id 0
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
I'm not sure what conditions you are checking, I just took a guess here.
PHP Code:
//If attacker is dead or attacker hurt himself, return.
if( !is_user_aliveidattacker ) || ( this == idattacker ) )
        return 
HAM_IGNORED
I think there should be:
PHP Code:
//If attacker is dead or attacker hurt himself, return.
if( !is_user_aliveidattacker ) && ( this == idattacker ) )
        return 
HAM_IGNORED
I just want to increase or decrease taken damage from knife, weapon or fall.

This is the whole code:
PHP Code:
public fw_PlayerTakeDamage(thisidinflictoridattackerFloat:damagedamagebits)
{
    if(!
is_user_alive(idattacker) || this == idattacker)
        return 
HAM_IGNORED;
    
    if(
get_user_weapon(idattacker) != CSW_KNIFE
    { 
        
damage += // here we increase damage by shooting
    
}
    else
    {
        
damage += // here we increase damage by knife
    
}
    
    
damage -= // here we reduce damage from shooting
        
    
SetHamParamFloat(4damage);
    
    if(
damagebits DMG_FALL)
    {
        
damage -= // here we reduce damage from falling
        
        
SetHamParamFloat(4damage);
    }

Could I detected using the damagebits parameter when damage is caused by a knife and when a weapon?

Last edited by KiLLeR.; 12-20-2014 at 13:02.
KiLLeR. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-20-2014 , 13:05   Re: Invalid player id 0
Reply With Quote #10

@RateX, I just explained what Yami told him, not taking into account his code.
__________________

Last edited by HamletEagle; 12-20-2014 at 13:06.
HamletEagle 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 15:18.


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