1. Post #1

    November 2011
    50 Posts
    Title says the problem. I'm trying to make the code not execute when the NPC has a grenade because it causes the code to return a nil value ending the script :\

    Code:

    Code:
    if NPC:GetActiveWeapon():IsValid() && NPC:GetActiveWeapon() != "weapon_frag" then
    (User was banned for this post ("Wrong section" - Gran PC))
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  2. Post #2
    Nexus435's Avatar
    July 2010
    1,458 Posts
    What is NPC defined as?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  3. Post #3

    November 2011
    50 Posts
    All current NPC's.
    This:
    Code:
    NPCS = ents.FindByClass( "npc_*" )
    	if  #NPCS == 0 then end
    	for i=1,#NPCS do
    		NPC = NPCS[i]
    And I feel like a dumbass now because I failed to read the big sticky and will probably be banned for this post...

    EDIT: If it helps, it worked before I added that part of the script, and it fails when they throw a grenade.

    EDIT2: Hah! I fixed it. It turns out that active grenades are NPC's. https://developer.valvesoftware.com/...c_grenade_frag.
    Reply With Quote Edit / Delete Windows 7 United States Show Events