[QUOTE=Staneh;38308044]Is there any way to make players not collide now? I tried using [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa58d.html[/url]
The example didn't work, also tried:
[lua] function GM:ShouldCollide( ent1, ent2 )
if ent1:IsPlayer() and ent2:IsPlayer() then
return (ent1:Team() != ent2:Team())
end
return true
end
[/lua]
Any help?[/QUOTE]
player:SetNoCollideWithTeammates(<bool>)
ShouldCollide doesn't seem to be called AT ALL in my script. I know the hook has some infamy as being rather unstable when used for anything but basic return true/return false statements, but the peculiar thing is that it's been working up until the latest gmod update and now it doesn't even seem to be being called no matter what I do.
shared.lua:
[lua]local function PhysgunProtection(ply, ent)
if ent:IsWeapon() == false then
ent:SetCollisionGroup(2)
ent:DrawShadow(false)
timer.Create( "MakePropNormal", 4 , 1, function()
propphysmarked = ent
timer.Create("MakePropNormal2", 0.1, 1, function()
if ent == propphysmarked then
--propphysmarked.MakeNoCollided = 1
ent:SetCollisionGroup(0)
timer.Create("MakePropNormal2.1", 0.1, 1 , function()
ent:SetCollisionGroup(2)
timer.Create("MakePropNormal2.3", 0.5, 1 , function()
ent:SetCollisionGroup(0)
--propphysmarked.MakeNoCollided = 0
ent:DrawShadow(true)
end )
end )
end
end )
end )
end
end
local function PropRepulsion( ent1, ent2)
print("working2")
if ent1:IsWorld() != true then
print("working1")
if ent2:IsWorld() != true then
print("working2")
if ent1 == propphysmarked then
print("working3")
--if ent1.MakeNoCollided == 1 then
print("working4")
timer.Create("MakePropNormal3", 0.1, 1, function()
ent2:SetVelocity(Vector(0,0,500))
print("working5")
end )
end
elseif ent2 == propphysmarked then
print("working6")
--if ent2.MakeNoCollided == 1 then
print("working7")
timer.Create("MakePropNormal4", 0.1, 1, function()
ent1:SetVelocity(Vector(0,0,500))
print("working8")
end )
end
end
end
hook.Add( "PhysgunDrop", "Physgun Item Ghosting", PhysgunProtection)
hook.Add("ShouldCollide","Player/Prop Protection and Repulsion", PropRepulsion)[/lua]
There may be a better way to do this. I'm trying to make it so that when you drop an entity with the physgun it's collision group changes to make it no collided with everything. Then, after a certain amount of time, everything stuck inside the entity is thrown out and it becomes solid again.
I don't get "working2" printed in the console either for the player or on the RCON of my dedicated server, that's why I think it isn't being called
PS. I know my tabbing is terrible.
-snip- fixed it!
-snip- I got it. Thanks for your help.
[vid]http://puu.sh/1mdeO[/vid]
I have no idea what is going on.
How do you draw a transparent image on the HUD?
I've tried to turn a transparent PNG in to a VTF and then draw it using DrawTexturedRect but I just can't get it to work...
Im trying to make a simple menu which gives you 25 hp if you click the button, but when i click it it says attempt to call global 'RemoveScrapMetal' (a nil value). Im trying to link it with the GoldenForge shop so it removes 5 coins when you buy it.
[lua]function WeaponSelectorDerma(ply)
local WeaponFrame = vgui.Create("DFrame")
WeaponFrame:SetSize(120, 250)
WeaponFrame:Center()
WeaponFrame:SetTitle("Awesome Menu")
WeaponFrame:SetDraggable(true)
WeaponFrame:SetSizable(false)
WeaponFrame:ShowCloseButton(true)
WeaponFrame:MakePopup()
local HealthButton = vgui.Create("DButton", WeaponFrame)
HealthButton:SetSize(100, 30)
HealthButton:SetPos(10, 35)
HealthButton:SetText("Give 25 HP")
HealthButton.DoClick = function() ply:SetHealth(25) then
ply:RemoveScrapMetal(5, "You recieved your 25 HP and lost 5 coins!") WeaponFrame:Close() end
end
concommand.Add("Menu", WeaponSelectorDerma) --make the console command to make this menu popup[/lua]
Any help is appreciated.
[QUOTE=craigy09;38310120]Im trying to make a simple menu which gives you 25 hp if you click the button, but when i click it it says attempt to call global 'RemoveScrapMetal' (a nil value). Im trying to link it with the GoldenForge shop so it removes 5 coins when you buy it.
[lua]function WeaponSelectorDerma(ply)
local WeaponFrame = vgui.Create("DFrame")
WeaponFrame:SetSize(120, 250)
WeaponFrame:Center()
WeaponFrame:SetTitle("Awesome Menu")
WeaponFrame:SetDraggable(true)
WeaponFrame:SetSizable(false)
WeaponFrame:ShowCloseButton(true)
WeaponFrame:MakePopup()
local HealthButton = vgui.Create("DButton", WeaponFrame)
HealthButton:SetSize(100, 30)
HealthButton:SetPos(10, 35)
HealthButton:SetText("Give 25 HP")
HealthButton.DoClick = function() ply:SetHealth(25) then
ply:RemoveScrapMetal(5, "You recieved your 25 HP and lost 5 coins!") WeaponFrame:Close() end
end
concommand.Add("Menu", WeaponSelectorDerma) --make the console command to make this menu popup[/lua]
Any help is appreciated.[/QUOTE]
It's saying that RemoveScrapMetal is not a real function, we can't help you without the code for that...
[QUOTE=Zyler;38308331]ShouldCollide doesn't seem to be called AT ALL in my script. I know the hook has some infamy as being rather unstable when used for anything but basic return true/return false statements, but the peculiar thing is that it's been working up until the latest gmod update and now it doesn't even seem to be being called no matter what I do.
shared.lua:
[lua]local function PhysgunProtection(ply, ent)
if ent:IsWeapon() == false then
ent:SetCollisionGroup(2)
ent:DrawShadow(false)
timer.Create( "MakePropNormal", 4 , 1, function()
propphysmarked = ent
timer.Create("MakePropNormal2", 0.1, 1, function()
if ent == propphysmarked then
--propphysmarked.MakeNoCollided = 1
ent:SetCollisionGroup(0)
timer.Create("MakePropNormal2.1", 0.1, 1 , function()
ent:SetCollisionGroup(2)
timer.Create("MakePropNormal2.3", 0.5, 1 , function()
ent:SetCollisionGroup(0)
--propphysmarked.MakeNoCollided = 0
ent:DrawShadow(true)
end )
end )
end
end )
end )
end
end
local function PropRepulsion( ent1, ent2)
print("working2")
if ent1:IsWorld() != true then
print("working1")
if ent2:IsWorld() != true then
print("working2")
if ent1 == propphysmarked then
print("working3")
--if ent1.MakeNoCollided == 1 then
print("working4")
timer.Create("MakePropNormal3", 0.1, 1, function()
ent2:SetVelocity(Vector(0,0,500))
print("working5")
end )
end
elseif ent2 == propphysmarked then
print("working6")
--if ent2.MakeNoCollided == 1 then
print("working7")
timer.Create("MakePropNormal4", 0.1, 1, function()
ent1:SetVelocity(Vector(0,0,500))
print("working8")
end )
end
end
end
hook.Add( "PhysgunDrop", "Physgun Item Ghosting", PhysgunProtection)
hook.Add("ShouldCollide","Player/Prop Protection and Repulsion", PropRepulsion)[/lua]
There may be a better way to do this. I'm trying to make it so that when you drop an entity with the physgun it's collision group changes to make it no collided with everything. Then, after a certain amount of time, everything stuck inside the entity is thrown out and it becomes solid again.
I don't get "working2" printed in the console either for the player or on the RCON of my dedicated server, that's why I think it isn't being called
PS. I know my tabbing is terrible.[/QUOTE]
Just bumping this in case no one sees it
[QUOTE=spykr;38310337]It's saying that RemoveScrapMetal is not a real function, we can't help you without the code for that...[/QUOTE]
Well im trying to link it with the goldenforge shop which uses that command to take coins/scrap metal.
How would i go about that?
I'm having problems with:
[LUA]function PPT.RES.CanPhysgunEnt( ply, ent )
--if ply:IsSuperAdmin() then return true end
if not IsValid( ent.Owner ) then return false end
if ply == ent.Owner or table.HasValue( ent.Owner.Friends, ply ) then
print( ent.Owner:Nick() ) --TESTING
return true
else return false end
end[/LUA]
Error: "attempt to index field 'Owner' (a nil value)"
Where I'm setting owner:
[LUA]-- Used for setting the owner --
hook.Add( "PlayerSpawnedProp", "PPTPropSpawned", function( ply, mdl, ent )
ent.Owner = ply
end )[/LUA]
They aren't in the same file. It works on SP but not on MP, anyone know what's going on and what I have to do to fix it?
How to make angle follow another angle and add something to it?
[lua]
local SomeAngle = Angle(0,0,0)
SomeAngle.r = 30
local RealPos, RealAngle = WorldToLocal(Vector(0,0,0), SomeAngle, ent:GetPos(), ent:GetAngles())
GhostEntity:SetAngles( RealAngle )
[/lua]
Does not work well.
How exactly is ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND used? I'm trying to make a crowbar do this animation on right-click, but it doesn't work at all.
I'm just using self.Owner:SetAnimation( ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND ) but nothing happens.
How do I setup the gamemode folder? So far it's like this:
[url]http://prntscr.com/iwy4t[/url]
I'm not really sure where I am supposed to add the shared or init.lua files.
[QUOTE=Matt W;38300650]Is there a way to use ACT_ animations on ClientsideModels?[/QUOTE]
[QUOTE=All0utWar;38311137]How do I setup the gamemode folder? So far it's like this:
[url]http://prntscr.com/iwy4t[/url]
I'm not really sure where I am supposed to add the shared or init.lua files.[/QUOTE]
Add a logo.png which should be 128px high and up to 1024px wide (goes on top of the menu) and a logo24.png which should be 24x24 and goes in the bottom right corner gamemode selector on the menu.
All lua goes into a "gamemode" folder next to info.txt (which should be the same name as your gamemode folder, in this case "shootsandpoops.txt"), and all content (fonts, textures, models, sounds, etc) go into a "content" folder also right next to info.txt.
Hello, I still got this error:
[ERROR] --- attempt to index local 'pl' (a nil value)
[LUA]function GM:SetPlayerSpeed(pl, walk)
pl.WalkSpeed = walk --Here--
pl:SetWalkSpeed(walk)
pl:SetRunSpeed(walk)
end[/LUA]
Another problem:
[ERROR] --- attempt to index a nil value
[LUA]function GM:ZombieHUD(MySelf)
local entityhealth = math.max(MySelf:Health(), 0)
local maxhealth = ZombieClasses[MySelf.Class].Health --Here--
local percenthealth = entityhealth / maxhealth
...[/LUA]
Anyone how to fix it? Thanks for any ideas.
Is there a way to make an ent non-physable?
Also, I'm beginning to think it might be better to just rebuild WM from scratch.
I've found that one of the tools just crashes the game outright.
pData->type!=m_type is 10 != 11 (Angle)
How would you go about creating a function to check if a player has moved for a certain period of time, Like if a player moved in the last 3 seconds, return false
How do you use the new network library's AddNetworkString function?
I have util.AddNetworkString( "ShopItems" ) in my init.lua
and it throws
[ERROR] addons/mod2/lua/pointmod/init.lua:8: attempt to call global 'AddNetworkString' (a nil value)
I copied that right off of the wiki, so am I just doing it wrong?
[QUOTE=Ghost_Sailor;38315661]How do you use the new network library's AddNetworkString function?
I have util.AddNetworkString( "ShopItems" ) in my init.lua
and it throws
[ERROR] addons/mod2/lua/pointmod/init.lua:8: attempt to call global 'AddNetworkString' (a nil value)
I copied that right off of the wiki, so am I just doing it wrong?[/QUOTE]
If your code is util.AddNetworkString then you wouldn't be getting an error about the GLOBAL function AddNetworkString
So I'm trying to figure out how to use stencils to give every brush a certain material, but every stencil example I've found, they all call an entities draw function, but I don't think you can do that with GetWorldEntity()?
Pretty much I just can't figure out the high wizardry that is stencils. I've read a ton of threads on them but I still don't understand it. Anyone have any thoughts?
[QUOTE=Drakehawke;38315675]If your code is util.AddNetworkString then you wouldn't be getting an error about the GLOBAL function AddNetworkString[/QUOTE]
My code is "util.AddNetworkString( "ShopItems" )" on line 8. There are no references to it anywhere else, and there are no functions called that. I don't know what I'm doing wrong here.
[QUOTE=Feihc;38315802]So I'm trying to figure out how to use stencils to give every brush a certain material, but every stencil example I've found, they all call an entities draw function, but I don't think you can do that with GetWorldEntity()?[/QUOTE]
I am not sure what are you trying to accomplish, but this might help you: render.BrushMaterialOverride ( Currently undocumented, and not used anywhere, but I heard it works like render.MaterialOverride )
[editline]4th November 2012[/editline]
About stencils, check out Overvs tutorial here: [URL]http://open.gl/depthstencils[/URL]
[QUOTE=MDave;38316128]I am not sure what are you trying to accomplish, but this might help you: render.BrushMaterialOverride ( Currently undocumented, and not used anywhere, but I heard it works like render.MaterialOverride )
[editline]4th November 2012[/editline]
About stencils, check out Overvs tutorial here: [URL]http://open.gl/depthstencils[/URL][/QUOTE]
Aha, I didn't see garry added that. Thanks. Now if I can just figure out how to use it :|
[QUOTE=Ghost_Sailor;38315853]My code is "util.AddNetworkString( "ShopItems" )" on line 8. There are no references to it anywhere else, and there are no functions called that. I don't know what I'm doing wrong here.[/QUOTE]
That error would only happen if you had the code
AddNetworkString( "ShopItems" )
I'm having an issue with [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4bfa.html"]Parenting[/URL].
It always turns out like this and i'm pretty sure I have to parent it. I'm using TTT's DeerStalker hat as an example template.
[IMG]http://cloud-2.steampowered.com/ugc/560956744516747508/60FB3A9A3E4671BC822F0D4166D7CCADCECB503B/[/IMG]
[lua]
function WearHat(self, cmd, args)
if IsValid(self) then
local hat = ents.Create(arg1)
if not IsValid(hat) then return end
hat:SetPos(self:GetPos() + Vector(0,0,70))
hat:SetAngles(self:GetAngles())
hat:SetParent(self)
self.hat = hat
hat:Spawn()
self:SaveHats()
end
end
concommand.Add("self_wear_hat", WearHat)
[/lua]
Thanks.
So I'm trying to figure out something. I need a way of finding out whether or not an entity took damage from the player. I thought about using EntityTookDamage() but Garry removed the attacker argument. Is their a method like if Ply:DealtDamage() or something?
[QUOTE=DoubleElite;38316729]So I'm trying to figure out something. I need a way of finding out whether or not an entity took damage from the player. I thought about using EntityTookDamage() but Garry removed the attacker argument. Is their a method like if Ply:DealtDamage() or something?[/QUOTE]
Use EntityTakeDamage, to get the attacker use dmginfo:GetAttacker()
Repost since I was at the bottom..
I'm having an issue with [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4bfa.html"]Parenting[/URL].
It always turns out like this and i'm pretty sure I have to parent it. I'm using TTT's DeerStalker hat as an example template.
[IMG]http://cloud-2.steampowered.com/ugc/560956744516747508/60FB3A9A3E4671BC822F0D4166D7CCADCECB503B/[/IMG]
[lua]
function WearHat(self, cmd, args)
if IsValid(self) then
local hat = ents.Create(arg1)
if not IsValid(hat) then return end
hat:SetPos(self:GetPos() + Vector(0,0,70))
hat:SetAngles(self:GetAngles())
hat:SetParent(self)
self.hat = hat
hat:Spawn()
self:SaveHats()
end
end
concommand.Add("self_wear_hat", WearHat)
[/lua]
Thanks.
Sorry, you need to Log In to post a reply to this thread.