Raised This Month: $ Target: $400
 0% 

Index out of bounds in de_dust2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 04-03-2011 , 16:34   Index out of bounds in de_dust2
Reply With Quote #1

Hi, I'm creating a plugin (based in this tutorial How To: Make a perfect NPC) and it works fine except in de_dust2 that gives me this error:
Code:
L 04/03/2011 - 20:49:45: [AMXX] Displaying debug trace (plugin "domination.amxx")
L 04/03/2011 - 20:49:45: [AMXX] Run time error 4: index out of bounds 
L 04/03/2011 - 20:49:45: [AMXX]    [0] domination.sma::dbase_think (line 71)
What the hell?!
It didn't give me any errors in the other maps that I tryed (de_nuke and aim_aztec_s)
__________________
"If God exists, I hope he has a good excuse." - Woody Allen
kotinha is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-03-2011 , 16:35   Re: Index out of bounds in de_dust2
Reply With Quote #2

Show your plugin.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 04-03-2011 , 18:07   Re: Index out of bounds in de_dust2
Reply With Quote #3

Here it is...
Attached Files
File Type: sma Get Plugin or Get Source (domination.sma - 621 views - 5.3 KB)
__________________
"If God exists, I hope he has a good excuse." - Woody Allen
kotinha is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-03-2011 , 19:16   Re: Index out of bounds in de_dust2
Reply With Quote #4

What are the values of "id" in dbase_think(id)? If you don't know then find out.

I don't really know anything abotu NPCs but from an inconsistency I can see that it is more than likely bool:Dominator[33] being declared too small. The other two arrays on that line are bigger.
__________________

Last edited by fysiks; 04-03-2011 at 19:20.
fysiks is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 04-03-2011 , 19:28   Re: Index out of bounds in de_dust2
Reply With Quote #5

The value of "id" is the index of the base that is thinking (or at least I think so).
And the boolominator[33] is for players while the other arrays are for the bases (max bases 99...)
__________________
"If God exists, I hope he has a good excuse." - Woody Allen

Last edited by kotinha; 04-03-2011 at 19:34.
kotinha is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-03-2011 , 20:04   Re: Index out of bounds in de_dust2
Reply With Quote #6

Don't use arrays to hold values for entities.
You should instead use place holders like EV_INT_iuser1 to EV_INT_iuser4
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 04-03-2011 , 20:40   Re: Index out of bounds in de_dust2
Reply With Quote #7

Are there more than 1 of your ents in de_dust2?
If so then you'll need to make a ent count to keep track of the ent's indices/indexes.

As Exolent mentioned above. Best to use place holders to keep track.

If I remember correctly... You can set and check an ent to a specific team with pev_team.

Anyway, just fixed a few minor things.

PHP Code:

new gMaxPlayers

public plugin_init()
{
    
//....
    
gMaxPlayers get_maxplayers();
}

//Note that I'm using iEnt as the index name for the entity and not id. Just makes things easier
public dbase_think(iEnt)
{
    if(!
is_valid_ent(iEnt))
        return;
        
    
//Should use get_maxplayers() instead and have it as a global variable
    
for(new id id <= gMaxPlayers id++)
    {
        
//I'm sure you would want to check for only alive players to 'dominate' your ent
        
if(is_user_alive(id))
        {
            
//entity_range returns a float. (You can use get_entity_distance which is exactly the same except it returns an int instead)
            
if(entity_range(iEntid)  < 200.0)
            {
                
//..... 
__________________
It's a mystery.
Mini_Midget is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-03-2011 , 21:01   Re: Index out of bounds in de_dust2
Reply With Quote #8

Quote:
Originally Posted by kotinha View Post
And the boolominator[33] is for players while the other arrays are for the bases (max bases 99...)
Your code does not use it that way. You use all three arrays indexed with the same "id".
__________________
fysiks 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 14:37.


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