Hey Guys,
so basiclly what i try to do is implementing Nextbot NPC's to the XP System i have on my Server.
My Idea was the Nextbot's Death to call OnNPCKilled, as this is what the XP System uses.
[code]function GetKilled( dmginfo )
hook.Call( "OnNPCKilled", GAMEMODE, self, dmginfo:GetAttacker(), dmginfo:GetInflictor() )
end
hook.Add( "OnKilled", "Pls", Killed )
hook.Add("OnNPCKilled", "SN_LVLSYSTEM_NPCK", function(npc, ply, at)
if(DARKRP_LVL_SYSTEM["SETTINGS"]["NPC_KILL_XP"] and tonumber(DARKRP_LVL_SYSTEM["SETTINGS"]["NPC_KILL_XP"]) and tonumber(math.floor(DARKRP_LVL_SYSTEM["SETTINGS"]["NPC_KILL_XP"])) > 0) then
if(npc and npc:IsValid() and npc:IsNPC() and ply and ply:IsValid() and ply:IsPlayer()) then
local am = tonumber(math.floor(DARKRP_LVL_SYSTEM["SETTINGS"]["NPC_KILL_XP"])) or 0
if(am == 0) then return end
ply:AddXP(am)
//ply:ChatPrint("You've received " .. am .. " XP for killing an NPC")
end
end
end)[/code]
That's the current code. I have no Idea what im doing wrong.
Have you done any debugging? If so what did work?
Any errors?
What XP system do you use?
But if it's a nextbot then isn't it triggered by its death anyway?
[QUOTE]ENT:OnKilled( dmginfo )[/QUOTE]
Edit:
Or this.
[QUOTE]
hook.Add( "OnNPCKilled", "NPCKilled", function( npc, attacker, inflictor )
code
end )[/QUOTE]
[QUOTE=KevinnTCG;50409938]Have you done any debugging? If so what did work?
Any errors?
What XP system do you use?[/QUOTE]
I am using one from SF
[url]https://scriptfodder.com/scripts/view/55[/url]
No Error's. It just didn't count Nextbot's death as "NPC Death".
[QUOTE=Bubbie;50410453]But if it's a nextbot then isn't it triggered by its death anyway?
Edit:
Or this.[/QUOTE]
Apparently not.
To:
[code]hook.Add( "OnNPCKilled", "NPCKilled", function( npc, attacker, inflictor )
code
end )
[/code]
I am using this already, huh?
[code]hook.Add("OnNPCKilled", "SN_LVLSYSTEM_NPCK", function(npc, ply, at)
code
end)[/code]
[QUOTE=Artiik;50413602]I am using one from SF
[url]https://scriptfodder.com/scripts/view/55[/url]
No Error's. It just didn't count Nextbot's death as "NPC Death".
Apparently not.
To:
[code]hook.Add( "OnNPCKilled", "NPCKilled", function( npc, attacker, inflictor )
code
end )
[/code]
I am using this already, huh?
[code]hook.Add("OnNPCKilled", "SN_LVLSYSTEM_NPCK", function(npc, ply, at)
code
end)[/code][/QUOTE]
Sorry but I'm having a hard time understanding what your problem is and what you need help with.
Could you explain in a bit more detail?
[QUOTE=Bubbie;50413679]Sorry but I'm having a hard time understanding what your problem is and what you need help with.
Could you explain in a bit more detail?[/QUOTE]
What exactly im trying to do is, i want to try that if a Nextbot Dies (by player?) that it should call OnNPCKilled so the XP System gets triggered and the Player gets XP
There is no hook directly. You need to modify the ENT:OnKilled of the Nextbot directly.
[url]https://wiki.garrysmod.com/page/NEXTBOT/OnKilled[/url]
[QUOTE=Tomelyr;50414413]There is no hook directly. You need to modify the ENT:OnKilled of the Nextbot directly.
[url]https://wiki.garrysmod.com/page/NEXTBOT/OnKilled[/url][/QUOTE]
Yup, we sorted that out. Thank you, and thanks to @Bubbie :)
Sorry, you need to Log In to post a reply to this thread.