Home   Help Search Login Register  

Author Topic: iskindof weapon  (Read 2770 times)

0 Members and 1 Guest are viewing this topic.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
iskindof weapon
« on: 19 Sep 2007, 00:02:26 »
is dere a way 2 check if a string iskindof weapon  ? like we wud use "T72" iskindof "tank" ???

so lets say i wanna check if "M16A2" iskindof "Weapon" ??? does it work dat way ? if it does what is da parent calss name of all weapons ?

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: iskindof weapon
« Reply #1 on: 19 Sep 2007, 01:36:53 »
I have a feeling that isKindOf is only for vehicle type objects, I don't think it works with weapons, at least my small experiments turned up no results with weapons.


Planck
I know a little about a lot, and a lot about a little.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: iskindof weapon
« Reply #2 on: 19 Sep 2007, 02:00:25 »
You need to use inheritsFrom. The thing is that this just tells you the parent class, so isn't quite as easy to use as isKindOf, but that just means you need to keep finding out the parent until there isn't another parent or you find a class you recognise.

e.g. to find out if a given weapon is a rifle (simplified from working code, so not 100% sure it will work, but you should get the idea ;P):
Code: [Select]
_unknownConfig = configFile >> "CfgWeapons" >> _unknownWeaponClass;
_rifleConfig = configFile >> "CfgWeapons" >> "RifleCore";

_isRifle = false;
while {isClass _unknownConfig} do
{
    if (_unknownConfig == _rifleConfig) exitWith
    {
        _isRifle = true;
    };

    _unknownConfig = inheritsFrom _unknownConfig;
};

***EDIT***

Might have misunderstood you there; if you just want to know if "M16A2" is a weapon or a magazine or whatnot, then just:
Code: [Select]
_item = "M16A2";
_isWeapon = isClass (configFile >> "CfgWeapons" >> _item); // => true
_isMagazine = isClass (configFile >> "CfgMagazines" >> _item); // => false
« Last Edit: 28 Sep 2007, 22:34:47 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: iskindof weapon
« Reply #3 on: 19 Sep 2007, 05:59:43 »
thx... exactly what i needed :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: iskindof weapon
« Reply #4 on: 19 Sep 2007, 12:19:17 »
Remember that some class names exist in CfgWeapons, CfgMagazines and/or CfgAmmo at the same time (They are different classes, serving different purposes, but since they are in different "namespaces" BIS were safe to give them the same name). May not be an issue for you, but it caused me minor headaches when I first used this code to build by shopping interface. E.g. "PipeBomb" exists as a magazine type and an ammo type.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: iskindof weapon
« Reply #5 on: 19 Sep 2007, 14:04:57 »
"PipeBomb" also exists as a weapon class too.    :P


Planck
I know a little about a lot, and a lot about a little.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: iskindof weapon
« Reply #6 on: 19 Sep 2007, 15:08:24 »
doesnt matter i found workaround :P finished building my own weapon trading script :D  :cool2:

prob solved :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Cheetah

  • Former Staff
  • ****
Re: iskindof weapon
« Reply #7 on: 19 Sep 2007, 17:53:29 »
You going to upload it to the beta board? Might be a script usable for others around. Don't know what's possible with you weapon trading script however..
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: iskindof weapon
« Reply #8 on: 19 Sep 2007, 18:09:16 »
i think after my next mision is gona b reviewed ill post some scripts (dat is after it passes beta testing nd stuff... :P)... i just hate writing documentation 4 my scripts  :no: wich keeps a lot of good scripts in my comp or w/ ppl who ask 4 em :P

as 4 my trade script... right now it just gives da player option 2 order magazines/weapons/vehicles  :cool2: nd... special stuff (im not realy gonna deliver em :P) like beers or cigis or watever u want (u can add nything u want)... it sends da stuff into array da maker can use :D next phase is 2 arrange choper droping everything down  :yes: on ny position player wants (onmapsingleclick)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta