Team Deathmatch Stuff

Well im pretty much doing a TDM mode for my gamemode (GCampaign) and im stuck on only 1 thing the player kills

What i got so far is player selectable classses and team

what i need to do is

-Once they kill oter team player they got 1 kill and that kill is added to the they team kills
And add a normal round timer the round start everything start to kill and like after 9 minutes the round ends and the map is changed

im pretty much stuck with the first thing the second i have alredy solve it

So i would appreciate any hints or help or whatever that can help me on this

Use Fretta. Pretty much everything you just talked about is an option in the shared.lua file.

Im not going to use fretta becouse my gamemode is a bit more heavier and from my eyes fretta is for more (light or round based gamemodes like Garrywaretwo or TTT)

Maybe this to give whats commented in the code:

[lua]function GM:DoPlayerDeath( victim, attacker, dmginfo )

victim:AddDeaths(1) --Adds 1 Death Score to the person who is died

if (attacker:IsValid() and attacker:IsPlayer()) then

	if ( attacker == victim ) then
		attacker:AddFrags(-1) --If you killed yourself you get -1 Kills added on
	else
		attacker:AddFrags(1) --Otherwise gives the attacker 1 Kill
		team.AddScore(attacker:Team(), 1) --Find the team the attacker is on and adds 1 Point
	end

end

end[/lua]

Thanks a lot

What’s wrong with Fretta?

its not suitable for my gamemode since it uses a custom sql database and a lot of stuff that as far i know wouldent be well on fretta

I am not sure you know what Fretta really is. Because it is exactly what you should be using…

okay thanks for the code so to end the match once they reach the max kill count i would use this after that code?

for k,v in pairs( player.GetAll() ) do // Looping trough a table of all players where v is an individual player.
local Frags = v:Frags() // Getting a player’s frags
if Frags == 50 then
// some code ill put here to end the match

just asking if its right

After adding the frags just do like:

if attacker:Frags() >= 50 then

ohh right thanks bro

Anytime.

okay well im now using

function GiveShit( victim, attacker, dmginfo )

victim:AddDeaths(1) --Adds 1 Death Score to the person who is died

if (attacker:IsValid() and attacker:IsPlayer()) then

    if ( attacker == victim ) then
        attacker:AddFrags(-1) --If you killed yourself you get -1 Kills added on
    else
        attacker:AddFrags(1) --Otherwise gives the attacker 1 Kill
        team.AddScore(attacker:Team(), 1) --Find the team the attacker is on and adds 1 Point
		if attacker:Frags() >= 3 then
		attacker:ChatPrint("[XP] You have kill people and win the match ")
    end

end

end

hook.Add(“OnNPCKilled”, “GiveShit”, GiveShit)

and after killing 50 npcs it dident printed the message i putted in

Use [lua] tags for your code to make it easier for us to read

NPC hooks and Player hooks are different, so try this for an NPC code, hopefully it’ll work:

[lua]function GiveShit( victim, attacker, weapon )

if (attacker:IsValid() and attacker:IsPlayer()) then
	attacker:AddFrags(1) --Gives the attacker 1 Kill
	team.AddScore(attacker:Team(), 1) --Find the team the attacker is on and adds 1 Point
end

if attacker:Frags() >= 50 then
	attacker:ChatPrint( "[XP] You killed enough people and win the match" )
end

end
hook.Add( “OnNPCKilled”, “GiveShit”, GiveShit )[/lua]

yeah! that did it thanks

[editline]25th February 2011[/editline]

by the way if im using attacker isnt that going to get the attacker frags and not the team frags?

nevermind i fixed it using

function GiveShit( victim, attacker, weapon )

if (attacker:IsValid() and attacker:IsPlayer()) then
    attacker:AddFrags(1) --Gives the attacker 1 Kill
    team.AddScore(attacker:Team(), 1) --Find the team the attacker is on and adds 1 Point
	TeamFrags = team.TotalFrags (1)
	if TeamFrags == 3 then
	 attacker:ChatPrint( "[XP] You killed enough people and win the match" )
end