Alright, I have coded a FFA DM round system. I have tried modifying everything that comes in my mind but it is still a bit glitchy. I am asking someone with time to help to check out my code and tell me what in it is wrong and what should be changed. I basically tried to make it so when there are enough people on, the rounds will start, and when only 1 person is alive, he will win, all dead players will spawn, and new round will start. This keeps going on unless the server hasn't got enough people online for new round. Also I was trying to make it so when you die, you get moved to team 1 (spectators), and I have function that should block spectator team from spawning (line 67). So team 1 = spectators and team 2 = players. Here we go:
[lua]
function GM:PlayerSpawn( ply )
ply:SetTeam(2)
ply:StripWeapons()
ply:Give( "weapon_crowbar" )
ply:SetGravity( 1 )
ply:SetHealth( 100 )
ply:SetWalkSpeed( 350 )
ply:SetRunSpeed( 500 )
ply:SetJumpPower( 200 )
ply:SetModel("models/player/group01/male_07.mdl")
end
// ROUND SYSTEM###################################################
local roundactive = false
local start = false
local canstart = false
local function startfalse()
start = false
end
function checkforplayers()
local num = team.NumPlayers( 2 )
if num > 2 then
canstart = true
roundactive = true
print("Enough players. Rounds will keep playing.")
elseif num == 2 then
canstart = false
roundactive = false
start = false
print ("Cannot start new round yet.")
end
end
hook.Add( "PlayerConnect", "playerscheck1", checkforplayers );
hook.Add( "PlayerDisconnected", "playerscheck2", checkforplayers );
function starting()
local num = team.NumPlayers( 2 )
if canstart == true and roundactive == true then
start = true
timer.Simple( 15, startfalse)
for k, v in pairs(player.GetAll()) do
v:ChatPrint("New round starting in 15 seconds, be prepared!")
end
if num == 1 then
roundactive = false
start = false
end
end
end
function playerblockrespawn( ply )
if ply:Team(1) then
return false
end
end
hook.Add( "PlayerDeathThink", "player_step_forcespawn", playerblockrespawn );
function printcanstart()
print(canstart)
end
concommand.Add("canstart",printcanstart)
function printroundactive()
print(roundactive)
end
concommand.Add("roundactive",printroundactive)
function printstart()
print(start)
end
concommand.Add("start",printstart)
// Deaths #####################################################
function playerDies( victim, weapon, killer )
if killer != victim then
if victim:GetMoney() >= 5 then
victim:ChatPrint( "You got killed by " .. killer:GetName() .. " and lost 5$!" )
victim:TakeMoney(5)
killer:ChatPrint( "You killed " .. victim:GetName() .. " and stole 5$ from him!" )
killer:AddMoney(5)
if roundactive == true and start == false then
victim:SetTeam( 1 )
elseif roundactive == true and start == true then
victim:SetTeam(2)
victim:Spawn()
elseif roundactive == false then
victim:SetTeam(2)
victim:Spawn()
elseif canstart == false then
victim:SetTeam(2)
victim:Spawn()
end
else
victim:ChatPrint( "You got killed by " .. killer:GetName() .. "!" )
killer:ChatPrint( "You killed " .. victim:GetName() .. " but he had no money to steal!" )
if roundactive == true and start == false then
victim:SetTeam( 1 )
elseif roundactive == true and start == true then
victim:SetTeam(2)
victim:Spawn()
elseif roundactive == false then
victim:SetTeam(2)
victim:Spawn()
elseif canstart == false then
victim:SetTeam(2)
victim:Spawn()
end
end
else
killer:ChatPrint( "You have suicided!" )
if roundactive == true and start == false then
victim:SetTeam( 1 )
elseif roundactive == true and start == true then
victim:SetTeam(2)
victim:Spawn()
elseif roundactive == false then
victim:SetTeam(2)
victim:Spawn()
elseif canstart == false then
victim:SetTeam(2)
victim:Spawn()
end
end
end
hook.Add( "PlayerDeath", "playerDeathPaska", playerDies );
[/lua]
I would appreciate any kind of help very much
You should go [url=http://glua.me/bin/]here[/url], and look at how TTT does the round system.
Sorry, you need to Log In to post a reply to this thread.