All of your stupid embarrassing coding mistakes! -
[HLF]Southclaw - 04.08.2012
If you see my posts, you probably know I make a ton of stupid mistakes, then I fix them, right after posting.
Some are annoying, some are quite hilarious! But they all make me feel stupid
I think the most recent one was I was having problems with file loading, I noticed my money was resetting, and a bunch of other things. I got all confused and started debugging my file script thinking something was failing.
I take a look at the login function and find that I never even called "file_Open" so all the "file_Get*" functions were just returning nothing!
The remedy I use is just practice, sometimes I just code things my server might not need, such as a text replacer that replaces "#<letter>" with the NATO phonetic of that letter (#y = yankee, #n = november etc...)
What other advice for remembering things have you guys got? I'm pretty forgetful in many things, especially coding (forgetting ;, function names, parameters, variables, stupid things etc)
Anyway, enough about me being stupid, I bet all of you (even the really good ones!) have made some stupid mistakes!
Re: All of your stupid embarrassing coding mistakes! -
Arca - 04.08.2012
This mistake often happens to me.
pawn Код:
SendClientMessage(playerid, -1, "Welcome back %s!", PName(playerid));
And also this
pawn Код:
static health; GetPlayerHealth(playerid, health);
Always forget the tags.
Re: All of your stupid embarrassing coding mistakes! -
Vince - 04.08.2012
I hooked GivePlayerMoney to automatically increment a variable, which, when I used it to give players money upon login inadvertently doubled their money every time.
Re: All of your stupid embarrassing coding mistakes! -
[KHK]Khalid - 04.08.2012
Quote:
Originally Posted by [HLF]Southclaw
What other advice for remembering things have you guys got? I'm pretty forgetful in many things, especially coding (forgetting ;, function names, parameters, variables, stupid things etc)
|
Commenting whatever you create? If you think you might forget what a function does or if a function needs explanation then comment it. For each function you make, leave a comment to describe the arguments and what it returns/does and once you update your code, update your comments too. Also this:
Quote:
Orignially Written by WikiHow
Use consistent naming conventions for variables. It will help you keep track of each type of variable, and also what that variable's purpose is. This means more typing than simply x = a + b * c, but it will make your code much easier to debug and maintain. One popular convention is Hungarian notation, where the variable name is prefixed with its type. For example, for integer variables you might use intRowCounter; strings might use strUserName. It doesn't matter what your naming convention is, but be sure that it is consistent and that your variable names are descriptive. (See Warnings below).
|
That way you will never have a problem to know what a code is written for.
Quote:
Originally Posted by [HLF]Southclaw
I bet all of you (even the really good ones!) have made some stupid mistakes!
|
Not really, pawn is not the first programming language for some of the people here, some of them have known (I mean studied) other greater programming languages such as c, c++ or c# before pawn which makes it kind of easy to understand the pawn language when you have a good knowledge in those languages. But, yea that's true in the very very beginning of learning a programming language (Atleast for me)
![Smiley](images/smilies/smile.png)
.
Re: All of your stupid embarrassing coding mistakes! -
[HLF]Southclaw - 04.08.2012
I never said only Pawn mistakes
Thanks for the comment tip as well, I started doing this a while back THEN FORGOT! I must remember to do it more
![Tongue](images/smilies/razz.gif)
The problem is once I start doing it, I'll want to do it to ALL my code (All 30~ files of it)
Naming conventions is a good way, I use a Hungarian Notation adaptation for SA:MP and my gamemode (Variables/Functions are prefixed based on what file they are in, each feature has it's local code in a file, and if anything is used across multiple files, it's put in the global master file)
The past few days I've been REALLY confused about my custom damage script, and got annoyed with it last night, however this morning I found the player health variable was being changed on OnPlayerTakeDamage AND OnPlayerGiveDamage so it was being set twice and instant-killing people, I felt very stupid for not checking both callbacks!
Re: All of your stupid embarrassing coding mistakes! -
Vince - 04.08.2012
Fuck Hungarian Notation. I hate that whole heartedly. The compiler does the type checking so this is just dumb and useless. I could see it being used in PHP or so, which is a typeless language, but not in Pawn or C. I just can't read code that's written in HN, it makes my eyes bleed.
Re: All of your stupid embarrassing coding mistakes! -
Bakr - 05.08.2012
Quote:
Originally Posted by Vince
Fuck Hungarian Notation. I hate that whole heartedly. The compiler does the type checking so this is just dumb and useless. I could see it being used in PHP or so, which is a typeless language, but not in Pawn or C. I just can't read code that's written in HN, it makes my eyes bleed.
|
The whole point of Hungarian Notation is not for the compiler but the programmers; specifically the ones who didn't write the code themselves. This will allow them to more easily follow the track of variables for things like their scope and data type without having to refer back to their declaration. If you have trouble reading Hungarian Notation, you will have trouble in the more
mainstream programming and projects.
As for my stupid mistakes, I often now use C functions instead of Pawn functions for things like string manipulation and file handling. It is quite annoying going from one language to the next when you have different functions that basically result in the same thing. It is even more annoying when functions have the same names, but take different parameters, return different values, or do something completely different than the one you previously knew.
Re: All of your stupid embarrassing coding mistakes! -
leonardo1434 - 05.08.2012
pretty easy to forget the name of the variable's/publics/functions, Even in others languages.
Such like in c++, i'm beginner in it, but already know some cool stuff.
Re: All of your stupid embarrassing coding mistakes! -
Misiur - 05.08.2012
Once I took a job for some e-shop feature. I got home drunk, and written it, but thank God I didn't publish it. When I woke up, hangover, I looked at the code - there were 4 nested loops, and on each level there was executed query - approx 16k unnecessary queries (I fixed it, and got final result of 1 query thanks to joins and stuff). Drunk coding might seem awesome, but leads to problems. Don't drink and develop!
Re: All of your stupid embarrassing coding mistakes! -
Joe Staff - 05.08.2012
I was having a variable change by itself without ever actually being changed by a particular code.
Turns out I was using a string with too few cells, which for some reason was changing my other variables.
Re: All of your stupid embarrassing coding mistakes! -
Universal - 05.08.2012
You are not the only one, who has these stupid little mistakes. This is one of my mistakes that I usually make:
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++) {
if(IsPlayerConnected(playerid)) {
// ...
}
}
I always forget that its not playerid I should use inside the loop.
And for the things you want to remember, I make a to-do list above everything in the main .pwn file (ofc. its commented) and I always track this list so I can remember what I have done and what needs to be done.
Re: All of your stupid embarrassing coding mistakes! -
Basssiiie - 05.08.2012
One I usually make:
Код:
stock Something(playerid);
{
// something here
}
There shouldn't be a ; on the after Something(playerid)..
Re: All of your stupid embarrassing coding mistakes! -
Jikesh - 05.08.2012
Happens with me most of the time
Код:
SendClientMessageToAll(playerid, -1, string);
Re: All of your stupid embarrassing coding mistakes! -
playbox12 - 05.08.2012
Using cache functions while having cache disabled for the query.
Re: All of your stupid embarrassing coding mistakes! -
[HLF]Southclaw - 05.08.2012
Okay, I just fixed a DAMN ANNOYING (but incredibly newbie stupid) bug.
I spent about
2 hours this morning trying to work out why file loaded vehicles weren't spawning or their coordinates weren't working in IsPointInDynamicArea.
Forgot 'Float:' on coordinate variables.
Re: All of your stupid embarrassing coding mistakes! -
Joe Staff - 05.08.2012
Quote:
Originally Posted by [HLF]Southclaw
Okay, I just fixed a DAMN ANNOYING (but incredibly newbie stupid) bug.
I spent about 2 hours this morning trying to work out why file loaded vehicles weren't spawning or their coordinates weren't working in IsPointInDynamicArea.
Forgot 'Float:' on coordinate variables.
![Picard](images/smilies/picard2.png)
|
I get these kinds of errors when working with Java (Android OS) and kind of relating to issues I have when working with angles. Not sure if I should use radians or Euler in some maths.
Re: All of your stupid embarrassing coding mistakes! -
Jstylezzz - 06.08.2012
i make those stupid mistakes like
pawn Код:
if(!IsPlayerInAnyVehicle(playerid,COLOR_RED,"You are not in any car"));
which has to be:
pawn Код:
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not in any car");
i know, this is pretty stupid
Re: All of your stupid embarrassing coding mistakes! -
admantis - 06.08.2012
I always confuse variables in loops, like this:
pawn Код:
foreach(Player, i)
{
SendClientMessage(playerid, -1, "Some text");
}
And the player would be spammed with that text.
It really happens in an almost daily basis.
Re: All of your stupid embarrassing coding mistakes! -
NinjaChicken - 13.08.2012
i accidently created a loop, so that every 10 seconds the players cars got duped, so in about 10 minutes the server over loaded because i broke samp limits it was quite diffcult to fix as every player had about 800 cars each spawning on the same spot... caused alot of lag
Re: All of your stupid embarrassing coding mistakes! -
Steven82 - 14.08.2012
Quote:
Originally Posted by NinjaChicken
i accidently created a loop, so that every 10 seconds the players cars got duped, so in about 10 minutes the server over loaded because i broke samp limits it was quite diffcult to fix as every player had about 800 cars each spawning on the same spot... caused alot of lag ![Smiley](images/smilies/smile.png)
|
Lol, I've done the same thing once but it was with an old house system I made about 2 years ago. I felt like such a n00b because the houses would load into the server and the house pickups would just keep creating and they wouldn't stop.