AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved cs_get_weapon_burst Error (https://forums.alliedmods.net/showthread.php?t=282787)

hellmonja 05-17-2016 01:41

cs_get_weapon_burst Error
 
1 Attachment(s)
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...

Arkshine 05-17-2016 03:28

Re: [HELP] cs_get_weapon_burst Error
 
cs_get_weapon_burst expects you a weapon entity index not player.

hellmonja 05-17-2016 04:09

Re: [HELP] cs_get_weapon_burst Error
 
Quote:

Originally Posted by Arkshine (Post 2419640)
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)



Arkshine 05-17-2016 04:59

Re: [HELP] cs_get_weapon_burst Error
 
As said, the weapon entity index, not the weapon CSW id. http://www.amxmodx.org/api/cstrike/cs_get_weapon_burst

hellmonja 05-17-2016 05:10

Re: [HELP] cs_get_weapon_burst Error
 
Quote:

Originally Posted by Arkshine (Post 2419654)
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...

Arkshine 05-17-2016 05:12

Re: [HELP] cs_get_weapon_burst Error
 
You have actually retrieved already the entity index, should be "Ent".

hellmonja 05-17-2016 05:22

Re: [HELP] cs_get_weapon_burst Error
 
Quote:

Originally Posted by Arkshine (Post 2419657)
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: :bacon!::crab:...

klippy 05-17-2016 06:07

Re: [HELP] cs_get_weapon_burst Error
 
Quote:

Originally Posted by hellmonja (Post 2419656)
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. :)

hellmonja 05-18-2016 00:25

Re: [HELP] cs_get_weapon_burst Error
 
Quote:

Originally Posted by KliPPy (Post 2419666)
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!...:bacon!:


All times are GMT -4. The time now is 18:43.

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