Sorry about my English :)
I made a entity-NPC.
I have this code:
hook.Add( "DoPlayerDeath", "Points", function( ply, attacker )
if ValidEntity( attacker ) and attacker:IsPlayer() then
--me code here
end
end )
I want to know how to change the "DoPlayerDeath" about the Entity.
Tnx for help :)
Do you mean
[CODE]function GM:OnNPCKilled(victim, killer, weapon)
if killer:IsPlayer() && weapon:IsValid() then
--Your code
end
end[/CODE]
I tried your code but it didn't worked.
i think you gave me code for NPC but i need code for entity:
NPC = ents.Create("npc_zombie")
NPC:SetPos(Somepos)
NPC:Spawn()
well mabye if you explained better people would know what the hell you are talking about.
[editline]06:05AM[/editline]
and his code doesnt do anything. so just because it didnt do what you wanted doesnt mean it doesnt work. you just havent coded anything to it.
There is a way to make a code that's make the game write in chat "+1" when you kill entity?
And again sorry about my English :)
[code]
function GM:OnNPCKilled(victim, killer, weapon)
if killer:IsPlayer() && weapon:IsValid() then
killer:PrintMessage( HUD_PRINTTALK, "+1")
end
end
[/code]
[code]
kills = 0
function GM:OnNPCKilled(victim, killer, weapon)
if killer:IsPlayer() && weapon:IsValid() then
kills + 1
killer:PrintMessage( HUD_PRINTTALK, kills)
end
end
[/code]
I tried the both codes you gave me but it didn't worked for me... i tried to put it in Init.lua, Shared.lua and cl_init.lua
i have a code that spawn a entity zombie (NOT NPC):
for i = 1, table.Count(Pos) do
NPC = ents.Create("npc_zombie2")
if util.IsInWorld(Pos[i]) then
NPC:SetPos(Pos[i])
NPC:Spawn()
end
end
I want to get 1 point for killing that NPC's
I think that code you gave me didn't worked for me because you gave me codes for killing NPCS and not a code for destroying Entity.
well first... all you asked was to put +1 in chat. Thats exactly what I gave you. and the zombie IS an npc... DERP.
And if it doesnt work, then its your error. Both of our codes are fine.
But commander you dont store that on the player so it will be for anyone that kills an npc where they share the kills
[QUOTE=Commander11;24340752][code]
kills = 0
function GM:OnNPCKilled(victim, killer, weapon)
if killer:IsPlayer() && weapon:IsValid() then
kills + 1
killer:PrintMessage( HUD_PRINTTALK, kills)
end
end
[/code][/QUOTE]
Where this code is supposed to go
cl_init ?
init ?
or shared ?
I try to do when you kill NPC then something happens
For example sending a message to Chat
But it does not work
I think because my NPC is entity
This is a gamemode function. so you need to add it to a gamemode.
Ok. since youre being ignorant... an NPC is an entity... so you are correct, but an npc is STILL AN NPC! Jesus.
Sorry, you need to Log In to post a reply to this thread.