• Round system randomely kills players on spawn, varies on map.
    3 replies, posted
I've looked through the code and nothing pops out to me. I cannot find this issue and its been plaguing my game mode since the beginning of development. How the spawn system works in mine for context: Player is spawned and blinded for a short time. During the blind, their team, model, weapon and stats are applied through a function. They are unblinded very shortly after when the round is started. Now this by itself sounds like it should work. However, for whatever reason players will randomly die on spawn. Its worst on the first few rounds of a map, but some maps are worse than others in terms of dying on spawn. Ive had two different maps and one will almost every time kill them on spawn, where as the other map never kills them on spawn. As usual, I end up pasting large walls of code in a desperate attempt for other people to find out what could I be doing wrong. Here is a video demonstrating what issues I do have. I change maps at the end to show that different maps give different results. https://files.facepunch.com/forum/upload/107320/4fa6aef5-e35c-44e1-aff0-6cde62d69649/2018-09-11 08-08-21.mp4 Alright, here's everything related to spawning i hope: local heromodels = {     "models/custom/izuku_midoriya.mdl",     "models/player/maizeplayermodels/mha/bakugou.mdl",     "models/custom/ochaco_uraraka.mdl",     "models/custom/tsuyu_asui_froppy_player.mdl",     "models/player/neckbeard.mdl",     "models/player/lulsec.mdl",     "models/shaggypm/shaggypm.mdl",     "models/gaben/gabe_3.mdl",     "models/player/korka007/nick.mdl", } function SetTeams()     timer.Create("respawn",0.5,1,function()         for k, v in pairs(player.GetAll()) do             v:SetNWInt("scream", math.random(0,1))         end     end)     timer.Create("respawn2",0.75,1,function()     for k, v in pairs(player.GetAll()) do         v:StripWeapons()         v:SetTeam(math.random(0,1))         if(v:Team() == 1) then             v:SetPlayerColor(Vector(0.0,0.0,1.0))         elseif(v:Team() == 0) then             v:SetPlayerColor(Vector(1.0,0.0,0.0))         end         if(table.Count( team.GetPlayers( 1 )) < table.Count( team.GetPlayers( 0 ))) then             v:SetTeam(1)             v:SetPlayerColor(Vector(1.0,1.0,0.0))         elseif(table.Count( team.GetPlayers( 0 )) < table.Count( team.GetPlayers( 1 ))) then             v:SetTeam(0)             v:SetPlayerColor(Vector(1.0,0.0,0.0))         end         if(v:IsBot() == true && v:Team() < 2) then             v:SetModel(table.Random(heromodels))         else             if(v:PS_HasItemEquipped("izuku")) then                 v:SetModel("models/custom/izuku_midoriya.mdl")             elseif(v:PS_HasItemEquipped("ochaco")) then                 v:SetModel("models/custom/ochaco_uraraka.mdl")             elseif(v:PS_HasItemEquipped("bakugo")) then                 v:SetModel("models/player/maizeplayermodels/mha/bakugou.mdl")             elseif(v:PS_HasItemEquipped("tsuyu")) then                 v:SetModel("models/custom/tsuyu_asui_froppy_player.mdl")             elseif(v:PS_HasItemEquipped("neckbeard")) then                 v:SetModel("models/player/neckbeard.mdl")             elseif(v:PS_HasItemEquipped("hacker")) then                 v:SetModel("models/player/lulsec.mdl")             elseif(v:PS_HasItemEquipped("shaggy")) then                 v:SetModel("models/shaggypm/shaggypm.mdl")             elseif(v:PS_HasItemEquipped("gaben")) then                 v:SetModel("models/gaben/gabe_3.mdl")             elseif(v:PS_HasItemEquipped("vinny")) then                 v:SetModel("models/player/korka007/nick.mdl")             else                 v:SetModel("models/custom/izuku_midoriya.mdl")             end         end         v:SetupHands()         v:SetJumpPower( 400 )         timer.Simple(0.5,function()             v:Spawn()             v:Freeze(false)             if(v:GetModel() == "models/custom/izuku_midoriya.mdl") then                 v:Give( "weapon_deku" )                 v:SetHealth( 300*2 )                 v:SetMaxHealth( 300*2 )                 //v:SetModelScale(0.907, 0.1)             elseif(v:GetModel() == "models/player/maizeplayermodels/mha/bakugou.mdl") then                 v:Give( "weapon_bakugo" )                 v:SetHealth( 325*2 )                 v:SetMaxHealth( 325*2 )                 v:SetModelScale(0.94, 0.1)                 v:SetNWFloat("movespeedmultcharacter",0.92)             elseif(v:GetModel() == "models/custom/ochaco_uraraka.mdl") then                 v:Give( "weapon_uraraka" )                 v:SetHealth( 350*2 )                 v:SetMaxHealth( 350*2 )                 //v:SetModelScale(0.886, 0.1)                 //v:SetModelScale(0.9, 0.1)                 v:SetNWFloat("movespeedmultcharacter",0.92)             elseif(v:GetModel() == "models/custom/tsuyu_asui_froppy_player.mdl") then                 v:Give( "weapon_asui" )                 v:SetHealth( 425*2 )                 v:SetMaxHealth( 425*2 )                 //v:SetModelScale(0.852, 0.1)                 //v:SetModelScale(0.9, 0.1)             elseif(v:GetModel() == "models/player/neckbeard.mdl") then                 v:Give( "weapon_katana" )                 v:SetHealth( 425*2 )                 v:SetMaxHealth( 425*2 )                 //v:SetModelScale(1.0, 0.1)             elseif(v:GetModel() == "models/shaggypm/shaggypm.mdl") then                 v:Give( "weapon_shaggy" )                 v:SetHealth( 300*2 )                 v:SetMaxHealth( 300*2 )                 //v:SetModelScale(1.0, 0.1)                 v:SetNWFloat("movespeedmultcharacter",1.44)             elseif(v:GetModel() == "models/player/lulsec.mdl") then                 v:Give( "weapon_hacker" )                 v:SetHealth( 300*2 )                 v:SetMaxHealth( 300*2 )                 //v:SetModelScale(1.0, 0.1)                 v:SetNWFloat("movespeedmultcharacter",0.92)             elseif(v:GetModel() == "models/gaben/gabe_3.mdl") then                 v:Give( "weapon_gaben" )                 v:SetHealth( 450*2 )                 v:SetMaxHealth( 450*2 )                 //v:SetModelScale(0.934, 0.1)                 v:SetNWFloat("movespeedmultcharacter",0.92)             elseif(v:GetModel() == "models/player/korka007/nick.mdl") then                 v:Give( "weapon_vinny" )                 v:SetHealth( 300*2 )                 v:SetMaxHealth( 300*2 )             end             timer.Simple(0.25,function()                 if(game.GetMap() == "gm_devrivertown") then                     if(v:Team() == 0) then                         v:SetPos(Vector(206.711273, -1799.586792, 88.031250))                     elseif(v:Team() == 1) then                         v:SetPos(Vector(5374.816895, 1384.849731, 144.031250))                     end                 elseif(game.GetMap() == "gm_tilted_towers_v7") then                     if(v:Team() == 0) then                         v:SetPos(Vector(1176.813477, -1195.366577, -197.968750))                     elseif(v:Team() == 1) then                         v:SetPos(Vector(-3443.123047, 3611.141846, -197.968750))                     end                 elseif(game.GetMap() == "gm_akb2") then                     if(v:Team() == 0) then                         v:SetPos(Vector(-6379.232910, 191.130157, -1709.018799))                     elseif(v:Team() == 1) then                         v:SetPos(Vector(6358.480957, -2856.616455, -1716.968750))                     end                 end             end)         end)     end     end) end function beginround()     timer.Create("spawneveryone",1.25,1,function()         SetTeams()     end)     net.Start("randomtip")     net.Broadcast()     timer.Simple(0.5,function()     SW.SetWeather( "" )     end)     SW.SetWeather( "" )     quirklesshealed = 0     winningteam = 4     itemchance = 0     weatherround = 0     weatherroundtype = 0     specialround = 0     specialroundtype = 0     coinmultiplier = 1.0     expmultiplier = 1.0     roundactive = false     net.Start( "round_active" )     net.WriteBool( false )     net.Broadcast()     timer.Create("startround",5,0,function()         if(#player.GetAll() < 2) then             roundactive = false             PrintMessage( HUD_PRINTCENTER, "Need 2 players to start a round!" )         else             if(timer.Exists("respawn") or timer.Exists("respawn2") or timer.Exists("spawneveryone")) then                 roundactive = false                 PrintMessage( HUD_PRINTCENTER, "Still setting up teams!" )             else                 roundactive = true                 roundendcheck()                 timer.Remove("startround")             end         end     end) end init.lua function GM:PlayerInitialSpawn( ply ) ply:statsload()     GAMEMODE:PlayerSpawnAsSpectator( ply )     PrintMessage( HUD_PRINTTALK, ply:GetName() .. " is now connected." )   end function GM:PlayerSpawn( ply ) if(timer.Exists("firstround") or ply:Team() == 2) then     GAMEMODE:PlayerSpawnAsSpectator( ply ) else     if( roundactive == true ) then         GAMEMODE:PlayerSpawnAsSpectator( ply )     elseif(!timer.Exists("respawn2")) then         ply:SetNWInt("injured_leg", 0)         ply:SetNWInt("injured_arm", 0)         ply:SetNWInt("left_arm_disable", 0)         ply:SetNWInt("right_arm_disable", 0)         ply:SetNWInt("right_leg_disable", 0)         ply:SetNWInt("left_leg_disable", 0)         ply:SetNWInt("injured_head", 0)         ply:SetNWInt("bleeding", 0)         ply:SetNWInt("blocking",0)         ply:SetNWFloat("healthregenmult",1)         ply:SetNWFloat("staminaregenmult",1)         ply:SetNWFloat("movespeedmult",1)         ply:SetNWFloat("movespeedmultcharacter",1.2)         ply:SetNWInt("followerstate",0)         ply:SetNWInt("hitamount",0)         ply:SetNWInt("damagedealt",0)         ply:SetNWFloat("stamina", 100.0)         ply:SetNWInt("ultra", 0)         ply:SetNWFloat("lockonmult", 1)         ply:SetNWString("actioncam", "none")         ply:SetNWInt("walljump", 0)         ply:SetCanWalk(true)         ply:SetupHands()         ply:SetCrouchedWalkSpeed(0.3)         ply:SetNWInt("victim",0)         ply:Freeze( true )         ply:GodEnable()         ply:UnSpectate()         ply:SetGravity(1.0)         ply:SetDuckSpeed( 0.0 )         ply:SetCollisionGroup( COLLISION_GROUP_WEAPON )         //ply:SetModel("models/player/Group01/Male_01.mdl")         //SetTeams()     end     ply:AllowFlashlight(false)     ply:SetCollisionGroup( COLLISION_GROUP_WEAPON )     ply:SetHullDuck(Vector( -16, -16, 0 ), Vector( 16, 16, 72 ))     ply:StopLuaAnimation("smash1")     ply:StopLuaAnimation("flick2")     ply:StopLuaAnimation("katanaspin2")     ply:StopLuaAnimation("frogleap")     ply:StopLuaAnimation("kickdown1")     ply:StopLuaAnimation("meleeslam2")     ply:StopLuaAnimation("block1")     ply:StopLuaAnimation("yatata")     ply:StopLuaAnimation("frogjump2")     ply:StopLuaAnimation("walljump_up1")     ply:StopLuaAnimation("walljump_up2")     ply:StopLuaAnimation("walljump_wall")     //ply:PS_GiveItem("pet_bobomb")     //ply:PS_GiveItem("pet_gardevoir")     //ply:PS_GiveItem("pet_jirachi")     //ply:PS_GiveItem("pet_fire")     //ply:PS_GiveItem("pet_koopa")     //ply:PS_GiveItem("pet_navi")     //ply:PS_GiveItem("pet_vinesauce")     //ply:PS_GiveItem("pet_star")     ply:ScreenFade( SCREENFADE.IN, Color( 0, 0, 0, 255 ), 1, 4.75 )     timer.Simple(1,function()     if(ply:PS_HasItem("izuku") == false) then         ply:PS_GiveItem("izuku")         ply:PS_EquipItem("izuku")     end     if(ply:PS_HasItem("ochaco") == false) then         ply:PS_GiveItem("ochaco")     end     if(ply:PS_HasItem("bakugo") == false) then         ply:PS_GiveItem("bakugo")     end     if(ply:PS_HasItem("tsuyu") == false) then         ply:PS_GiveItem("tsuyu")     end     if(ply:PS_HasItem("neckbeard") == false) then         ply:PS_GiveItem("neckbeard")     end     if(ply:PS_HasItem("hacker") == false) then         ply:PS_GiveItem("hacker")     end     if(ply:PS_HasItem("shaggy") == false) then         ply:PS_GiveItem("shaggy")     end     if(ply:PS_HasItem("gaben") == false) then         ply:PS_GiveItem("gaben")     end     if(ply:PS_HasItem("vinny") == false) then         ply:PS_GiveItem("vinny")     end     end) end end function GM:PlayerDeathThink( ply )     if(ply:IsOnFire() == true) then         ply:Extinguish()     end     local players = player.GetAll()     if ply:KeyPressed( IN_ATTACK ) then         local target = GetNextAlivePlayer(ply:GetObserverTarget())         ply:SpectateEntity( target )         end     if(IsValid(ply:GetObserverTarget())) then         ply:SetPos(ply:GetObserverTarget():GetPos())     end end function GM:PlayerSpawnAsSpectator( ply )     ply:KillSilent()     ply:Spectate( OBS_MODE_ROAMING ) end For all i know the issue might not even be in the code snippets above which would frustrate me even more.
Looks like telekilling to me, make sure spawn is not occupied already
once again a problem that seems too large for me to handle gets fixed moments after somone points out something that should have been obvious. Turns out doing this fixed my apparent spawn issues. function GM:IsSpawnpointSuitable( ply, spawnpointent, bMakeSuitable )     return false end
https://github.com/Facepunch/garrysmod/blob/394ae745df8f8f353ea33c8780f012fc000f4f56/garrysmod/gamemodes/base/gamemode/player.lua#L369 Thiis is why it kills people. Basically it only kills when the team has run out of spawnpoints so make new ones or allow people to spawn inside each other (i,e, no collide)
Sorry, you need to Log In to post a reply to this thread.