so, taking an old script, and trying to fix it, and so far all is good. its a hitmenu.
the server isn't picking up on DetectHits: here's the code.
[CODE]
local function DetectHits( victim, wep, killer )
if killer:GetNWString( "targ" ) == victim:Name() then
local ns = killer:GetNWEntity( "req" )
killer:addMoney( killer:GetNWString( "bounty" ) )
print("holy balls!")
for k, v in pairs( player.GetAll() ) do
umsg.Start( "AnnounceHit", v )
umsg.Entity( victim )
umsg.End()
end
killer:SetNWString( "targ", "" )
for k, v in pairs( player.GetAll() ) do
if v:GetNWString( "targ" ) == victim:Name() then
v:SetNWString( "targ", "" )
end
end
umsg.Start( "HitComplete", killer )
umsg.End()
umsg.Start( "CloseAv", killer )
umsg.End()
end
if table.HasValue( HIT.HitmanTeams, team.GetName(victim:Team()) ) and string.len(victim:GetNWString( "targ" )) > 1 then
local gb = victim:GetNWEntity( "req" )
gb:addMoney( tonumber( victim:GetNWString( "bounty" ) ) )
gb:SetNWEntity( "Hitman", nil )
umsg.Start( "CloseAv", victim )
umsg.End()
umsg.Start( "HitmanDied", gb )
umsg.Entity( victim )
umsg.End()
end
end
hook.Add( "PlayerDeath", "playerDeathTest", DetectHits )[/CODE]
No Lua errors, nothiing like that. but as you can see, from the Print("holly balls!") message i added, i checked to see if the system was even picking up on the hits and its not.
so so far, money is deducted, but nobody gets payed and instantly it triggers like the hit is done. the bot is still alive. this is meant for DarkRP 2.5. what am i doing wrong here?
You're using a lot of depreciated features, like umsg and Set/GetNWVar. I also wouldn't recommend using the victim's name to check, since players might have the same name. [b]and[/b] I don't see the point of networking some of those variables.. like really lol
You'd probably have better luck rewriting it entirely, this is just messy.
[code]
-- pseudo serverside
hook.Add("PlayerDeath", "HitmanPlayerDeath", function(victim, weapon, killer)
-- our killer got their target
if victim == killer.target then
-- give that bounty to the killer
killer:AddMoney(victim.bounty)
-- tell everyone this person was moidered
net.Start("AnnounceHit")
net.WriteString(victim:GetName())
net.Broadcast()
-- unassign the target
killer.target = nil
-- remove the bounty
victim.bounty = nil
-- you should close whatever 'av' is inside the receiving end of this net msg.
net.Start("HitComplete")
net.Send(killer)
end
end)[/code]
isn't [code]Add.Money[/code] = [code]add.Money[/code] for 2.5?
[editline]25th May 2014[/editline]
this is going to be a nightmare. -grumbles-
There are hitman hooks
[url]http://wiki.darkrp.com/index.php/Category:Hooks[/url]
[QUOTE=Walrus Viking;44907454]You're using a lot of depreciated features, like umsg and Set/GetNWVar. I also wouldn't recommend using the victim's name to check, since players might have the same name. [b]and[/b] I don't see the point of networking some of those variables.. like really lol
You'd probably have better luck rewriting it entirely, this is just messy.
[code]
-- pseudo serverside
hook.Add("PlayerDeath", "HitmanPlayerDeath", function(victim, weapon, killer)
-- our killer got their target
if victim == killer.target then
-- give that bounty to the killer
killer:AddMoney(victim.bounty)
-- tell everyone this person was moidered
net.Start("AnnounceHit")
net.WriteString(victim:GetName())
net.Broadcast()
-- unassign the target
killer.target = nil
-- remove the bounty
victim.bounty = nil
-- you should close whatever 'av' is inside the receiving end of this net msg.
net.Start("HitComplete")
net.Send(killer)
end
end)[/code][/QUOTE]
don't forget to check if victim == killer
[lua]
hook.Add("PlayerDeath", "HitmanPlayerDeath", function(victim, weapon, killer)
-- our killer got their target
if victim == killer.target && victim ~= killer then
-- give that bounty to the killer
killer:AddMoney(victim.bounty)
-- tell everyone this person was moidered
net.Start("AnnounceHit")
net.WriteString(victim:GetName())
net.Broadcast()
-- unassign the target
killer.target = nil
-- remove the bounty
victim.bounty = nil
-- you should close whatever 'av' is inside the receiving end of this net msg.
net.Start("HitComplete")
net.Send(killer)
end
end)
[/lua]
Sorry, you need to Log In to post a reply to this thread.