[QUOTE=asgloki;52414663]I'm trying to make an entity but whenever I spawn it in sandbox I get an error model, though when I spawn it in through my gamemode the model shows up. I've got no idea how to fix it, this is the code but I feel like it's probably because of where I saved the entity or something:
[CODE]function ENT:Initizialize()
self:SetModel( "models/props_borealis/bluebarrel001.mdl" )
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_NONE)
self:SetSolid(SOLID_VPHYSICS)
self:GetPhysicsObject():Wake()
end[/CODE][/QUOTE]
Wild guess, but I'm assuming you've saved your entity Lua file(s) in the gamemode folder and not the gmod Lua folder? If it's only in the gamemode folder, it will not work in Sandbox, as it doesn't exist. It doesn't work like materials/sounds where even if it's not used, it's still recognized. If you load a different gamemode, it's gone.
As for a question --
Is there a Lua call for detecting if a player is zoomed in, say with the HL2 Crossbow? I have a working code that needs to be shifted to only run when the player is zoomed in, but I cannot find one on the wiki.
[QUOTE=Rory;52415729]Wild guess, but I'm assuming you've saved your entity Lua file(s) in the gamemode folder and not the gmod Lua folder? If it's only in the gamemode folder, it will not work in Sandbox, as it doesn't exist. It doesn't work like materials/sounds where even if it's not used, it's still recognized. If you load a different gamemode, it's gone.
As for a question --
Is there a Lua call for detecting if a player is zoomed in, say with the HL2 Crossbow? I have a working code that needs to be shifted to only run when the player is zoomed in, but I cannot find one on the wiki.[/QUOTE]
Nah, that's not it. I have it saved in the gamemode folder and the lua folder. If I didn't have it in the lua folder it wouldn't even show up in entities on sandbox would it? It's really strange.
[QUOTE=asgloki;52415844]Nah, that's not it.[/QUOTE]
Yeah, I just realized what I had said. If it's spawning at all, then it's being recognized, otherwise it would say unknown entity type... Blue barrel should be a stock Half-Life 2 item, so it should be good to go. Does your code have any other models, or anything that would give off a model like a prop? If you're worried about posting the whole code publicly, you can send me a message. I'm not a Lua professional like some people here but I can give a second opinion while you wait for a reply. My new and more-informed assumption would be that the entity/entities are rendering another model that your gamemode automatically assumes/uses..
Hey guys
So I just added an image to a DPanel and I "draw.DrawText"'d some Text to be on Top of this Image, but "DImage" Covers the text instead of the text covering the Image. Any Idea why?
[CODE]
draw.DrawText("Example Text", "Arial", 140, 320, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT)
local Image = vgui.Create("DImage", self)
Image:SetPos(120, 340)
Image:SetSize(280, 80)
Image:SetImage("example/Image")
[/CODE]
[QUOTE=Benn20002;52415467]This is literally spamming my console..
Bad SetLocalOrigin(-17068.048828,-15015.128906,-30.203926) on gmod_hands
What could cause this?[/QUOTE]
It would be caused by some modification made to the viewmodel
[QUOTE=Pwned231;52416288]Hey guys
So I just added an image to a DPanel and I "draw.DrawText"'d some Text to be on Top of this Image, but "DImage" Covers the text instead of the text covering the Image. Any Idea why?
[CODE]
draw.DrawText("Example Text", "Arial", 140, 320, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT)
local Image = vgui.Create("DImage", self)
Image:SetPos(120, 340)
Image:SetSize(280, 80)
Image:SetImage("example/Image")
[/CODE][/QUOTE]
I tried Drawing the Text after the Image... I really don't want to use DLabel's Also, any ideas?
[QUOTE=Pwned231;52416443]I tried Drawing the Text after the Image... I really don't want to use DLabel's Also, any ideas?[/QUOTE]
You shouldn't be mixing the draw library with derma like that, otherwise you're doing something wrong. Why not just use a DLabel?
[QUOTE=YourStalker;52416597]You shouldn't be mixing the draw library with derma like that, otherwise you're doing something wrong. Why not just use a DLabel?[/QUOTE]
Sorry I forgot to mention, 'draw.DrawText' is inside DPanel.Paint() function.
EDIT: And the DImage is outside
How can I make it so that a in TTT, the server has data as to whether or not a killer had DNA on their victim?
[QUOTE=Pwned231;52416620]Sorry I forgot to mention, 'draw.DrawText' is inside DPanel.Paint() function.
EDIT: And the DImage is outside[/QUOTE]
If you want text inside a DIamge, you should be setting the text after the image using panel:SetText()
correct me if im wrong.
I'm trying to make a poison zombie torso. and the code is at the bottom. and my problem is that first off the torso is slightly floating? and when disable ai is on it goes to T animation instead of idle animation. Help?
function ENT:RunBehaviour()
while ( true ) do
timer.Simple(1.7,function()
end)
local ent = ents.Create("npc_poisonzombie")
ent:SetPos(self:GetPos() + Vector(0,0,20))
ent:SetAngles(self:GetAngles())
ent:Spawn()
ent:SetModel("models/zombie/poison_torso.mdl")
ent:SetKeyValue( "crabcount", 0 )
ent:SetSaveValue("m_fIsTorso", true)
ent:SetName("Poison Zombie Torso")
undo.Create( "Poison Zombie Torso" )
local k, v
for k, v in ipairs( ents.GetAll( ) ) do
if v:IsPlayer() then
undo.AddEntity( ent )
undo.SetPlayer( v )
undo.Finish()
SafeRemoveEntity(self)
coroutine.yield()
end
end
[QUOTE=PigeonTroll;52416979]How can I make it so that a in TTT, the server has data as to whether or not a killer had DNA on their victim?[/QUOTE]
[url]https://github.com/Tommy228/TTTDamagelogs[/url]
This is a damage lof script by Tommy228, it keeps tracks of almost all events, including when a player gets DNA on another.
I'm trying to make a poison zombie torso. and the code is at the bottom. and my problem is that first off the torso is slightly floating? and when disable ai is on it goes to T animation instead of idle animation. Help?
function ENT:RunBehaviour()
while ( true ) do
timer.Simple(1.7,function()
end)
local ent = ents.Create("npc_poisonzombie")
ent:SetPos(self:GetPos() + Vector(0,0,20))
ent:SetAngles(self:GetAngles())
ent:Spawn()
ent:SetModel("models/zombie/poison_torso.mdl")
ent:SetKeyValue( "crabcount", 0 )
ent:SetSaveValue("m_fIsTorso", true)
ent:SetName("Poison Zombie Torso")
undo.Create( "Poison Zombie Torso" )
local k, v
for k, v in ipairs( ents.GetAll( ) ) do
if v:IsPlayer() then
undo.AddEntity( ent )
undo.SetPlayer( v )
undo.Finish()
SafeRemoveEntity(self)
coroutine.yield()
end
end
Hello people, im trying to make a swep that gives me movespeed when i hit a player thats on the zombie team,
code is
[CODE]function SWEP.BulletCallback(attacker, tr, dmginfo)
local ent = tr.Entity
if ent:IsValid() and ent:IsPlayer() and ent:Team() == TEAM_UNDEAD then
move:SetMaxSpeed(move:GetMaxSpeed() + 50)
move:SetMaxClientSpeed(move:GetMaxSpeed())
end
end[/CODE]
Anyone care to tell me what im doing wrong? would really appreciate it :)
edit: another variation of what im trying to do
[CODE]function SWEP.BulletCallback(attacker, tr, dmginfo)
local ent = tr.Entity
if ent:IsValid() and ent:IsPlayer() and ent:Team() == TEAM_UNDEAD then
self.Owner:SetWalkSpeed(self.Owner:GetWalkSpeed() + 50)
self.Owner:SetWalkSpeed(math.Clamp( self.Owner:GetWalkSpeed() + 50, 0, self.Owner:MaxWalkSpeed() )
end
end[/CODE]
[QUOTE=code_gs;52416296]It would be caused by some modification made to the viewmodel[/QUOTE]
Serverside?
I don't see any serversided hook that has to do with the viewmodel except OnViewModelChanged which isn't used in any of my addons.
I'm having a weird problem
Basically i have a mine entity with the explode code like this
[code]function ENT:Explode()
self.Entity:EmitSound( "ambient/explosions/explode_4.wav" )
self.Entity:SetOwner(self.C4Owner)
local detonate = ents.Create( "env_explosion" )
detonate:SetOwner(self.C4Owner)
detonate:SetPos( self.Entity:GetPos() )
detonate:SetKeyValue( "iMagnitude", "90" )
detonate:Spawn()
detonate:Activate()
detonate:Fire( "Explode", "", 0 )
self.Entity:Remove()
end[/code]
And i make it detonate-able by guns or any damage source
[code]function ENT:OnTakeDamage( dmginfo )
self:Explode()
end[/code]
It work fine when i shoot it, but if it's detonated by explosion like other mine or grenade it will create MANY explosion at a time causing fps drop and leaving tons of decal behind
Any idea why this is happening?
[editline]30th June 2017[/editline]
Ok just tested, it does create many explosions not just some effect
my health gone from 9999 to -7
[editline]30th June 2017[/editline]
Fixed it by adding a 0,1s timer, I guess explosion cause many damage source at a time and the mine didn't explode fast enough so it took all that input and create the same amount of explosion
[QUOTE=Rory;52415913]Yeah, I just realized what I had said. If it's spawning at all, then it's being recognized, otherwise it would say unknown entity type... Blue barrel should be a stock Half-Life 2 item, so it should be good to go. Does your code have any other models, or anything that would give off a model like a prop? If you're worried about posting the whole code publicly, you can send me a message. I'm not a Lua professional like some people here but I can give a second opinion while you wait for a reply. My new and more-informed assumption would be that the entity/entities are rendering another model that your gamemode automatically assumes/uses..[/QUOTE]
I don't mind posting the code, I'm only learning right now so there's not much code anyway, I'll show you how it's spawned in the gamemode, I don't think the rest of my code should really affect this anyway.
[CODE]
function powerupSpawn()
if t < CurTime() then
t = CurTime() + interval
local powerup = ents.Create( "powerup" )
powerup:SetModel("models/props_borealis/bluebarrel001.mdl")
powerup:SetPos( Vector( 1306, 2195, 32) )
powerup:PhysicsInit(SOLID_VPHYSICS)
powerup:SetMoveType(MOVETYPE_NONE)
powerup:SetSolid(SOLID_VPHYSICS)
powerup:SetCollisionGroup(COLLISION_GROUP_WEAPON)
powerup:Spawn()
end
end
hook.Add("Think", "PowerupThink", powerupSpawn)[/CODE]
[QUOTE=asgloki;52414663]I'm trying to make an entity but whenever I spawn it in sandbox I get an error model, though when I spawn it in through my gamemode the model shows up. I've got no idea how to fix it, this is the code but I feel like it's probably because of where I saved the entity or something:
[CODE]function ENT:Initizialize()
self:SetModel( "models/props_borealis/bluebarrel001.mdl" )
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_NONE)
self:SetSolid(SOLID_VPHYSICS)
self:GetPhysicsObject():Wake()
end[/CODE][/QUOTE]
You spelt 'initialize' wrong, it should be
[CODE]function ENT:Initialize() [/CODE]
-snip
[QUOTE=Meninist;52416981]If you want text inside a DIamge, you should be setting the text after the image using panel:SetText()
correct me if im wrong.[/QUOTE]
panel:SetText() would build text differently from DrawText and wouldn't fix the DrawRoundedBox problem. I don't want alt's I want to simply put Draw's On top of the Image. I know we can do this because I already did sometime ago, but I don't remember. I'll tell you when I get it done.
Thanks for the try anyway
I'm trying to make a poison zombie torso. and the code is at the bottom. and my problem is that first off the torso is slightly floating? and when disable ai is on it goes to T animation instead of idle animation. Help?
function ENT:RunBehaviour()
while ( true ) do
timer.Simple(1.7,function()
end)
local ent = ents.Create("npc_poisonzombie")
ent:SetPos(self:GetPos() + Vector(0,0,20))
ent:SetAngles(self:GetAngles())
ent:Spawn()
ent:SetModel("models/zombie/poison_torso.mdl")
ent:SetKeyValue( "crabcount", 0 )
ent:SetSaveValue("m_fIsTorso", true)
ent:SetName("Poison Zombie Torso")
undo.Create( "Poison Zombie Torso" )
local k, v
for k, v in ipairs( ents.GetAll( ) ) do
if v:IsPlayer() then
undo.AddEntity( ent )
undo.SetPlayer( v )
undo.Finish()
SafeRemoveEntity(self)
coroutine.yield()
end
end
I already responded to your PM: stop spamming your code -- you've posted it here 5+ times already and made 2 individual threads.
-snip-
You're probably overwriting the functions player classes rely on. As for your first attempt, you need to call it on a player, not the player meta table. You would use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LocalPlayer]LocalPlayer[/url] in place of it. I believe you'd have to call this on every player though, so might be easier just to use (Set/Get)NW2* functions as they do the same internally.
[QUOTE=bigdogmat;52419717]your first attempt[/QUOTE]
The first attempt was the only one that even remotely worked. Everything serverside worked but the client couldn't use it, because it was created server side. PlayerInitialSpawn is server side only so it wouldn't change anything to put it in a shared file.
Everything I read said it's better to use NetworkVar, but I'm about to either go back to (Get/Set)NW*, or punch my monitor if I can't get this figured out.
What I understand is that it has to be called on the player entity itself, which is why it worked on the first example (server-side). I can't find any way to do this in a shared file. OnEntityCreated is client/server, but I just tried that now and it did jack diddly shit.
Bringing an issue back up that I didn't quite get an answer to:
When I try to force a player to crouch in SetupMove, StartCommand, or CreateMove, the player appears to be rapidly tapping crouch instead of holding it.
Ideally I need to force this behavior serverside as I can't exactly trust the player to cripple themselves.
[video=youtube;zmOajB3Rp3k]https://www.youtube.com/watch?v=zmOajB3Rp3k[/video]
[code]
hook.Add( "StartCommand", "BrokenLegsMove", function( ply, dat )
if ( not ply or not IsValid( ply ) or not dat ) then return end
if ( ply:GetNWBool( "BrokenLegs", false ) and ply:Alive() ) then
dat:SetButtons( dat:GetButtons() + IN_DUCK )
end
end )
[/code]
[QUOTE=a1steaksa;52419907]the player appears to be rapidly tapping crouch instead of holding it.[/QUOTE]
I believe "IN_DUCK" just runs the action once, not locks it down like the "+duck" console command does... In technical terms, the control +duck is toggled whereas IN_DUCK is just a call. If I'm correct, then the only way I see doing that is by having the client run the +duck command
[lua]
ply:ConCommand("+duck")
[/lua]
Use -duck to make them stand up. I think the only problem with this is that you would have a problem with players typing -duck to get up from it.
Hopefully that gives you some type of answer while the Lua Masters come up with the real one. Comment out your code and use +duck for now, so you can make your addon/gamemode functional until you're either done and can return to it or wait for a good answer.
Quick question: How do i take the weapon's w_model of the weapon that the player is holding? I want to make they drop weapon on death but prop only
[QUOTE=YoutoYokodera;52421132]Quick question: How do i take the weapon's w_model of the weapon that the player is holding? I want to make they drop weapon on death but prop only[/QUOTE]
The wording of your question is very vague, but here are the relevant functions to what you're generally asking.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ShouldDropWeapon]Player:ShouldDropWeapon[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/ShouldDropOnDie]SWEP:ShouldDropOnDie[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/DropNamedWeapon]Player:DropNamedWeapon[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/DropWeapon]Player:DropWeapon[/url]
[QUOTE=code_gs;52421162]The wording of your question is very vague, but here are the relevant functions to what you're generally asking.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ShouldDropWeapon]Player:ShouldDropWeapon[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/ShouldDropOnDie]SWEP:ShouldDropOnDie[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/DropNamedWeapon]Player:DropNamedWeapon[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/DropWeapon]Player:DropWeapon[/url][/QUOTE]
Is the weapon dropped pickup-able / Or how to disable pickup
Sorry, you need to Log In to post a reply to this thread.