if ( var = true )
could set var to true. There is a limited protection for this so whole scripts don't get screwed up.
I would recommend disabling the players weapons for this script, then custom scripting the onKeyPressed() instead of replacing the anis of sword, etc.
I personally would disagree with this:
PHP Code:
if (this.harpo_on == 1 && keychar == "r") {
I don't like that styling much, but it's purely personal preference. Most people think that so long as they are related that's okay. You could also do something like this:
PHP Code:
function onKeyPressed( keycode, keychar )
{
if ( this.harpo_on == false )
{
return false;
}
if ( keychar == "r" )
{
if ( client.harpo_ammo != 0 )
{
return false;
}
// Set gani, change ammo, etc.
}
}
Also, I advise against using client.harpoon_ammo; you could use a this. variable, and then have it base encoded, and unencode it for checks. Something like this:
PHP Code:
function setAmmo( ammo )
{
this.ammo = base64encode( ammo );
}
function getAmmo()
{
return base64decode( this.ammo );
}
This way it's harder to hack--though if it's a good hacker, they could just modify the code, hehe.
Nice script though; better than I used to do for guns.
(I used to modify sprites.png, and then change the arrows so they looked like bullets, then shoot arrows at everyone! Hah!)