T1 Need help with debugging!

Amadeus
12-16-2003, 02:40 PM
I'm making the second version of my weapon changing script (the first one was a bit buggy). The first version's checks were time based, wich made it quite simple, but this is ammo based and thus a bit more complicated. I know exactly how to do it, and I also wrote the syntax, but it says it has a syntax error in line 55 (marked here in the code). I'm posting the whole code (no need for criticizing it, thx) to give you folks a clear vision. Here it goes (this is the best format I could make it, code does not work right):


$Weapon[1] = "11"; //Blaster
$Weapon[2] = "15"; //Plasma Rifle
$Weapon[3] = "13"; //Chaingun
$Weapon[4] = "21"; //Disc Launcher
$Weapon[5] = "17"; //Grenade Launcher
$Weapon[6] = "22"; //Laser Rifle
$Weapon[7] = "24"; //ELF gun
$Weapon[8] = "19"; //Mortar


$index[11] = 1;
$index[15] = 2;
$index[13] = 3;
$index[21] = 4;
$index[17] = 5;
$index[22] = 6;
$index[24] = 7;
$index[19] = 8;


$Ammo[11] = "";
$Ammo[15] = "plasma bolt"; //bullet
$Ammo[13] = "bullet"; //plasma bolt
$Ammo[21] = "disc"; //disc
$Ammo[17] = "grenade ammo"; //grenade ammo
$Ammo[22] = "";
$Ammo[24] = "";
$Ammo[19] = "mortar ammo"; //mortar ammo


$WeaponName[1] = "Blaster";
$WeaponName[2] = "Plasma Rifle";
$WeaponName[3] = "Chaingun";
$WeaponName[4] = "Disc launcher";
$WeaponName[5] = "Grenade launcher";
$WeaponName[6] = "Laser Rifle";
$WeaponName[7] = "elf gun";
$WeaponName[8] = "Mortar";

function changeWeapon()
{
if (getmounteditem(0))
{
%curWeapon = getmounteditem(0);
if (!%curWeapon == 19)
for (%i = $index[%curWeapon]; %i <= 8; %i = %i+1) {
if (!$Ammo[%i])
{
useitem($WeaponName[%i]);
return;
}

else if (getitemcount($Ammo[$Weapon[%i]])
{
useitem($WeaponName[%i]); <--------- Line 55
return;
}
}

for (%i = 1; %i <= $index[%curWeapon]-1; %i = %i+1) {
if (!$Ammo[%i])
{
useitem($WeaponName[%i]);
return;
}

else if (getitemcount($Ammo[$Weapon[%i]])
{
useitem($WeaponName[%i]);
return;
}
}
}
else
{
for (%i = 1; %i <= 8; %i = %i+1) {
if (!$Ammo[%i])
{
useitem($WeaponName[%i]);
return;
}

if (getitemcount($Ammo[$Weapon[%i]])
{
useitem($WeaponName[%i]);
return;
}
}
}


EditActionMap("playMap.sae");

bindcommand(keyboard0, make, "q", to, "changeWeapon();");

Thanks in advance for the help!

crotchkicker450
12-16-2003, 04:11 PM
shouldn't "if (getitemcount($Ammo[$Weapon[%i]])" look like:
"if (getitemcount($Ammo[$Weapon[%i]]))" ?

Amadeus
12-16-2003, 05:09 PM
omfg

You're right, I got confused with all those damn brackets and stuff. :banging:

SuperSlug
12-17-2003, 02:26 AM
You should use code tags.