• AddRelationship doesn't work?
    3 replies, posted
Im trying to make it so citizen's will attack you, if you kill one of them: GM = gmod.GetGamemode() E = ents.FindByClass("npc_citizen") function GM:OnNPCKilled( victim, killer, weapon )    if(victim:GetClass() == "npc_citizen" and killer:IsPlayer() and victim:Disposition(killer) != 1 ) then        Msg(victim:Disposition(killer))        for k,v in pairs(killer:GetTable()) do            E:AddRelationship("player D_HT 99")         end     end    end end I get this:
Call ents.FindByClass inside the function instead of caching it outside. Loop over that instead of killer:GetTable(). Also, use hooks instead of overriding gamemode functions unless you're making a gamemode.
I don't use hooks just because I don't understand how to use one
hook.Add("OnNPCKilled", "Some identifier", function() -- Code end)
Sorry, you need to Log In to post a reply to this thread.