• Deleting preset weapons and items in a map
    0 replies, posted
[b]Objective: [/b]I'm trying to setup my class based game mode so that when a round starts all preset guns and certain ammo types get deleted (so I can use basic HL2DM maps for testing) [b]Error: [/b]It currently does delete the guns and ammo but it also strips them from the playe before the round starts. If the player suicides they get their normal loadout [b]Code: [/b] [b]init.lua[/b] [lua] include("ent_gunkiller.lua") // Separate file containing the ent.SW.kill_HL2_junk function function GM:OnRoundStart( num ) for t=1,2 do //this is clearing the players scores for k,v in pairs( team.GetPlayers( t ) ) do v:SetFrags( 0 ) end end ents.SW.kill_HL2_junk()//calling function to get rid of unneeded HL2 weapons/ammo UTIL_UnFreezeAllPlayers() //unfreeze players so they can start shooting end [/lua] [b]ent_gunkiller.lua[/b] [lua] unneeded={} //This tables going to list things we want taken out unneeded[1] = "weapon_357" //20 more lines of these function ents.SW.kill_HL2_junk() for k, v in pairs(ents.GetAll()) do for i=1,21 do //compare each ent against the ones in the table, if they match remove them if( v:GetClass()== unneeded[i]) then v:Remove() end end end end [/lua] [b]Notes: [/b] The only ways I can think of to solve it right now is to either create new sweps that are exactly the same or find a way to have it first check to see if its a player that has the entity.
Sorry, you need to Log In to post a reply to this thread.