Raised This Month: $ Target: $400
 0% 

Non player is out of range?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
proffs
Senior Member
Join Date: Jul 2013
Old 08-16-2014 , 15:48   Non player is out of range?
Reply With Quote #1

I don't get it why I get this error.

Code:
L 08/16/2014 - 11:06:15: [CSTRIKE] Non-player entity 0 out of range
L 08/16/2014 - 11:06:15: [AMXX] Displaying debug trace (plugin "trainpcw.amxx")
L 08/16/2014 - 11:06:15: [AMXX] Run time error 10: native error (native "cs_get_weapon_ammo")
L 08/16/2014 - 11:06:15: [AMXX]    [0] trainpcw.sma::eDeath (line 9999999)
PHP Code:
public eDeath()  

        new 
iKiller read_data(1); 
        new 
iVictim read_data(2);
        new 
szKillMSG[50];
        new 
weapon_id fm_find_ent_by_owner(-1weapon_weaponiKiller);
      
      
        if( 
IsPlayer(iKiller) && is_user_alive(iKiller) && Tonly[iKiller]) 
        { 
        if( 
iVictim != iKiller
        { 
            switch( 
cs_get_weapon_ammo(weapon_id) )
            {
            case 
0formatex(szKillMSGcharsmax(szKillMSG), "K");
            case 
1formatex(szKillMSGcharsmax(szKillMSG), "P");
            }
            
            
set_hudmessage(02550, -1.00.406.02.50.00.0, -1);
            
show_hudmessage(iKillerszKillMSG);
        
            if( 
is_user_alive(iKiller) )
            {
            if( 
weapon_id 
            {
                if( 
cs_get_weapon_ammo(weapon_id) == )
                {
                
cs_set_weapon_ammo(weapon_id1); 
                }
            }
            }
        } 
        } 
         
        return 
PLUGIN_HANDLED

proffs is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 08-16-2014 , 17:50   Re: Non player is out of range?
Reply With Quote #2

create weapon_id and szKillMSG after the two iKiller checks

why are you using is_user_alive two times?

create a new var to save the value of cs_get_weapon_ammo, before using this native check if weapon_id is valid

Last edited by baneado; 08-16-2014 at 17:54.
baneado is offline
proffs
Senior Member
Join Date: Jul 2013
Old 08-16-2014 , 17:53   Re: Non player is out of range?
Reply With Quote #3

Quote:
Originally Posted by baneado View Post
create weapon_id and szKillMSG after the two iKiller checks
What? Sorry for being now, Can you show me? Never worked with these type of stuff.
proffs is offline
colossus
Member
Join Date: Sep 2013
Old 08-16-2014 , 18:28   Re: Non player is out of range?
Reply With Quote #4

PHP Code:
public eDeath()   
{  
    new 
iKiller read_data(1);  
    new 
iVictim read_data(2); 
    new 
szKillMSG[50]; 
    new 
weapon_id fm_find_ent_by_owner(-1weapon_weaponiKiller);
    
    if(!
is_valid_ent(weaponid))
        return 
PLUGIN_CONTINUE
        
    
new ammo cs_get_weapon_ammo(weapon_id)
       
    if(
IsPlayer(iKiller) && is_user_alive(iKiller) && Tonly[iKiller])  
    {  
        if( 
iVictim != iKiller)  
        {
            if(
ammo
            { 
                
formatex(szKillMSGcharsmax(szKillMSG), "P"); 
                
cs_set_weapon_ammo(weapon_id1); 
            }
            else
                
formatex(szKillMSGcharsmax(szKillMSG), "K"); 
                
            
set_hudmessage(02550, -1.00.406.02.50.00.0, -1); 
            
show_hudmessage(iKillerszKillMSG)
        }
    }
    return 
PLUGIN_CONTINUE

TEST
colossus is offline
proffs
Senior Member
Join Date: Jul 2013
Old 08-17-2014 , 04:54   Re: Non player is out of range?
Reply With Quote #5

Quote:
Originally Posted by colossus View Post
PHP Code:
public eDeath()   
{  
    new 
iKiller read_data(1);  
    new 
iVictim read_data(2); 
    new 
szKillMSG[50]; 
    new 
weapon_id fm_find_ent_by_owner(-1weapon_weaponiKiller);
    
    if(!
is_valid_ent(weaponid))
        return 
PLUGIN_CONTINUE
        
    
new ammo cs_get_weapon_ammo(weapon_id)
       
    if(
IsPlayer(iKiller) && is_user_alive(iKiller) && Tonly[iKiller])  
    {  
        if( 
iVictim != iKiller)  
        {
            if(
ammo
            { 
                
formatex(szKillMSGcharsmax(szKillMSG), "P"); 
                
cs_set_weapon_ammo(weapon_id1); 
            }
            else
                
formatex(szKillMSGcharsmax(szKillMSG), "K"); 
                
            
set_hudmessage(02550, -1.00.406.02.50.00.0, -1); 
            
show_hudmessage(iKillerszKillMSG)
        }
    }
    return 
PLUGIN_CONTINUE

TEST
Now you don't get +1 bullet if u kill someone
proffs is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 08-17-2014 , 08:26   Re: Non player is out of range?
Reply With Quote #6

on the mobile..

PHP Code:
public eDeath()
{
   new 
iKiller read_data(1);
   new 
iVictim read_data(2);

   if (
IsPlayer(Killer) && iVictim != iKiller && Tonly[iKiller])
   {
       new 
weapon_id find_ent_by_owner(-1"weapon_*"iKiller);
       if (!
weapon_id) return;

       new 
szKillMSG[3];
       switch (
cs_get_weapon_ammo(weapon_id))
       {
          case 
0: {
              
//formatex....
              
cs_set_weapon_ammo(weapon_id1);
          }
          case 
1: {
             
//formatex...
          
}
          default: return;
       }

        
//hudmessage
   
}


Last edited by baneado; 08-17-2014 at 08:35.
baneado is offline
proffs
Senior Member
Join Date: Jul 2013
Old 08-17-2014 , 11:01   Re: Non player is out of range?
Reply With Quote #7

Quote:
Originally Posted by baneado View Post
on the mobile..

PHP Code:
public eDeath()
{
   new 
iKiller read_data(1);
   new 
iVictim read_data(2);

   if (
IsPlayer(Killer) && iVictim != iKiller && Tonly[iKiller])
   {
       new 
weapon_id find_ent_by_owner(-1"weapon_*"iKiller);
       if (!
weapon_id) return;

       new 
szKillMSG[3];
       switch (
cs_get_weapon_ammo(weapon_id))
       {
          case 
0: {
              
//formatex....
              
cs_set_weapon_ammo(weapon_id1);
          }
          case 
1: {
             
//formatex...
          
}
          default: return;
       }

        
//hudmessage
   
}

Makes no sense, tells me to return n shitz :S
Ty for helping...
I get few errors still.
proffs is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 08-24-2014 , 16:16   Re: Non player is out of range?
Reply With Quote #8

Quote:
Originally Posted by baneado View Post
on the mobile..

PHP Code:
public eDeath()
{
   new 
iKiller read_data(1);
   new 
iVictim read_data(2);

   if (
IsPlayer(Killer) && iVictim != iKiller && Tonly[iKiller])
   {
       new 
weapon_id find_ent_by_owner(-1"weapon_*"iKiller);
       if (!
weapon_id) return;

       new 
szKillMSG[3];
       switch (
cs_get_weapon_ammo(weapon_id))
       {
          case 
0: {
              
//formatex....
              
cs_set_weapon_ammo(weapon_id1);
          }
          case 
1: {
             
//formatex...
          
}
          default: return;
       }

        
//hudmessage
   
}

as longes i know, weapon entity is in client side and the entity index can not find that way.
Also you don't need entity id, you need weapon id.
.Dare Devil. is offline
proffs
Senior Member
Join Date: Jul 2013
Old 08-25-2014 , 15:49   Re: Non player is out of range?
Reply With Quote #9

Quote:
Originally Posted by .Dare Devil. View Post
as longes i know, weapon entity is in client side and the entity index can not find that way.
Also you don't need entity id, you need weapon id.
what do u mean? :S
proffs is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 08-17-2014 , 12:07   Re: Non player is out of range?
Reply With Quote #10

post errors.

the code should work as you want
baneado 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 12:57.


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