I picked a bad choice of words before instead of 'use functions properly' I was trying to say 'use functions to your advantage':
PHP Code:
//#CLIENTSIDE
function onKeyPressed() {
if (keydown(0)) {
doKeyDownZeroStuff();
}
else if (keydown(1)) {
doKeyDownOneStuff();
}
}
function doKeyDownZeroStuff() {
// code...
}
function doKeyDownOneStuff() {
// code...
}
Obviously give the functions meaningful names i.e:
PHP Code:
//#CLIENTSIDE
function onKeyPressed() {
if (keydown(5)) {
doAttack();
}
}
function doAttack() {
// attack code here...
}
It increases the maintainability of your code and allows you to separate the different pieces of logic into much more manageable bites.
I.e: In my example above I have the keyboard controls logic in onKeyPressed and my call to doAttack allows me to store all my attacking logic in doAttack.