Well, I hope this is the right place to ask for help. I've been attempting to make a script that replenishes your points when you suicide since apparently its a big issue according to the people on play. ----> This isn't my code, Im just using it as a initial start, I just modified it..
Any help would be appreciated
Please post constructive critiscm, ty
I don't know how to put it in to any smaller forms so:
The Table for it:
[QUOTE] local SuicidePoints = {
[2] = {[2] = 50,--Killed Detective as Detective
[0] = 0,--Killed Innocent as Detective
[1] = 0--Killed Traitor as Detective
},
[0] = {[2] = -0,--Killed Detective as Innocent
[0] = 10,--Killed Innocent as Innocent
[1] = 0--Killed Traitor as Innocent
},
[1] = {[2] = 0,--Killed Detective as Traitor
[0] = 0,--Killed Innocent as Traitor
[1] = 50--Killed Traitor as Traitor
}
}
[/QUOTE]
The Code that i've been attempting to modify:
[QUOTE]function NotifySuicider(victim, inflictor, attacker)
local num = SuicidePoints[killer:GetRole()][ply:GetRole()]
local boos = string.find(num, "-")
if boos(victim == attacker) then
killer:PrintMessage(HUD_PRINTTALK, "You regained"..num.." points back killing yourself as "..ply:GetRoleString().."!")
else
killer:PrintMessage(HUD_PRINTTALK, "You regained "..num.." points for killing yourself as "..ply:GetRoleString().."!")
end
killer:PS_GivePoints(num)
end
[/QUOTE]
The entire code:
[QUOTE]--To be placed in lua/autorun/server/
-- ROLE_INNOCENT = 0
-- ROLE_TRAITOR = 1
-- ROLE_DETECTIVE = 2
-- ROLE_NONE = ROLE_INNOCENT
local RolePoints = {
[2] = {[2] = -50,--Killed Detective as Detective
[0] = -10,--Killed Innocent as Detective
[1] = 50--Killed Traitor as Detective
},
[0] = {[2] = -50,--Killed Detective as Innocent
[0] = -10,--Killed Innocent as Innocent
[1] = 50--Killed Traitor as Innocent
},
[1] = {[2] = 10,--Killed Detective as Traitor
[0] = 10,--Killed Innocent as Traitor
[1] = -50--Killed Traitor as Traitor
}
}
local SuicidePoints = {
[2] = {[2] = 50,--Killed Detective as Detective
[0] = 0,--Killed Innocent as Detective
[1] = 0--Killed Traitor as Detective
},
[0] = {[2] = -0,--Killed Detective as Innocent
[0] = 10,--Killed Innocent as Innocent
[1] = 0--Killed Traitor as Innocent
},
[1] = {[2] = 0,--Killed Detective as Traitor
[0] = 0,--Killed Innocent as Traitor
[1] = 50--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, "You just lost"..num.." points for killing a "..ply:GetRoleString().."!")
else
killer:PrintMessage(HUD_PRINTTALK, "You were awarded "..num.." points for killing a "..ply:GetRoleString().."!")
end
killer:PS_GivePoints(num)
end
function PointShopDeathHook(ply, killer, dmginfo)
if !IsValid(killer) and !killer:IsPlayer() and !IsValid(ply) and !ply:IsPlayer() then return end
if GetRoundState() == ROUND_ACTIVE then
NotifyPlayer(ply, killer)
end
end
function NotifySuicider(victim, inflictor, attacker)
local num = SuicidePoints[killer:GetRole()][ply:GetRole()]
local boos = string.find(num, "-")
if boos(victim == attacker) then
killer:PrintMessage(HUD_PRINTTALK, "You regained"..num.." points back killing yourself as "..ply:GetRoleString().."!")
else
killer:PrintMessage(HUD_PRINTTALK, "You regained "..num.." points for killing yourself as "..ply:GetRoleString().."!")
end
killer:PS_GivePoints(num)
end
hook.Add("DoPlayerDeath", "PointShopDeathHook", PointShopDeathHook)[/QUOTE]
Sorry If I've done anything to annoy any OCD people, Don't use forums often.
Thanks.
Also please don't hate, im fairly new to this.
[editline]2nd May 2014[/editline]
I've started testing to see if it works in any a seperate file, but that leads to the disapearance of bodies, and no actual "deaths" apparently happening
Work in progress:
--To be placed in lua/autorun/server/
-- ROLE_INNOCENT = 0
-- ROLE_TRAITOR = 1
-- ROLE_DETECTIVE = 2
-- ROLE_NONE = ROLE_INNOCENT
local SuicidePoints = {
[2] = {[2] = 50,--Killed Detective as Detective
[0] = 0,--Killed Innocent as Detective
[1] = 0--Killed Traitor as Detective
},
[0] = {[2] = -0,--Killed Detective as Innocent
[0] = 10,--Killed Innocent as Innocent
[1] = 0--Killed Traitor as Innocent
},
[1] = {[2] = 0,--Killed Detective as Traitor
[0] = 0,--Killed Innocent as Traitor
[1] = 50--Killed Traitor as Traitor
}
}
function NotifySuicider(killer)
local num = SuicidePoints[killer:GetRole()][killer:GetRole()]
local bool = string.find(num, "-")
if bool then
killer:PrintMessage(HUD_PRINTTALK, "You regained"..num.." points back killing yourself as "..ply:GetRoleString().."!")
else
killer:PrintMessage(HUD_PRINTTALK, "You regained "..num.." points for killing yourself as "..ply:GetRoleString().."!")
end
killer:PS_GivePoints(num)
end
function PointShopDeathHook(killer, dmginfo)
if !IsValid(killer) and !killer:IsPlayer() and !IsValid(killer) and !ply:IsPlayer() then return end
if GetRoundState() == ROUND_ACTIVE then
NotifyPlayer(ply, killer)
end
end
hook.Add("DoPlayerDeath", "PointShopDeathHook", PointShopDeathHook)
Sorry, you need to Log In to post a reply to this thread.