[Support] Problem handling DVARS. !Help

Topic created · 6 Posts · 71 Views
  • I'm trying to get the player's primary weapon, looking in a guide I found something like this:

    Primaryname = self.PrimaryWeapon;
    

    I tried this too but it doesn't seem to work either

    Primaryname = self.primaryWeapon;
    

    But, what it implements and doesn't seem to work, since I send it to print on one line and it doesn't print.

    self iprintln ("Primary weapon on player is" + Primaryname);
    

    Someone to guide me how to handle this please.

  • That isn't a DVAR but just a variable (that you are making). If you wanted to grab the current weapon the player is holding, you can do something like this:

    displayWeapon()
    {
        primaryWeapon = self getCurrentWeapon();
    
        self iPrintln("You are currently holding: " + primaryWeapon);
    }
    
  • @homura said in Problem handling DVARS. !Help:

    getCurrentWeapon();

    I understand, but I also understand that the function gets me the player's current weapon, but not the primary weapon. Because I can have the secondary weapon as my current weapon.

  • That's all you can do then as far as I know. self.primaryWeapon works in IW4, I think, and I'm not sure how else you can get it in T6. I looked at the BO3 script docs and I couldn't find anything.

  • @Kalitos said in Problem handling DVARS. !Help:

    @homura said in Problem handling DVARS. !Help:

    getCurrentWeapon();

    I understand, but I also understand that the function gets me the player's current weapon, but not the primary weapon. Because I can have the secondary weapon as my current weapon.

    @homura said in Problem handling DVARS. !Help:

    That's all you can do then as far as I know. self.primaryWeapon works in IW4, I think, and I'm not sure how else you can get it in T6. I looked at the BO3 script docs and I couldn't find anything.

    You can for example see if the weapon is found in level.primary_weapon_array.
    maps\mp\gametypes\_weapons.gsc has a function for checking it as well:

    isprimaryweapon(weaponname)
    {
    	return isDefined(level.primary_weapon_array[weaponname]);
    }
    

    Alternatively, <player> getloadoutitem(<loadout>, "primary") could be used.

  • @Ox_
    That's perfect, I did not know about that. Thanks so much, Ox_!

    @Kalitos I would suggest trying what Ox_ has posted.

Log in to reply