15.12.2010, 21:12
(
Последний раз редактировалось Kwarde; 16.12.2010 в 14:04.
Причина: Forgot one, critical word: PROBABLY
)
Hey! I've noticed that some people have difficulty with fixing errors and warnings.
Mostly, it are "Loose indentation" warnings. And sometimes errors. Well, I'll try to explain in this tutorial how to fix them!
And I'll also give some tips, for the scripters. Let's start.
Warning Loose Indentation.
This code means, more or less, that your code is MESSY. Sorry to say it like that, but it's the hard truth.
And the funny thing is, it is easy to remove the warnings! All lines within a bracket 'group' need to be on the same line.
Here's an example:
BAD EXAMPLE:
GOOD EXAMPLE:
You can see it. The 'a = 1' to 'c = 3' is now on one line. That's much more clearer! And warnings will be gone now.
And in the "BetterFunction" I've added tabs after the opening brackets. This will also probaly remove the loose indentation warnings.
There are multilple reason's why good scripters are using this.
1) It's much more clearer
2) It's easier to find and fix an error/warning
3) It's much easier to find something you wanna find
I know that this costs more diskspace. But I want that more, then having an messy code!
Fixing errors
There are alot of errors. I won't say how to fix them all. I'll just give an tip. This is an example error line:
You see, after the 'GM.pwn' this: (202). This is the line where the error is. It is handy to go to it with CTRL+G.
With that, you can simply go to a line of the script. So if you typ '202' in it and then press ENTER, you'll go to the line with the error!
I'll give an example again.
I'll get an error on line 5! It will say that 'playerid' is unknown. There is no where an 'playerid' defined, so it's impossible to use it in that function!
Well. I got the error. Now I press CTRL+G. I typ in that, '5' and I press ENTER. I'll go to this line: true = playerid;.
The error also said that 'playerid' was unknown. I have to change that! Let's change it to 'true'. Now, compile it again.
NO ERRORS ANYMORE IN THAT FUNCTION! - Fixed.
What did you learn?
* How to make your script clean
* How to remove loose indentation warnings
* How to fix/find errors
Please confirm that you have learned that! If you didn't learn it yet, read this tutorial once again! And whatever, here is a rule:
* An warning is different then an error! If you have an warning, your script will PROBABLY still work. Don't be scared if you have a warning. It's not funny, but it's not critical too!
I HOPE that this tutorial was a bit usefull.
And I hope that you've learned something with this. Good luck with scripting
- Kevin
Mostly, it are "Loose indentation" warnings. And sometimes errors. Well, I'll try to explain in this tutorial how to fix them!
And I'll also give some tips, for the scripters. Let's start.
Warning Loose Indentation.
This code means, more or less, that your code is MESSY. Sorry to say it like that, but it's the hard truth.
And the funny thing is, it is easy to remove the warnings! All lines within a bracket 'group' need to be on the same line.
Here's an example:
BAD EXAMPLE:
pawn Код:
stock BadFunction()
{
if(true)
{
a = 1;
true = false;
b = 2;
c = 3;
}
}
pawn Код:
stock BetterFunction()
{
if(true)
{
a = 1;
true = false;
b = 2;
c = 3;
}
}
And in the "BetterFunction" I've added tabs after the opening brackets. This will also probaly remove the loose indentation warnings.
There are multilple reason's why good scripters are using this.
1) It's much more clearer
2) It's easier to find and fix an error/warning
3) It's much easier to find something you wanna find
I know that this costs more diskspace. But I want that more, then having an messy code!
Fixing errors
There are alot of errors. I won't say how to fix them all. I'll just give an tip. This is an example error line:
Код:
C:\SampServer\GM.pwn(202) : error 055: start of function body without function header
With that, you can simply go to a line of the script. So if you typ '202' in it and then press ENTER, you'll go to the line with the error!
I'll give an example again.
pawn Код:
stock ThisFunction(true = false) //line 1
{ //line 2
if(true) //line 3
{ //line 4
true = playerid; //line 5
} //line 6
} //line 7
Well. I got the error. Now I press CTRL+G. I typ in that, '5' and I press ENTER. I'll go to this line: true = playerid;.
The error also said that 'playerid' was unknown. I have to change that! Let's change it to 'true'. Now, compile it again.
NO ERRORS ANYMORE IN THAT FUNCTION! - Fixed.
What did you learn?
* How to make your script clean
* How to remove loose indentation warnings
* How to fix/find errors
Please confirm that you have learned that! If you didn't learn it yet, read this tutorial once again! And whatever, here is a rule:
* An warning is different then an error! If you have an warning, your script will PROBABLY still work. Don't be scared if you have a warning. It's not funny, but it's not critical too!
I HOPE that this tutorial was a bit usefull.
And I hope that you've learned something with this. Good luck with scripting
- Kevin