if( issubstr( weapon, "upgraded" ) ) help

Topic created · 6 Posts · 81 Views
  • Im working on something, I can be a bit of a dummy. Let's say I have a mp5k_zm, I upgrade it and it comes back as mp5k_upgraded_zm, how can I use...

    if( issubstr( weapon, "upgraded" ) ) {
        return "upgraded";
    }
    

    to return the original weapon name where the weapon is still upgraded but will still check as mp5k_zm I have tried get_base_name( weapon ) it's just a big headache just trying to cut some of the code in half, I was told you can do it with if( issubstr ) and help will be amazing

  • Please stop posting questions in the release section.
    "How do I do X" is NOT a release that you share.

    You should be able to do it with subStr(weapon, "upgraded")[0]

  • @Meat-Missile The pattern for defined weapons is pretty simple. It's <weaponname> + "_zm"(except for some special weapons, Treyarch is braindead) or if its upgraded <weaponname> + "upgraded" + "_zm.

    I would do a strTok( weapon, "" ) and rebuild the string without the upgraded part. You can concatenate strings with "" to rebuild the string in a for loop.

  • @Resxt Sorry Im bad at reading forums like this

  • base = get_base_weapon_name( weapon, issubstr( weapon, "upgraded" ) );

  • has_weapon( weapon ) {
        if( self has_weapon_or_upgrade( weapon ) ) {
            if( is_weapon_upgraded( weapon ) ) {
                return true;
            }
            else {
                return true;
            }
        }
        return false;
    }```
    This works better and I actually tested this
Log in to reply