how Give points for killing someone?

I would like someone to help me complete this code for me.


function KillingPoints()
-- some code to find if the player you killed was on team ROLE_TRAITOR
if ply:Team() == ROLE_INNOCENT and VIP then
	print("[:Pass] You killed a traitor, +10 points!")
	ply:SetPData("Points", Points + 10 )
else
	print("[:Pass] You killed a traitor, +5 points!")
	ply:SetPData("Points", Points + 5 )
	end
end

What i want is for it to give you +10 points for killing a Traitor in TTT


function KillingPoints()
-- some code to find if the player you killed was on team ROLE_TRAITOR
if ply:Team() == ROLE_INNOCENT and VIP then
	print("[:Pass] You killed a traitor, +10 points!")
	ply:PS_GivePoints(5)
else
	print("[:Pass] You killed a traitor, +5 points!")
	ply:PS_GivePoints(5)
	end
end

hook.add("DoPlayerDeath", playerdeaths, KillingPoints)


Untested, but it should work.


if ply:Team() == ROLE_INNOCENT and VIP then

Just ‘VIP’ can’t be right, surely?

VIP is a defined variable in the rest of the code

snipp

Use the “PlayerDeath” hook, as it returns the player and attacker:
[lua]hook.Add( “PlayerDeath”, “GivePoints”, function( victim, inflictor, attacker )

if ( attacker:Team() == TEAM_INNOCENT or attacker:IsActiveDetective() ) and victim:IsTraitor() then --make sure that the attacker was innocent/detective and victim is a traitor
attacker:SetPData(“Points”, Points + 5*(bonus[attacker:GetNWString(“usergroup”)] or 1) ) – give them the points adding on any multiplier necessary
end

end )

local bonus = { [“superadmin”] = 2.5, [“VIP”] = 2 } – multiplier table, to make it easier to calculate the points to give, modify as necessary[/lua]
Make sure that you use the method to get the usergroup of the player (in the SetPData) that fits your admin system. This works with ULX method only, as far as I know.

this thread is fucking painful, nobody has provided a solution that isn’t wrangled with syntax errors, gee.

[lua]local RolePoints = {
[2] = {[2] = -30,–Killed Detective as Detective
[0] = -10,–Killed Innocent as Detective
[1] = 200–Killed Traitor as Detective
},
[0] = {[2] = -50,–Killed Detective as Innocent
[0] = -20,–Killed Innocent as Innocent
[1] = 50–Killed Traitor as Innocent
},
[1] = {[2] = 200,–Killed Detective as Traitor
[0] = 25,–Killed Innocent as Traitor
[1] = -30–Killed Traitor as Traitor
}
}

function NotifyPlayer(ply, killer)
local num = RolePoints[killer:GetRole()][ply:GetRole()]
local bool = string.find(num, “-”)
if bool then
killer:PrintMessage(HUD_PRINTTALK, “[TTT] Shop: You had “…num…” points taken away for killing “…ply:Nick()…”, they were a(n) “…ply:GetRoleString()…”.”)
else
killer:PrintMessage(HUD_PRINTTALK, “[TTT] Shop: You were awarded “…num…” points for killing “…ply:Nick()…”, they were a(n) “…ply:GetRoleString()…”.”)
end
killer:PS_GivePoints(num)
– or in op’s case
killer:SetPData(“Points”, killer:GetPData(“Points”, 0) + num)
end

function PointShopDeathHook(ply, killer, dmginfo)
if !IsValid(killer) or !killer:IsPlayer() or !IsValid(ply) or !ply:IsPlayer() then return end
if GetRoundState() == ROUND_ACTIVE then
NotifyPlayer(ply, killer)
end
end
hook.Add(“DoPlayerDeath”, “PointShopDeathHook”, PointShopDeathHook)[/lua]

Isn’t it wonderful what the smallest of Google searches and a little common sense can do.

That code reduces points if someone kills themself. I’ll fix it tonight.

Thanks for giving me credits and here’s a fixed up version:
[lua]
//lua/autorun/server

hook.Add(“Initialize”, “Points.Initialize”, function()
if !ROLE_INNOCENT then return end

local RolePoints = {
	[ROLE_DETECTIVE] = {
		[ROLE_DETECTIVE] = -30,
		[ROLE_INNOCENT] = -10,
		[ROLE_TRAITOR] = 200
	},
	[ROLE_INNOCENT] = {
		[ROLE_DETECTIVE] = -50,
		[ROLE_INNOCENT] = -20,
		[ROLE_TRAITOR] = 50
	},
	[ROLE_TRAITOR] = {
		[ROLE_DETECTIVE] = 200,
		[ROLE_INNOCENT] = 25,
		[ROLE_TRAITOR] = -30
	}
}

local function NotifyPlayer(ply, killer)
	local num = RolePoints[killer:GetRole()][ply:GetRole()]
	local bool = string.find(num, "-")
	if bool then
		killer:PrintMessage(HUD_PRINTTALK, "[TTT] Shop: You had "..num.." points taken away for killing "..ply:Nick()..", they were a(n) "..ply:GetRoleString()..".")
	else
		killer:PrintMessage(HUD_PRINTTALK, "[TTT] Shop: You were awarded "..num.." points for killing "..ply:Nick()..", they were a(n) "..ply:GetRoleString()..".")
	end
	
	killer:SetPData("Points", killer:GetPData("Points", 0) + num)
end

hook.Add("DoPlayerDeath", "PS.GivePointsOnDeath", function(ply, killer, dmginfo)
	if !IsValid(killer) or !killer:IsPlayer() or !IsValid(ply) or !ply:IsPlayer() or (ply == killer) then return end
	if GetRoundState() == ROUND_ACTIVE then
		NotifyPlayer(ply, killer)
	end
end)

end)
[/lua]

Tell me how to do multiplication points for group admins?
For Deathrun


hook.Add( "PlayerDeath", "GivePoints", function( victim, inflictor, attacker )
 local points = 15
 attacker:PS_GivePoints(points)
 attacker:PS_Notify("Вы получили " ..points.. " монет за убийство.")
end)