Page 1 of 1

ACS Question

Posted: Fri Sep 30, 2005 3:48 pm
by Cyrez
hey all, can i get an example of how Checkweapon works please?
I no this but it's one of them brain fart days and I can't for the life of we figure it out. what im wanting is a

if curweapon is blah
do blah
else if curweapon is blah2
do blah2

sorry for asking such a dumb question but hey :wink:

Posted: Fri Sep 30, 2005 3:55 pm
by ace
I'm not sure, but wouldn't it be something like:

Code: Select all

script 123 (void)
{
   if(CheckWeapon("Shotgun")==1)
   {
       do this
   }
   if(CheckWeapon("PlasmaRifle")==1)
   {
       do that
   }
   if(CheckWeapon("RocketLauncher")==1)
   {
       blow stuff up
   }
}
And so on... again, just a guess but it sounds similar to CheckInventory to me.

Posted: Sat Oct 01, 2005 7:42 pm
by Wasted Youth
This would work:

Code: Select all

Script 1 (void) {
	If(CheckWeapon("Shotgun")) {
		action;
	}
	Else {
		If(CheckWeapon("PlasmaRifle")) {
			action;
		}
		Else {
			If(CheckWeapon("RocketLauncher")) {
				action;
			}
		}
	}
}
One thing to remember about IF and ELSE statements.

If you have a script like this.

Code: Select all

Script 1 (void) {
	If(cat1 == 1) {
		action;
	}
	If(cat2 == 1) {
		action;
	}
	If(cat3 == 1) {
		action;
	}
}
If cat1 = 1, cat2 = 1, and cat3 = 1, it will do all actions for cat1, cat2, and cat3.
If cat1 = 0, cat2 = 1, and cat3 = 1, it will do all actions for cat2 and cat3.
If cat1 = 0, cat2 = 0, and cat3 = 1, it will do all actions for cat3.

If you have a script like this.

Code: Select all

Script 1 (void) {
	If(cat1 == 1) {
		action;
	}
	Else {
		If(cat2 == 1) {
			action;
		}
		Else {
			If(cat3 == 1) {
				action;
			}
		}
	}
}
If cat1 = 1, cat2 = 1, and cat3 = 1, it will only do the action for cat1.
If cat1 = 0, cat2 = 1, and cat3 = 1, it will only do the action for cat2.
If cat1 = 0, cat2 = 0, and cat3 = 1, it will only do the action for cat3.

Why? Because it reads straight down the list. If you are using ELSE statements, if the IF statement is True it will ignore anything in the ELSE statement.

Posted: Sun Oct 02, 2005 10:16 am
by Dr_Ian
Wasted Youth wrote:This would work:
You are using a lot of surplus brackets. This is equivilent:

Code: Select all

Script 1 (void) {
	If(CheckWeapon("Shotgun")) {
		action;
	}
	Else If(CheckWeapon("PlasmaRifle")) {
		action;
	}
	Else If(CheckWeapon("RocketLauncher")) {
		action;
	}
}

Posted: Sun Oct 02, 2005 10:33 am
by Wasted Youth
I know, I just like to do it that way. I like to have good order.

Posted: Sun Oct 02, 2005 11:52 am
by Graf Zahl
Dr_Ian's is better ordered. All paths are on the same level so more indentations only make it harder to read. ;)