Raised This Month: $ Target: $400
 0% 

[PROBLEM SOLVED] [fcos] Run time error 4:index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-11-2006 , 11:28   [PROBLEM SOLVED] [fcos] Run time error 4:index out of bounds
Reply With Quote #1

This topic is directly related to my plugin [fcos].

[fcos] Plugin URL = http://forums.alliedmods.net/showthread.php?t=25927

I was having a problem using multidimensional arrays in the plugin. To see the finished working plugin go to the above URL. Thanks to mytzlplk for giving me the pointers I needed to figure out the problem.
SubStream is offline
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-11-2006 , 18:40  
Reply With Quote #2

I unfortunately don't have that much time to go through your entire code but what actually like immediately caught my eyes is your use of global variables within function loops.
That's a big nono. Always try and make as many variables as possible local!
Im not saying that this fixes your error, as I mentioned above, but I'm saying that it's a good idea to make your gi_playernum and gi_playercnt local.
Wolle is offline
Send a message via AIM to Wolle
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-11-2006 , 19:19  
Reply With Quote #3

Ok 2 more things. One big nono.
Don't do things like
Code:
if ( ! ( gf_valuefromplayer == gf_calfloatvalue ) )

instead write it like so
Code:
if( gf_valuefromplayer != gf_calfloatvalue )

It does the same thing but it's way easier to understand and not prone to be misunderstood (wich just happened to me)

Also there's no need for these extra brackets
Code:
if ( ! ( is_user_admin ( gi_playerID2 ) ) )

This also does the job
Code:
if( !is_user_admin( gi_playerID2 ))

Maybe you should have a look at the Good programming habits thread.

http://<br /> <a href="http://forum...6481</a><br />
Wolle is offline
Send a message via AIM to Wolle
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-11-2006 , 21:02  
Reply With Quote #4

You really need to fix the way you loop through the arrays!
I rewrote it so it compiles right but I don't have the time for testing right now.
You have a look at your loops and you will get it.
Wolle is offline
Send a message via AIM to Wolle
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-12-2006 , 08:06  
Reply With Quote #5

#1. None of the tips you posted were even on the "Good programming habits page"
#2. I've already read it and clearly applied the advice to my code
#3. Using global variables is not a bad thing and since it is used in quite a many number of places it takes up less code to make it global and it also helps to keep the coding consistent.
#4. It is easier to read code when the same variable name can be used as much as possible when it represents the same thing.
#5. If I had different variables for every single function I would go insane trying to keep track of them all and writing new for each function or reintroducing them as variables in each function would completely waste coding and add a huge amount to an already big plugin.
#6. Using if ( ! statement ) instead of if ( statement ) is all mere preference and nothing more. If a person has trouble reading statements with ! before them then I would imagine they can't understand half of the code written in amxmodx since that is used in nearly every plugin that I know of. It's not hard to read... if ( ! statement ) means if not statement... so if ( ! is_user_connected ( id ) ) means if the user is not connected. That doesn't seem very difficult at all to me whatsoever.
#7. Telling me I really need to fix a problem I already know needs fixing does not offer any help and if anything waste space on this forum and my time reading it. I am pretty sure the topic name "Run time error 4 index out of bounds" explains in and of itself that I know what the problem is. Obviously index out of bounds relates to the array index going out of bounds and not being looped right... obviously that is the problem.
#8. You rewrote it so it compiles right??? It already compiles with no errors. I am not sure what compiler you are using but you obviously do not know what you are doing. Here is the compile from the .sma listed above:
Code:
Welcome to the AMX Mod X 1.70-300 Compiler.
Copyright (c) 1997-2005 ITB CompuPhase, AMX Mod X Team

Header size:           2876 bytes
Code size:            55848 bytes
Data size:            13412 bytes
Stack/heap size:      16384 bytes; estimated max. usage=179 cells (716 bytes)
Total requirements:   88520 bytes
Done.
Clearly there are no errors or warnings whatsoever in that message.

Read the first post. I do not want newbies to respond, nor do I want irrelivant information.
SubStream is offline
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-12-2006 , 11:57  
Reply With Quote #6

Quote:
Originally Posted by SubStream
... Read the first post. I do not want newbies to respond, nor do I want irrelivant information.
Insulting someone who tries to help you certainly isn't the right way to get help here.
Good luck finding someone who's willing to waste his/her time to work through your messy code.
Wolle is offline
Send a message via AIM to Wolle
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-13-2006 , 14:46  
Reply With Quote #7

Quote:
Originally Posted by Wolle
Quote:
Originally Posted by SubStream
... Read the first post. I do not want newbies to respond, nor do I want irrelivant information.
Insulting someone who tries to help you certainly isn't the right way to get help here.
Good luck finding someone who's willing to waste his/her time to work through your messy code.
Insulting??? Re-read what I said in the first post.
Quote:
Originally Posted by SubStream
I do not need newbies on the same skill level as me who are not sure about something to reply.
Clearly I label myself as a newbie by saying "on the same skill level as me." If I insulted you then I also therefore insulted myself. Newbie simply means someone who is newer to coding and/or programming. If I wasn't a newbie I wouldn't have problems with what some people on here may consider trivial, easy to solve problems. If you weren't then you would have not posted irrelivant information. I am not trying to insult anyone, just stating facts. The word "newbie" does not mean that you are anything negative coming from me... at least not meant to be taken that way. Why would I say a newbie is on the same skill level as me if I was trying to insult anyone??? And furthermore... why would I insult anyone on a forum? That's next to childish. If I insulted you I appologize.

Also... not sure what you mean by messy code. It's fairly neat if you ask me but to each his own.
SubStream is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-13-2006 , 14:49  
Reply With Quote #8

Offtopic: What does cl_timeout do?
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-13-2006 , 14:55  
Reply With Quote #9

cl_timeout Variable Max is 3500
Inactivity time before a client is disconnected. Does not affect alt-tabbed timing out any longer.

So if you set cl_timeout to 0 you most likely will disconnect the second you stop doing something in game. If it is at 0 you also will be unable to connect to any server as this is also the variable for how long you have to connect to servers. CAL default is 35 which is sufficient time.
SubStream is offline
mytzlplk
New Member
Join Date: Apr 2006
Location: Orlando, FL
Old 04-20-2006 , 13:11  
Reply With Quote #10

I'm willing to help solve the problem. I want to use this plugin and if there is a problem, I'll help fix it. I've been a software engineer for 25 years so I should be able to help.
One thing, though.
Up until now, for the past couple of years, when I go to one of my servers to do a match/scrim/war, the first thing I type is AMX_OFF.
Then, I use RCON to exec cal.cfg or calcss.cfg and then lo3.cfg...
Most people DO NOT WANT amx ON during a scrim/match - especially CAL match.
So, in order to get the benefit of this plugin, I would not use AMX_OFF and instead, I would have to stop the other 29 plugins or whatever # there is .. manually? and leave AMX ON? so I can get the benefit of this plugin right?
Do you think we should make this a Metamod module in C++ so it would work even when AMX_OFF is used?
This is like the CSP thing that I run on my SRCDS servers for CAL cs:s matches right?
Anyway, as far as fixing the runtime 4 error, let me know if it is still a problem that needs addressing.
I'm going to download this plugin and run it on 5 of my HLDS servers to see if those error messages get logged and if I see them, I'll start looking at the problem and we'll get it licked, dude.
__________________
"We don't stop playing because we grow old...
... we grow old because we stop playing".

- George Bernard Shaw -
mytzlplk 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 16:40.


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