[QUOTE=Blakestr;48867516]Seriously shouldn't need its own thread...
I'm trying to make my character invisible to others (and his weapons)
When I use any iteration of SetColor or SetWeapon color, it works but my weapons are GONE. I try cycling through them but when I respawn (that's the function command) my weapons are gone. (i had a camera so i verified I was invisible)
[CODE]function GM:PlayerSpawn( ply )
ply:SetColor( Vector( 0, 0, 1 ) )
ply:SetRenderMode(RENDERMODE_TRANSALPHA)
end[/CODE][/QUOTE]
The issue is that PlayerSpawn is used to call PlayerLoadout which gives weapons to the player. And you are overriding it. Unless you are going to make a custom gamemode you should use hook.Add. If you are doing so you should call the PlayerLoadout hook in PlayerSpawn.
[QUOTE=Dinnanid;48867636]The issue is that PlayerSpawn is used to call PlayerLoadout which gives weapons to the player. And you are overriding it. Unless you are going to make a custom gamemode you should use hook.Add. If you are doing so you should call the PlayerLoadout hook in PlayerSpawn.[/QUOTE]
I'm not sure how to call that though...
[CODE]hook.Call (PlayerLoadout, Playerspawn) ??? [/CODE]
[QUOTE=Blakestr;48867774]I'm not sure how to call that though...
[CODE]hook.Call (PlayerLoadout, Playerspawn) ??? [/CODE][/QUOTE]
[URL="http://wiki.garrysmod.com/page/hook/Add"]hook.Add[/URL] (Instead of function GM:...)
[QUOTE=Blakestr;48867774]I'm not sure how to call that though...
[CODE]hook.Call (PlayerLoadout, Playerspawn) ??? [/CODE][/QUOTE]
[QUOTE]Line 274 of gamemodes/base/gamemode/player.lua
[CODE]hook.Call( "PlayerLoadout", GAMEMODE, pl )[/CODE][/QUOTE]
[QUOTE=Blakestr;48867774]I'm not sure how to call that though...
[CODE]hook.Call (PlayerLoadout, Playerspawn) ??? [/CODE][/QUOTE]
[CODE]hook.Add("PlayerLoadout", "SomeUniqueName", function( ply )
-- Code Here
end)[/CODE]
[QUOTE=Dinnanid;48867636]The issue is that PlayerSpawn is used to call PlayerLoadout which gives weapons to the player. And you are overriding it. Unless you are going to make a custom gamemode you should use hook.Add. If you are doing so you should call the PlayerLoadout hook in PlayerSpawn.[/QUOTE]
I am making a custom gamemode so does that change things? It has its own gamemode folder and everything (based off sandbox)
[QUOTE=Blakestr;48867896]I am making a custom gamemode so does that change things? It has its own gamemode folder and everything (based off sandbox)[/QUOTE]
You can still use hook.Add(). As far as I know, overriding the gamemode function doesn't have any benefits over hook.Add() (other than overriding the default function, duh).
[QUOTE=roastchicken;48867987]You can still use hook.Add(). As far as I know, overriding the gamemode function doesn't have any benefits over hook.Add() (other than overriding the default function, duh).[/QUOTE]
For what he needs this is definitely the easiest way to go. I just tend to overwrite the base functions because they have extraneous things that I don't want when making a full fledged gamemode.
[QUOTE=Dinnanid;48868060]For what he needs this is definitely the easiest way to go. I just tend to overwrite the base functions because they have extraneous things that I don't want when making a full fledged gamemode.[/QUOTE]
Last question for the next 5 minutes...if I call PlayerLoadout that will give me whatever the default load out is..
[QUOTE=Blakestr;48868147]Last question for the next 5 minutes...if I call PlayerLoadout that will give me whatever the default load out is..[/QUOTE]
Im pretty sure if you state return false at the end it disables the default ? I think i saw it somewhere.
[QUOTE=Cheese_3;48868190]Im pretty sure if you state return false at the end it disables the default ? I think i saw it somewhere.[/QUOTE]
You need to return true in order to prevent default Loadout.
[url]http://wiki.garrysmod.com/page/GM/PlayerLoadout[/url]
my grenade does not want to work
[code]function ENT:Initialize()
self:SetModel(self.Model)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
timer.Simple(1, function()
if SERVER then
for k, target in pairs(self.FindInSphere(self:GetPos(), 500)) do
if IsValid(target) then
target:ConCommand("r_screenoverlay models/screenspace")
target:Kill()
self:Remove()
end
end
end
end)
end
[/code]
[code][ERROR] gamemodes/terrortown/entities/entities/ttt_scarenade_proj.lua:17: attempt to call field 'FindInSphere' (a nil value)
1. unknown - gamemodes/terrortown/entities/entities/ttt_scarenade_proj.lua:17
Timer Failed! [Simple][@gamemodes/terrortown/entities/entities/ttt_scarenade_proj.lua (line 15)]
[/code]
No clue why it isn't working
[QUOTE=343N;48870457]:snip:
No clue why it isn't working[/QUOTE]
You need to do ents.FindInSphere, not self.FindInSphere, and what are you trying to do with the screenspace bit?
Try this:
[CODE]
function ENT:Initialize()
self:SetModel(self.Model) --MAKE SURE TO DEFINE THIS
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
timer.Simple(1, function()
if SERVER then -- A server check halfway through the script seems a bit dodgy to me
for k, target in pairs(self.FindInSphere(self:GetPos(), 500)) do
if IsValid(target) and target ~= self then
target:Kill()
self:Remove()
end
end
end
end)
end
[/CODE]
oh just testing running screen overlays on players that's all
and I have another problem!
my phys objects material does not change (e.g i want it to have flesh impact sounds but it refuses to change and stays on the props default)
the code in question
[code]function ENT:Initialize()
self:SetModel(self.Model)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetMaterial("effects/prisonmap_disp")
self:SetCollisionGroup(COLLISION_GROUP_WORLD)
self:EmitSound("ambient/machines/teleport1.wav")
phys = self:GetPhysicsObject()
phys:SetMass(60000)
if SERVER then
self:SetMaxHealth(4000)
end
self:SetHealth(4000)
if SERVER then
self:SetUseType(SIMPLE_USE)
end
if SERVER then
ff = ents.Create("prop_physics")
ff:SetModel("models/hunter/tubes/tube4x4x4.mdl")
ff:SetMaterial("models/props_combine/portalball001_sheet")
ff:PhysicsInit(SOLID_VPHYSICS)
ff:SetSolid(SOLID_VPHYSICS)
ff:SetCollisionGroup(COLLISION_GROUP_WORLD)
ff:SetPos(self:GetPos())
ff:SetParent(self)
fphys = ff:GetPhysicsObject()
fphys:SetMaterial("flesh")
sound.Add({
name = "forcefieldloop",
channel = "CHAN_AUTO",
volume = 0.3,
pitch = {95,105},
sound = ("ambient/machines/combine_shield_touch_loop1.wav")
})
self:EmitSound("forcefieldloop")
end
-- dlight = DynamicLight( dlightindexid + 1 )
-- dlight.pos = self.GetPos()
-- dlight.r = 100
-- dlight.g = 100
-- dlight.b = 255
--- dlight.brightness = 2
-- dlight.Size = 256
-- Register with owner``
end[/code]
i hope i'm not like, bloating the thread :)
[QUOTE=343N;48870731]-snip-[/QUOTE]
Please add proper spacing before posting walls of code.
I think you should do a serverside check across ALL your ENT:Initialize() function rather than just segments of it
[editline]10th October 2015[/editline]
Also, I have a problem- on the wiki there's a great example of a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Derma_Anim]Global.Derma_Anim[/url] (the function called inQuad), but since I'm terrible at math and I'd really like some different transitional animation functions like that one, does anyone know some sort of site/place where I can find some? I've seen them used in a lot of UI's on this thread... at least I think...
[QUOTE=tzahush;48870836]Please add proper spacing before posting walls of code.[/QUOTE]
proper spacing?
i dont know how to properly space my code
Basically anything that is not one word shouldn't be one word.
Any "(" "{" should have a space after it (And ")" "}" should have a space before it), along with commas and arithmetic functions
[QUOTE=UnknownFusion;48870962]
[CODE]local function Health()
local Health = LocalPlayer():Health() or 0
local FullHealth = LocalPlayer():Health() or 0
if Health < 0 then Health = 0 elseif Health > 100 then Health = 100 end
local DrawHealth = math.Min(Health/GAMEMODE.Config.startinghealth, 1)
draw.RoundedBox(6, HUD.PosX+370, HUD.PosY-10, 50, 120, Color(30,30,30,110))
if Health != 0 then
draw.RoundedBox(6, HUD.PosX+375, HUD.PosY-5, (40) * DrawHealth, 110, HUD.HealthColor)
end
draw.DrawText(FullHealth, "BebasNeue",HUD.PosX + 394, HUD.PosY+79,Color(255, 255, 255, 255), TEXT_ALIGN_CENTER)
end[/CODE]
[/QUOTE]
The line:
[CODE]
draw.RoundedBox(6, HUD.PosX+375, HUD.PosY-5, (40) * DrawHealth, 110, HUD.HealthColor)
[/CODE]
Draw.RoundedBox has it's args like this:
[CODE]
draw.RoundedBox( cornerRadius, x, y, w, h, color )
[/CODE]
You're changing the WIDTH of the panel with (40) * DrawHealth. Change that so it changes the 110 instead
[QUOTE=JasonMan34;48871011]Basically anything that is not one word shouldn't be one word.
Any "(" "{" should have a space after it (And ")" "}" should have a space before it), along with commas and arithmetic functions[/QUOTE]
i code without spaces after parentheses. you're making a big deal out of something that shouldn't be. if i were to make a big deal out of anything, it would be the lack of proper tabbing.
[QUOTE=UnknownFusion;48871033]I did that, but now it goes from the bottom to the top, instead of the top to the bottom, thanks in advance[/QUOTE]
apply same modifier to Y-position except add instead of subtract.
[QUOTE=JasonMan34;48871011]Basically anything that is not one word shouldn't be one word.
Any "(" "{" should have a space after it (And ")" "}" should have a space before it), along with commas and arithmetic functions[/QUOTE]
[QUOTE=tzahush;48870836]Please add proper spacing before posting walls of code.[/QUOTE]
[code]function ENT:Initialize()
self:SetModel( self.Model )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetMaterial( "effects/prisonmap_disp" )
self:SetCollisionGroup( COLLISION_GROUP_WORLD )
self:EmitSound( "ambient/machines/teleport1.wav" )
phys = self:GetPhysicsObject()
phys:SetMass( 60000 )
if SERVER then
self:SetMaxHealth( 4000 )
end
self:SetHealth( 4000 )
if SERVER then
self:SetUseType( SIMPLE_USE )
end
if SERVER then
ff = ents.Create( "prop_physics" )
ff:SetModel( "models/hunter/tubes/tube4x4x4.mdl" )
ff:SetMaterial( "effects/com_shield003a" )
ff:PhysicsInit( SOLID_VPHYSICS )
ff:SetSolid( SOLID_VPHYSICS )
ff:SetCollisionGroup( COLLISION_GROUP_WORLD )
ff:SetPos( self:GetPos() )
ff:SetParent( self )
fphys = ff:GetPhysicsObject()
fphys:SetMaterial( "glass" ) --this isnt changing the material, this is what i want to fix
sound.Add( {
name = "forcefieldloop",
channel = "CHAN_AUTO",
volume = 0.3,
pitch = { 95,105 },
sound = ( "ambient/machines/combine_shield_touch_loop1.wav" )
} )
self:EmitSound( "forcefieldloop" )
end
-- dlight = DynamicLight( dlightindexid + 1 )
-- dlight.pos = self.GetPos()
-- dlight.r = 100
-- dlight.g = 100
-- dlight.b = 255
--- dlight.brightness = 2
-- dlight.Size = 256
-- Register with owner``
end[/code]
there
One of my ulx features is kinda weird but working.
The !trainfuck "player to target"
To explain, if i do the cmd while the player is on the ground, the train goes into the ground and spazzes then freeze. (It works well if the player is in mid-air)
Second problem, the train doesn't self remove after somes seconds.
And third problem, it spawns on the right side of the player instead of front side.
Here's the code:
[Lua]function SpawnTrain( Pos, Direction )
local train = ents.Create( "prop_physics" )
train:SetModel("models/props_trainstation/train001.mdl")
train:SetAngles( Direction:Angle() )
train:SetPos( Pos )
train:Spawn()
train:Activate()
train:EmitSound( "ambient/alarms/train_horn2.wav", 100, 100 )
train:GetPhysicsObject():SetVelocity( Direction * 100000 )
timer.Create( "TrainRemove_"..CurTime(), 5, 1, function( train ) train:Remove() end, train )
end
function ulx.trainfuck( calling_ply, target_plys )
for _, pl in ipairs( target_plys, calling_ply ) do
local Hp = pl:Health()
local Dif = Hp - 1
local HpOut = Hp - Dif
local HpSur = Hp + Dif
pl:SetMoveType( MOVETYPE_WALK )
pl:GodDisable()
pl:SetHealth(HpOut)
SpawnTrain( pl:GetPos() + pl:GetForward() * 500 + Vector(0,0,50), pl:GetForward() * -1 )
pl:GodDisable()
pl:SetMoveType( MOVETYPE_WALK )
timer.Create( "trainKillNot_", 6.5, 1, function( target_plys )
if pl:Alive() then pl:SetHealth(HpSur) else end
end )
end
ulx.fancyLogAdmin( calling_ply, "#A trainfucked #T", target_plys )
end
local trainfuck = ulx.command( "Fun", "ulx trainfuck", ulx.trainfuck, "!trainfuck" )
trainfuck:addParam{ type=ULib.cmds.PlayersArg }
trainfuck:defaultAccess( ULib.ACCESS_ADMIN )
trainfuck:help( "Fuck a player with a train." )[/lua]
I asked this before, but I'd really like an answer- where can I find some functions that'd work with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Derma_Anim]Global.Derma_Anim[/url] like the inQuad function in the example on the page of it?
very quick question, how would I get the Z of a vector? I want to get the tr.HitPos(x,y,z) but only the z value, nothing else
[QUOTE=343N;48871481]very quick question, how would I get the Z of a vector? I want to get the tr.HitPos(x,y,z) but only the z value, nothing else[/QUOTE]
tr.HitPos.z
this is only affecting one player, not every player in the radius
[code] for k, v in pairs(ents.FindInSphere(self:GetPos(), 256)) do
if IsValid(v) then
models = {
("models/alyx/alyx_faceandhair"),
("models/gman/gman_facehirez"),
("models/humans/male/group01/mike_facemap")}
face = table.Random(models)
v:ConCommand("r_screenoverlay "..face)
self:EmitSound("npc/fast_zombie/fz_scream1.wav", 500, math.random(30,100), 1, CHAN_AUTO)
v:Freeze(true)
timer.Simple(2, function()
v:ConCommand("r_screenoverlay 0")
v:Freeze(false)
end)
end[/code]
[QUOTE=Nekomi;48871359]One of my ulx features is kinda weird but working.
The !trainfuck "player to target"
To explain, if i do the cmd while the player is on the ground, the train goes into the ground and spazzes then freeze. (It works well if the player is in mid-air)
Second problem, the train doesn't self remove after somes seconds.
And third problem, it spawns on the right side of the player instead of front side.
Here's the code:
[Lua]function SpawnTrain( Pos, Direction )
local train = ents.Create( "prop_physics" )
train:SetModel("models/props_trainstation/train001.mdl")
train:SetAngles( Direction:Angle() )
train:SetPos( Pos )
train:Spawn()
train:Activate()
train:EmitSound( "ambient/alarms/train_horn2.wav", 100, 100 )
train:GetPhysicsObject():SetVelocity( Direction * 100000 )
timer.Create( "TrainRemove_"..CurTime(), 5, 1, function( train ) train:Remove() end, train )
end
function ulx.trainfuck( calling_ply, target_plys )
for _, pl in ipairs( target_plys, calling_ply ) do
local Hp = pl:Health()
local Dif = Hp - 1
local HpOut = Hp - Dif
local HpSur = Hp + Dif
pl:SetMoveType( MOVETYPE_WALK )
pl:GodDisable()
pl:SetHealth(HpOut)
SpawnTrain( pl:GetPos() + pl:GetForward() * 500 + Vector(0,0,50), pl:GetForward() * -1 )
pl:GodDisable()
pl:SetMoveType( MOVETYPE_WALK )
timer.Create( "trainKillNot_", 6.5, 1, function( target_plys )
if pl:Alive() then pl:SetHealth(HpSur) else end
end )
end
ulx.fancyLogAdmin( calling_ply, "#A trainfucked #T", target_plys )
end
local trainfuck = ulx.command( "Fun", "ulx trainfuck", ulx.trainfuck, "!trainfuck" )
trainfuck:addParam{ type=ULib.cmds.PlayersArg }
trainfuck:defaultAccess( ULib.ACCESS_ADMIN )
trainfuck:help( "Fuck a player with a train." )[/lua][/QUOTE]
For the position stuff I have no idea, I can try to test it with different vectors but honestly angles and vectors still confuse the shit out of me.
The one problem I can help you with though, is your function. First of all, you're passing a fifth argument "train" to timer.Create. I'm not sure why this isn't giving an error, but according to the wiki timer.Create only takes four arguments, the last one being the function to be called.
The fifth argument doesn't seem to do anything, but you also have an argument for the function that is called. timer.Create doesn't pass any arguments to the function it calls, it just calls it. Since the argument train is declared in the function, whereas the actual train entity is declared outside of the function, then the train argument will be used when you refer to train. Since the argument is nil, the Remove() will do nothing. If you remove the argument from the function in timer.Create then the train should be removed.
So I am working on the begineer Lua challange of creating a betting system. I don't really like command based stuff, that's why I would like to have a panel for it.
My code:
[CODE]local function ChatCommand( ply, text, public )
if ( string.sub(text, 1, 4) == "!bet" ) then
frame:SetVisible( true )
end
end
local function BetFrame()
local frame = vgui.Create( "DFrame" )
frame:SetPos( 100, 100 )
frame:SetSize( 300, 200 )
frame:SetTitle( "Bet Panel" )
frame:SetDraggable( true )
end
hook.Add( "PlayerSay", "ChatCommand", ChatCommand )[/CODE]
The error (blue):
[CODE]
[ERROR] addons/bet system/lua/autorun/bet_system.lua:3: attempt to index global 'frame' (a nil value)
1. v - addons/bet system/lua/autorun/bet_system.lua:3
2. unknown - lua/includes/modules/hook.lua:84
[/CODE]
[QUOTE=Astr0niiX;48872022]So I am working on the begineer Lua challange of creating a betting system. I don't really like command based stuff, that's why I would like to have a panel for it.
My code:
[CODE]local function ChatCommand( ply, text, public )
if ( string.sub(text, 1, 4) == "!bet" ) then
frame:SetVisible( true )
end
end
local function BetFrame()
local frame = vgui.Create( "DFrame" )
frame:SetPos( 100, 100 )
frame:SetSize( 300, 200 )
frame:SetTitle( "Bet Panel" )
frame:SetDraggable( true )
end
hook.Add( "PlayerSay", "ChatCommand", ChatCommand )[/CODE]
The error (blue):
[CODE]
[ERROR] addons/bet system/lua/autorun/bet_system.lua:3: attempt to index global 'frame' (a nil value)
1. v - addons/bet system/lua/autorun/bet_system.lua:3
2. unknown - lua/includes/modules/hook.lua:84
[/CODE][/QUOTE]
Your variable 'frame' is a local variable. It is declared in the BetFrame function. Local variables can only be accessed within the block that they were declared. In this case, frame was declared in BetFrame so it can only be accessed within BetFrame.
[QUOTE=343N;48871618]Odd code[/QUOTE]
What are you trying to do exactly?
Sorry, you need to Log In to post a reply to this thread.