[PROBLEM SOLVED] [fcos] Run time error 4:index out of bounds
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. |
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. |
Ok 2 more things. One big nono.
Don't do things like Code:
instead write it like so Code:
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:
This also does the job Code:
Maybe you should have a look at the Good programming habits thread. http://<br /> <a href="http://forum...6481</a><br /> |
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. |
#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.Read the first post. I do not want newbies to respond, nor do I want irrelivant information. |
Quote:
Good luck finding someone who's willing to waste his/her time to work through your messy code. |
Quote:
Quote:
Also... not sure what you mean by messy code. It's fairly neat if you ask me but to each his own. |
Offtopic: What does cl_timeout do?
|
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. |
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. |
| All times are GMT -4. The time now is 16:40. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.