local curWeps = curPly:GetWeapons()
for id, wep in SortedPairs( curWeps ) do
if IsValid(wep) then
local data = weapons.GetStored( wep:GetClass() )
--wep:SetClip1(data.Primary.ClipSize)
print( table.ToString( data, "wepstuff", true ) )
end
end
So I want to set every one of curPly's weapons to have a full clip.
Idk what I should be looking for. Winging it I found that data.Primary.ClipSize doesn't work for finding that ClipSize. Any tips?
Entity Callbacks
PhysicsCollide callback
You need to Entity/SetPos on the player's Entity/GetPos and then Entity/Spawn.
There's an example in ents.Create
Are you meaning something like this?
local button = ents.Create( "stick" )
button:SetPos( ent:GetPos() )
button:Spawn()
because this just gives the player a stick when they throw the stick, without them having to get near it.
I think that's because it's touching the thrower. You could filter them out, or put a timed delay before the stick can be caught.
Found a solution, so the player throws their stick, then a 2 second delay is started (to prevent the player from picking the stick back up as soon as they throw it) then when the delay is over, the stick replaces its "prop_physics" with a stick weapon model, that can be picked up.
Cool, thanks, what about getting the sound files related to the entity's physics object material?
I requested it here.
Okay I'm gonna assume the forums bugged out when you sent that post and that you meant to link me to this.
my game seems to be crashing every time this hook is called/a referenced npc is spawned.
(This worked fine last night, but I created and modified this while the game was running)
hook.Add( "OnEntityCreated", "ddlSetNPCRelat", function( npc )
if not ( npc:IsValid() && npc:IsNPC() ) then return end
local curClass = npc:GetClass()
if string.find( string.lower(curClass), "citiz", 1 ) then
npc:AddRelationship( "npc_headcrab D_HT 5" )
npc:AddRelationship( "npc_headcrab_fast D_HT 10" )
npc:AddRelationship( "npc_headcrab_black D_HT 20" )
npc:AddRelationship( "npc_headcrab_poison D_HT 20" )
npc:AddRelationship( "npc_zombie D_HT 50" )
npc:AddRelationship( "npc_zombie_torso D_HT 30" )
npc:AddRelationship( "npc_fastzombie D_HT 60" )
npc:AddRelationship( "npc_fastzombie_torso D_HT 40" )
npc:AddRelationship( "npc_poisonzombie D_HT 80" )
npc:AddRelationship( "npc_zombine D_HT 35" )
npc:AddRelationship( "npc_antlionguard D_HT 100" )
npc:AddRelationship( "npc_antlionguardian D_HT 110" )
npc:AddRelationship( "npc_antlion_worker D_HT 90" )
npc:AddRelationship( "npc_antlion D_HT 2" )
npc:AddRelationship( "npc_combine_s D_NU 1" )
npc:AddRelationship( "npc_hunter D_HT 90" )
npc:AddRelationship( "npc_manhack D_HT 1" )
elseif string.find( string.lower(curClass), "combin", 1 ) then
npc:AddRelationship( "npc_headcrab D_HT 5" )
npc:AddRelationship( "npc_headcrab_fast D_HT 10" )
npc:AddRelationship( "npc_headcrab_black D_HT 20" )
npc:AddRelationship( "npc_headcrab_poison D_HT 20" )
npc:AddRelationship( "npc_zombie D_HT 50" )
npc:AddRelationship( "npc_zombie_torso D_HT 30" )
npc:AddRelationship( "npc_fastzombie D_HT 60" )
npc:AddRelationship( "npc_fastzombie_torso D_HT 40" )
npc:AddRelationship( "npc_poisonzombie D_HT 80" )
npc:AddRelationship( "npc_zombine D_HT 35" )
npc:AddRelationship( "npc_antlionguard D_HT 100" )
npc:AddRelationship( "npc_antlionguardian D_HT 110" )
npc:AddRelationship( "npc_antlion_worker D_HT 90" )
npc:AddRelationship( "npc_antlion D_HT 2" )
npc:AddRelationship( "npc_citizen D_NU 1" )
elseif string.find( string.lower(curClass), "hunter", 1 ) then
npc:AddRelationship( "npc_headcrab D_HT 5" )
npc:AddRelationship( "npc_headcrab_fast D_HT 10" )
npc:AddRelationship( "npc_headcrab_black D_HT 20" )
npc:AddRelationship( "npc_headcrab_poison D_HT 20" )
npc:AddRelationship( "npc_zombie D_HT 50" )
npc:AddRelationship( "npc_zombie_torso D_HT 30" )
npc:AddRelationship( "npc_fastzombie D_HT 60" )
npc:AddRelationship( "npc_fastzombie_torso D_HT 40" )
npc:AddRelationship( "npc_poisonzombie D_HT 80" )
npc:AddRelationship( "npc_zombine D_HT 35" )
npc:AddRelationship( "npc_antlionguard D_HT 100" )
npc:AddRelationship( "npc_antlionguardian D_HT 110" )
npc:AddRelationship( "npc_antlion_worker D_HT 90" )
npc:AddRelationship( "npc_antlion D_HT 2" )
npc:AddRelationship( "npc_citizen D_HT 1" )
elseif string.find( string.lower(curClass), "metro", 1 ) then
npc:AddRelationship( "npc_headcrab D_HT 105" )
npc:AddRelationship( "npc_headcrab_fast D_HT 120" )
npc:AddRelationship( "npc_headcrab_black D_HT 130" )
npc:AddRelationship( "npc_headcrab_poison D_HT 130" )
npc:AddRelationship( "npc_zombie D_HT 50" )
npc:AddRelationship( "npc_zombie_torso D_HT 30" )
npc:AddRelationship( "npc_fastzombie D_HT 60" )
npc:AddRelationship( "npc_fastzombie_torso D_HT 40" )
npc:AddRelationship( "npc_poisonzombie D_HT 80" )
npc:AddRelationship( "npc_zombine D_HT 35" )
npc:AddRelationship( "npc_antlionguard D_HT 100" )
npc:AddRelationship( "npc_antlionguardian D_HT 110" )
npc:AddRelationship( "npc_antlion_worker D_HT 90" )
npc:AddRelationship( "npc_antlion D_HT 2" )
npc:AddRelationship( "npc_citizen D_NU 1" )
elseif string.find( string.lower(curClass), "ant", 1 ) then
npc:AddRelationship( "npc_headcrab D_HT 105" )
npc:AddRelationship( "npc_headcrab_fast D_HT 120" )
npc:AddRelationship( "npc_headcrab_black D_HT 130" )
npc:AddRelationship( "npc_headcrab_poison D_HT 130" )
npc:AddRelationship( "npc_zombie D_HT 50" )
npc:AddRelationship( "npc_zombie_torso D_HT 30" )
npc:AddRelationship( "npc_fastzombie D_HT 60" )
npc:AddRelationship( "npc_fastzombie_torso D_HT 40" )
npc:AddRelationship( "npc_poisonzombie D_HT 25" )
npc:AddRelationship( "npc_zombine D_HT 15" )
npc:AddRelationship( "npc_antlionguard D_LI 200" )
npc:AddRelationship( "npc_antlionguardian D_LI 200" )
npc:AddRelationship( "npc_antlion_worker D_LI 200" )
npc:AddRelationship( "npc_antlion D_LI 200" )
npc:AddRelationship( "npc_citizen D_HT 1" )
npc:AddRelationship( "npc_combine_s D_HT 1" )
npc:AddRelationship( "npc_hunter D_HT 5" )
npc:AddRelationship( "npc_manhack D_HT 1" )
end
end )
also I'm sure there's a much better way to do what I'm trying to do, maybe using tables? I'm having trouble figuring that out as well but I think fixing the crashes is more important right now.
Try adding the relationships a frame later (0-second timer).
That fixed the crash but I don't understand the error
[ERROR] addons/myaddon/lua/autorun/ddl_relationships.lua:112: Tried to use a NULL entity!
1. AddRelationship - [C]:-1
2. unknown - addons/myaddon/lua/autorun/ddl_relationships.lua:112
Timer Failed! [Simple][@addons/myaddon/lua/autorun/ddl_relationships.lua (line 10)]
Check if the entity is valid in the timer before using it - it could have been removed in that time. Here's an example of how you could condense your code (code tags are broken atm so here's it in text):
local tCitizenRelationships = {
npc_headcrab = "D_HT 5",
npc_headcrab_fast = "D_HT 10",
npc_headcrab_black = "D_HT 20"
-- etc
}
local tCombineRelationships = {}
local tHunterRelationships = {}
local tMetroRelationships = {}
local tAntlionRelationships = {}
local tClasses = {
npc_citizen = tCitizenRelationships,
npc_hunter = tHunterRelationships,
npc_metropolice = tMetroRelationships,
npc_antlion = tAntlionRelationships,
npc_antlionguard = tAntlionRelationships,
npc_antlionguardian = tAntlionRelationships,
npc_antlion_worker = tAntlionRelationships,
-- etc
}
hook.Add( "OnEntityCreated", "ddlSetNPCRelat", function( pNPC )
if ( pNPC:IsNPC() ) then
local tRelationships = tClasses[ pNPC:GetClass() ]
if ( tRelationships ~= nil ) then
timer.Simple( 0, function()
if ( pNPC:IsValid() ) then
for sClass, sRelationship in pairs( tRelationships ) do
pNPC:AddRelationship( string.format( "%s %s", sClass, sRelationship ) )
end
end
end )
end
end
end )
I have a 3D2D menu that follows the camera's pitch and yaw axis, but at certain angles or positions the menu likes to glitch out, and it gets much worse when I tab out (Windowed mode) is there some way to remedy this?
Screen capture
Is there a way to force an npc to ignore an ent that blocks their line of fire? I'm using a prop to block bullets and projectiles, but NPCs react by ceasing fire and trying to run through the prop.
The preferred result is the NPCs essentially don't even register the entity so they try (and fail) to shoot through it.
I'm creating a sawblade and I want it to slice zombies when it hits them, much like when throwing them with the gravity gun.
if SERVER then
local vThrow = FWD * 4000
local Blade = ents.Create( "prop_physics" )
Blade:SetModel("models/props_junk/sawblade001a.mdl")
Blade:SetPos( self.Owner:GetShootPos()+FWD*10+UP*(-10)+RGT*10 )
Blade:SetAngles( vThrow:Angle() )
Blade:SetAbsVelocity( vThrow )
Blade:SetOwner( self.Owner )
Blade:SetLocalAngularVelocity(Angle(0, math.Rand(-420, -690), 0))
Blade:SetVelocity(FWD*(800+VB)+UPV)
Blade:SetCollisionGroup(COLLISION_GROUP_PROJECTILE)
Blade:Spawn()
Blade:SetMoveType(MOVETYPE_FLYGRAVITY)
Blade:Activate()
local bPhy = Blade:GetPhysicsObject()
bPhy:AddGameFlag(FVPHYSICS_WAS_THROWN)
end
It's not working. They spawn, they hit stuff... but they don't damage stuff. How can I fix that?
Anyone have any idea as to why my Dlistview is not updating when i addlines via a net message?
cl_init.lua
function Refreshlist()
list:Clear()
if (IsValid(entity)) then
list:AddLine(entity:Nick(),string,"Open")
end
end
net.Receive("SndB", function()
print("Received SndB net message from server.")
local entity = net.ReadTable()
local string = net.ReadString()
if (IsValid(frame55)) then
Refreshlist()
frame55:Show()
else
AdminGUI()
end
end)
init.lua
net.Receive("ticket", function(len,ply)
filter = RecipientFilter()
for k,v in pairs(player.GetAll()) do
if v:IsAdmin() then
filter:AddPlayer(v)
end
end
ply2 = {}
ply2.Name = ply:UserID()
local players = filter:GetPlayers()
PrintTable(players)
net.Start("SndB")
net.WriteTable(ply2)
net.WriteString(net.ReadString())
net.Send(filter:GetPlayers())
end)
i'm thinking it has to do with my recipient filter... Although net.Send(Players table) can send to a table of players.
Try calling Player/SimulateGravGunPickup on it.
Does anyone know if it's possible to draw view model but without hands using DrawModel function?
Is it a v_model or c_model?
c_model.
GM/PreDrawPlayerHands
Sorry, you need to Log In to post a reply to this thread.