Raised This Month: $ Target: $400
 0% 

Solved cs_get_weapon_burst Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-17-2016 , 01:41   cs_get_weapon_burst Error
Reply With Quote #1

I'm wondering why I'm getting this error in my console:
PHP Code:
L 05/17/2016 13:32:24: [CSTRIKENon-player entity 1 out of range
L 05
/17/2016 13:32:24: [AMXXRun time error 10 (plugin "ap-vp70.amxx") (native "cs_get_weapon_burst") - debug not enabled!
L 05/17/2016 13:32:24: [AMXXTo enable debug modeadd "debug" after the plugin name in plugins.ini (without quote 
Here's a snippet of the part involved. I'm sure this is it because I only used "cs_get_weapon_burst" once in this plug-in:
PHP Code:
        new Float:rof
        
if(Get_BitVar(g_Had_Weapon,id))
        {
            if(!
cs_get_weapon_burst(id)) rof RATEOFIRE
            
else rof BURSTROF
        

I admit it's not actually a problem because it actually works. I'm just concerned about why that error pops up. Not to mention it clutters up my console because it appears everytime I fire so it's hard to find the messages I actually need to see.

I've attached the plugin itself in case you guys need to take a look at the whole thing...
Attached Files
File Type: sma Get Plugin or Get Source (ap-vp70.sma - 561 views - 20.9 KB)

Last edited by hellmonja; 06-25-2017 at 04:22. Reason: Solved...
hellmonja is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-17-2016 , 03:28   Re: [HELP] cs_get_weapon_burst Error
Reply With Quote #2

cs_get_weapon_burst expects you a weapon entity index not player.
__________________
Arkshine is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-17-2016 , 04:09   Re: [HELP] cs_get_weapon_burst Error
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
cs_get_weapon_burst expects you a weapon entity index not player.
You mean like "CSW_VP70"? but that's what was originally in there and it also got an error.
But okay, I'll test it again first. Might just be a slight case of the stupid on my part.
Be updating you in a few...

UPDATE:
======
No go replacing it with "CSW_VP70". I even tried putting "CSWID" but still the same error. I'll put the whole "Event_CurWeapon" code so you can see what I mean.

PHP Code:
public Event_CurWeapon(id)
{
    if(!
is_user_alive(id))
        return
        
    static 
CSWIDCSWID read_data(2)
    
    if((
CSWID == CSW_VP70 && g_Old_Weapon[id] != CSW_VP70) && Get_BitVar(g_Had_Weaponid))
    {
        
set_pev(idpev_viewmodel2V_MODEL)
        
set_pev(idpev_weaponmodel2"")
        
        
set_weapon_anim(idDRAW_ANIM)
        
Draw_NewWeapon(idCSWID)
        
set_user_maxspeed(idget_user_maxspeed(id)-WALKSPEED);
    } else if((
CSWID == CSW_VP70 && g_Old_Weapon[id] == CSW_VP70) && Get_BitVar(g_Had_Weaponid)) {
        static 
EntEnt fm_get_user_weapon_entity(idCSW_VP70)
        if(!
pev_valid(Ent))
        {
            
g_Old_Weapon[id] = get_user_weapon(id)
            return
        }
        
        new 
Float:rof
        
if(Get_BitVar(g_Had_Weapon,id))
        {
            if(
cs_get_weapon_burst(CSWID)) rof BURSTROF
            
else rof RATEOFIRE
        
}
        
set_pdata_float(Ent46get_pdata_float(Ent464) * rof4)
    } else if(
CSWID != CSW_VP70 && g_Old_Weapon[id] == CSW_VP70Draw_NewWeapon(idCSWID)
    
    
g_Old_Weapon[id] = get_user_weapon(id)


Last edited by hellmonja; 05-17-2016 at 04:37.
hellmonja is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-17-2016 , 04:59   Re: [HELP] cs_get_weapon_burst Error
Reply With Quote #4

As said, the weapon entity index, not the weapon CSW id. http://www.amxmodx.org/api/cstrike/cs_get_weapon_burst
__________________
Arkshine is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-17-2016 , 05:10   Re: [HELP] cs_get_weapon_burst Error
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
As said, the weapon entity index, not the weapon CSW id. http://www.amxmodx.org/api/cstrike/cs_get_weapon_burst
Ah! Then I apologize because I get this "weapon_" and "CSW_" confused. I thought "CSW" is the weapon index and "weapon_" is the weapon entity. Turns out I might be wrong all this time.

I've been trying to find some examples of code using the cs_get_weapon_burst func since yesterday but to no avail. If it's not much to ask, can you give an example? I'll give you some bacon. Heck, I'll even throw in a crab for you...
hellmonja is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-17-2016 , 05:12   Re: [HELP] cs_get_weapon_burst Error
Reply With Quote #6

You have actually retrieved already the entity index, should be "Ent".
__________________
Arkshine is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-17-2016 , 05:22   Re: [HELP] cs_get_weapon_burst Error
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
You have actually retrieved already the entity index, should be "Ent".
Ah so it seems! I'm sorry, this is actually not my code but am only editing it.

Thank you for taking the time to help! And as promised: ...
hellmonja is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-17-2016 , 06:07   Re: [HELP] cs_get_weapon_burst Error
Reply With Quote #8

Quote:
Originally Posted by hellmonja View Post
I thought "CSW" is the weapon index and "weapon_" is the weapon entity. Turns out I might be wrong all this time.
CSW_* constants are weapon indexes. What cs_get_weapon_burst() expects is a weapon entity index, just as Arkshine said. Just like players have their entity indexes from 1 to 32, all other entities (including weapons) have them, and that's what you need.

And that "weapon_*" is just a classname by which entities are recognized and linked to C++ classes.

Last edited by klippy; 05-17-2016 at 06:09.
klippy is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-18-2016 , 00:25   Re: [HELP] cs_get_weapon_burst Error
Reply With Quote #9

Quote:
Originally Posted by KliPPy View Post
CSW_* constants are weapon indexes. What cs_get_weapon_burst() expects is a weapon entity index, just as Arkshine said. Just like players have their entity indexes from 1 to 32, all other entities (including weapons) have them, and that's what you need.

And that "weapon_*" is just a classname by which entities are recognized and linked to C++ classes.
I actually copy-pasted this into a text file for safe keeping. Thank you! That was most informative. More bacon to go 'round!...
hellmonja 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 18:43.


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