Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 11 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 SP Mapping
CoD 4 mapping and level design for single player.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Using 'if' statements to check a AI's weapon
Josh.S
General Member
Since: May 27, 2012
Posts: 86
Last: Sep 16, 2014
[view latest posts]
Level 3
Category: CoD4 SP Mapping
Posted: Wednesday, Jul. 31, 2013 04:16 pm
Is there anyway to use a if statement to check what weapon an AI is using?
I tried using these:
if ( self.weapon == "ak47")
class = weaponClass( self.weapon );
The error I get is
pair undefined and 'ak47' has unmatching types 'undefined' and 'string'.

I understand what it means, but you can set a weapon using self.weapon = "m4_grunt"; but you can't check?

if it is a string how come I can't compare it to... a string?
The GSC for aitype's can change the weapon,
so why does it give me undefined when I "compare" it to another string??
Share |
3st0nian
General Member
Since: Jan 14, 2008
Posts: 291
Last: Dec 4, 2017
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD4 SP Mapping
Posted: Wednesday, Jul. 31, 2013 04:55 pm
Tested it with this script. Worked fine. Make sure self is defined.
Code:

ai = getaiarray("axis");
	for(i=0; i<ai.size; i++)
	{
		if(ai[i].weapon == "ak47")
			iprintlnbold("Weapon found");
	}


When I used if(self.weapon == "ak47"), it throw me same error about undefined and string.
Share |
Josh.S
General Member
Since: May 27, 2012
Posts: 86
Last: Sep 16, 2014
[view latest posts]
Level 3
Category: CoD4 SP Mapping
Posted: Thursday, Aug. 1, 2013 02:20 pm
The error stop showing but it didn't print anything.
Also, it brings up the error if I use it on a spawner array.
GetSpawnerTeamArray( "axis" );
Share |
SparkyMcSparks
General Member
Since: Feb 28, 2004
Posts: 1713
Last: Dec 29, 2016
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoD4 SP Mapping
Posted: Friday, Aug. 2, 2013 08:38 am
Spawners don't have weapons, they aren't AI.
Share |
Josh.S
General Member
Since: May 27, 2012
Posts: 86
Last: Sep 16, 2014
[view latest posts]
Level 3
Category: CoD4 SP Mapping
Posted: Friday, Aug. 2, 2013 01:48 pm
But you can still check a spawner classname before they spawn right?
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 SP Mapping

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»