Permalink
Browse files

Small fixes and changes

* Moved the menu bar stuff to one file for several reasons
* Fix for Facepunch/garrysmod-issues#887
* Made so that editing presets doesn't remove default presets set by the
CPanel
* Aligned tabulation with Notepad++, since it's the most used for GLua
  • Loading branch information...
1 parent 02c47b6 commit da42d7e836f2189a6b263f3c8dd2da01bd67486c @robotboy655 robotboy655 committed Mar 25, 2014
@@ -9,7 +9,7 @@ util.AddNetworkString( "NPCKilledNPC" )
function GM:OnNPCKilled( ent, attacker, inflictor )
-- Don't spam the killfeed with scripted stuff
- if ( ent:GetClass() == "npc_bullseye" ) then return end
+ if ( ent:GetClass() == "npc_bullseye" || ent:GetClass() == "npc_launcher" ) then return end
-- Convert the inflictor to the weapon that they're holding if we can.
if ( inflictor && inflictor != NULL && attacker == inflictor && (inflictor:IsPlayer() || inflictor:IsNPC()) ) then
@@ -263,7 +263,7 @@ function DoPlayerEntitySpawn( player, entity_name, model, iSkin, strBody )
-- Set new position
ent:SetPos( vFlushPoint )
- player:SendLua( "achievements.SpawnedProp()" );
+ player:SendLua( "achievements.SpawnedProp()" )
else
@@ -274,7 +274,7 @@ function DoPlayerEntitySpawn( player, entity_name, model, iSkin, strBody )
phys:SetPos( phys:GetPos() + VecOffset )
end
- player:SendLua( "achievements.SpawnedRagdoll()" );
+ player:SendLua( "achievements.SpawnedRagdoll()" )
end
@@ -294,7 +294,7 @@ local function InternalSpawnNPC( Player, Position, Normal, Class, Equipment )
-- We don't want them spawning any entity they like!
if ( !NPCData ) then
if ( IsValid( Player ) ) then
- Player:SendLua( "Derma_Message( \"Sorry! You can't spawn that NPC!\" )" );
+ Player:SendLua( "Derma_Message( \"Sorry! You can't spawn that NPC!\" )" )
end
return end
@@ -390,7 +390,13 @@ local function InternalSpawnNPC( Player, Position, Normal, Class, Equipment )
-- What weapon should this mother be carrying
--
- if ( Equipment && Equipment != "none" ) then
+ -- Check if this is a valid entity from the list, or the user is trying to fool us.
+ local valid = false
+ for _, v in pairs( list.Get( "NPCUsableWeapons" ) ) do
+ if v.class == Equipment then valid = true end
+ end
+
+ if ( Equipment && Equipment != "none" && valid ) then
NPC:SetKeyValue( "additionalequipment", Equipment )
NPC.Equipment = Equipment
end
@@ -457,7 +463,7 @@ function Spawn_NPC( player, NPCClassName, WeaponName, tr )
-- And cleanup
player:AddCleanup( "npcs", SpawnedNPC )
- player:SendLua( "achievements.SpawnedNPC()" );
+ player:SendLua( "achievements.SpawnedNPC()" )
end
@@ -591,7 +597,7 @@ function Spawn_SENT( player, EntityName, tr )
local trace = {}
trace.start = vStart
- trace.endpos = vStart + (vForward * 4096)
+ trace.endpos = vStart + ( vForward * 4096 )
trace.filter = player
tr = util.TraceLine( trace )
@@ -641,6 +647,10 @@ function Spawn_SENT( player, EntityName, tr )
entity:SetKeyValue( k, v )
end
end
+
+ if ( EntTable.Material ) then
+ entity:SetMaterial( EntTable.Material )
+ end
entity:Spawn()
entity:Activate()
@@ -658,9 +668,9 @@ function Spawn_SENT( player, EntityName, tr )
gamemode.Call( "PlayerSpawnedSENT", player, entity )
end
- undo.Create("SENT")
- undo.SetPlayer(player)
- undo.AddEntity(entity)
+ undo.Create( "SENT" )
+ undo.SetPlayer( player )
+ undo.AddEntity( entity )
if ( PrintName ) then
undo.SetCustomUndoText( "Undone "..PrintName )
end
@@ -670,8 +680,7 @@ function Spawn_SENT( player, EntityName, tr )
entity:SetVar( "Player", player )
end
-
-
+
end
concommand.Add( "gm_spawnsent", function( ply, cmd, args ) Spawn_SENT( ply, args[1] ) end )
@@ -712,7 +721,7 @@ function Spawn_Weapon( Player, wepname, tr )
if ( wepname == nil ) then return end
- local swep = list.Get( "Weapon" )[ wepname ];
+ local swep = list.Get( "Weapon" )[ wepname ]
-- Make sure this is a SWEP
if ( swep == nil ) then return end
@@ -820,7 +829,7 @@ function Spawn_Vehicle( Player, vname, tr )
if ( vehicle.Members ) then
table.Merge( Ent, vehicle.Members )
- duplicator.StoreEntityModifier( Ent, "VehicleMemDupe", vehicle.Members );
+ duplicator.StoreEntityModifier( Ent, "VehicleMemDupe", vehicle.Members )
end
undo.Create( "Vehicle" )
@@ -838,7 +847,7 @@ concommand.Add( "gm_spawnvehicle", function( ply, cmd, args ) Spawn_Vehicle( ply
local function VehicleMemDupe( Player, Entity, Data )
- table.Merge( Entity, Data );
+ table.Merge( Entity, Data )
end
-duplicator.RegisterEntityModifier( "VehicleMemDupe", VehicleMemDupe );
+duplicator.RegisterEntityModifier( "VehicleMemDupe", VehicleMemDupe )
@@ -92,7 +92,7 @@ function PANEL:FillViaTable( Table )
--
if ( Table.ControlPanelBuildFunction ) then
- self:FillViaFunction( Table.ControlPanelBuildFunction );
+ self:FillViaFunction( Table.ControlPanelBuildFunction )
--
-- If not, use the txt file
@@ -133,7 +133,7 @@ function PANEL:LoadControlsFromTextFile( strName )
local kv = table.CollapseKeyValue( data.Value )
local ctrl = self:AddControl( data.Key, kv )
if ( ctrl && kv.description ) then
- ctrl:SetTooltip( kv.description );
+ ctrl:SetTooltip( kv.description )
end
end
@@ -146,10 +146,10 @@ end
-----------------------------------------------------------]]
function PANEL:ControlValues( data )
if ( data.label) then
- self:SetLabel( data.label );
+ self:SetLabel( data.label )
end
if ( data.closed ) then
- self:SetExpanded( false );
+ self:SetExpanded( false )
end
end
@@ -292,7 +292,7 @@ function PANEL:AddControl( control, data )
if ( control == "combobox" ) then
- if ( tostring(data.menubutton) == "1" ) then
+ if ( tostring( data.menubutton ) == "1" ) then
local ctrl = vgui.Create( "ControlPresets", self )
ctrl:SetPreset( data.folder )
@@ -135,8 +135,9 @@ end
function PANEL:ReloadPresets()
self:Clear()
- --reload our given defaults
- self:SetOptions()
+ for name, data in pairs( self.Options ) do
+ self:AddOption( name, data )
+ end
local Presets = presets.GetTable( self.m_strPreset )
local sortedPresets, i = {}, 1
@@ -147,7 +148,7 @@ function PANEL:ReloadPresets()
table.sort( sortedPresets )
for _, name in ipairs( sortedPresets ) do
- self:AddOption( name, Presets[name] )
+ self.DropDown:AddChoice( strName, data )
end
end
Oops, something went wrong.

0 comments on commit da42d7e

Please sign in to comment.