Raised This Month: $ Target: $400
 0% 

Invalid player id 0


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
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 #1

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 #2

@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 #3

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 #4

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
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