[QUOTE=bobbleheadbob;47172528][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerBindPress]GM/PlayerBindPress[/url] hook. I forget the convar for the context menu, type "bind c" in the console and it will tell you the command.[/QUOTE]
Right so I get this error
[lua]
[ERROR] lua/includes/extensions/client/panel.lua:579: Tried to use invalid object (type Panel) (Object was NULL or not of the right type)
1. SetVisible - [C]:-1
2. Show - lua/includes/extensions/client/panel.lua:579
3. plrMdlGui - gamemodes/shooter/gamemode/cl_init.lua:63
4. unknown - gamemodes/shooter/gamemode/cl_init.lua:75
[/lua]
after using this code:
[lua]
function plrMdlGui()
frame:Show()
end
function noPlrMdlGui()
frame:Hide()
end
function GM:PlayerBindPress( ply, bind, pressed )
--To block more commands, you could add another line similar to
--the one below, just replace the command
if ( string.find( bind, "menu_context" ) ) then
if pressed then
plrMdlGui()
else
noPlrMdlGui()
end
end
end
[/lua]
What's wrong now?
[lua]function plrMdlGui()
frame:Show()
end
function noPlrMdlGui()
frame:Hide()
end[/lua]
frame is nil/NULL. Have a check before you try to use it.
[lua]if ( not frame ) then return end
if ( not frame:IsPanel( ) ) then return end[/lua]
[B]EDIT:[/B] I did this to the code mentioned below at line 34:
[LUA]
frame = vgui.Create( "DFrame" )
frame:Center()
frame:SetSize( ScrW(), ScrH() )
frame:SetTitle( "Player Model" )
frame:SetDraggable( true )
frame:SetWorldClicker( false )
frame:SetDeleteOnClose( false )
frame:Hide()
[/LUA]
Now my game displays it, but doesn't hide it when I stop holding and looks weird, like this:
[url]http://imgur.com/2AROImq[/url]
[QUOTE=Author.;47172672][lua]function plrMdlGui()
frame:Show()
end
function noPlrMdlGui()
frame:Hide()
end[/lua]
frame is nil. frame is nothing. Have a check for it before you try to Hide it.[/QUOTE]
FYI, I did define the frame at line 34 (that code's at 62):
[LUA]
frame = vgui.Create( "DFrame" )
frame:Center()
frame:SetSize( ScrW(), ScrH() )
frame:SetTitle( "Player Model" )
frame:SetDraggable( true )
frame:SetWorldClicker( true )
frame:Close()
frame:SetDeleteOnClose( false )
[/LUA]
And after doing this to that code you quoted:
[LUA]
function plrMdlGui()
if frame then
frame:Show()
end
end
function noPlrMdlGui()
if frame then
frame:Hide()
end
end
[/LUA]
I get this error:
[LUA]
[ERROR] lua/includes/extensions/client/panel.lua:579: Tried to use invalid object (type Panel) (Object was NULL or not of the right type)
1. SetVisible - [C]:-1
2. Show - lua/includes/extensions/client/panel.lua:579
3. plrMdlGui - gamemodes/shooter/gamemode/cl_init.lua:64
4. unknown - gamemodes/shooter/gamemode/cl_init.lua:79
[/LUA]
Seems to be the same no matter how many times I change it. Weird huh? :rolleyes:
[QUOTE=ROFLBURGER;47168788]I need help with logic
I'm using the CreateMove hook and I'm trying to make it so it takes away stamina if you jump.
so far I have
[code]
if cmd:KeyDown(IN_JUMP) and ply:OnGround() then
--do shit
end
[/code]
But it takes away stamina if you're holding down the spacebar and you're still on the ground. I tried a bunch of combination with latches but it doesn't work, I'm still trying.[/QUOTE]
I know you've already received one or so answers but I have a base stamina system set up with a few of those options in place so here's another variant to help you or anyone else:
Basic: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/basic_stamina_system/sh_basic_stamina_system.lua.html[/url]
Extended: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/basic_stamina_system/sh_extended_stamina_system.lua.html[/url]
Remove .html for .lua
[editline]19th February 2015[/editline]
[QUOTE='[CLRP]extra;47170730']Quick question. If I looped a colour table which was laid out like:
How would I make a value the colors in that table? I tried col = v.r,v.g,v.b and it says 'attempt to index a number value'.[/QUOTE]
If it's only 1 color, use Color( _color.r, _color.g, _color.b, _color.a ); instead of the loop.
Also, the reason for your error is because you're using the "assign multiple variables on one line" syntax... You'd need to do something like: local r, g, b, a = _color.r, _color.g, _color.b, _color.a; for that to work... Then Color( r, g, b, a );
[QUOTE=Acecool;47173052]
Also, the reason for your error is because you're using the "assign multiple variables on one line" syntax... You'd need to do something like: local r, g, b, a = _color.r, _color.g, _color.b, _color.a; for that to work... Then Color( r, g, b, a );[/QUOTE]
the reason for his error is because he's attempting to index v, which is a number
[QUOTE=figgycity50;47172712]Seems to be the same no matter how many times I change it. Weird huh? :rolleyes:[/QUOTE]
could be because you're calling :Close() before :SetDeleteOnClose(false), but it looks like you want :SetVisible(false) instead
also, please don't make everything global like that, that's really bad
Is there a command to check if the player has fully joined the server ie the guy can move around and see what's going on?
I'm looking at the PlayerConnect hook but im not sure if that means it's called the instant a connection is received from the server
theres also Player:IsConnected( ) but im not sure if that's the same thing
[QUOTE=buu342;47170506]
Door entity
Door Menu Code
I think I might just screw using Nick() completely.[/QUOTE]
Yeah no idea why you're using nick. Also pretty sure you had inconsistent indices or something I forgot now. how about this approach:
Door entity:
[lua]
function ENT:Think()
if self.SetNW then return end -- inverse logic
if IsValid(self:GetOwner()) and self:GetOwner():IsPlayer() then -- i don't care enough here for inverse logic
self.SetNW = true
if not self.Owners then self.Owners = {count = 0} end
if not self.Owners[self:GetOwner()] then
self.Owners[self:GetOwner()] = true
self.Owners.count = self.Owners.count + 1 -- replacement for using #table
end
end
end
net.Receive("PleaseUseAUniquePrefix_AddOwner", function(len, ply)
if not ply:IsAdmin() then return end -- If someone had allowcslua they could run
-- net.Start("PleaseUseAUniquePrefix_AddOwner") net.WriteEntity(trace.Entity) net.WriteEntity(LocalPlayer()) net.SendToServer()
-- to add themselves to a door, might want to do more checking
local door = net.ReadEntity()
local newowner = net.ReadEntity()
door.Owners[newowner] = true
door.Owners.count = door.Owners.count + 1 -- replacement for using #table
end)
[/lua]
[lua]
local firep = vgui.Create("DButton")
firep:SetPos(padding+6, padding+26)
firep:SetParent(ps)
firep:SetText("Set Door Owners")
firep:SetSize(w - 36, 128)
firep.DoClick = function(self)
local menu = DermaMenu()
menu.found = false
local door = trace.Entity
for k, v in pairs(player.GetAll()) do
if door.Owners[v] then continue end
menu.found = true
menu:AddOption(v:Nick(), function()
net.Start("PleaseUseAUniquePrefix_AddOwner")
net.WriteEntity(door)
net.WriteEntity(v)
net.SendToServer()
door.Owners[v] = true
door.Owners.count = door.Owners.count + 1 -- replacement for using #table
end)
end
if not menu.found then
menu:AddOption("There are no other players available.") -- empty function *shouldn't be according to wiki* necessary & makes a pointless new closure
end
menu:Open()
end
[/lua]
Also might want to read my comments.
[editline]e[/editline]
Oh, sorry, the comment about the malicious net message thing is wrong because it uses my code, but if it was changed to have been LocalPlayer():Nick() it would be valid with your existing code.
I need help with some issues,
Number 1; Is there a way i could get those little icons that admins get such as a shield and iv'ed also seen other icons, but i cant seem to find them, if you can give me step by stem instructions on how to get them that would be great.
Number 2; I need to some how to get ULX groups to have the little icons of my choice, so when they are in the tab menu it will give show there icon that i listed for them.
Number 3; how do i change the groups icons or add icons.
Number 4; if you have all the answers to all my questions add me on steam BeefyBadgerr
Please add me and so we can talk thank you for reading, if you add me ill be on for another hour after this post has been made after that ill be on at 08:45 in the morning (england time) Thank you.
NOTE. one of the icons i want is the winner at the bottem of my post or this link : [url]http://www.facepunch.com/fp/ratings/winner.png[/url]
[QUOTE=ROFLBURGER;47173499]Is there a command to check if the player has fully joined the server ie the guy can move around and see what's going on?
I'm looking at the PlayerConnect hook but im not sure if that means it's called the instant a connection is received from the server
theres also Player:IsConnected( ) but im not sure if that's the same thing[/QUOTE]
the PlayerInitialSpawn hook is when the player entity is initialized. This is the first point at which a player object is considered valid.
Can a filter be drawn using textures or can they only be drawn with polygonal shapes? Like, for a generic example, perhaps I wanna cut an S out of something... as in, make that S see-through... can I use a texture with S on it? Actually, 2 questions, but my biggest curiosity is just if you can draw a filter with textures.
Can you draw a filter with TEXT?
[B][U]Can you draw a filter with the Alpha of Textures?[/U][/B]
If by "Draw a filter" you mean "Use stencils to cut pieces out of a shape" then yes you can use text and textures.
Just note that (unless they have the alphatest flag) any part of a material or which is drawn to the stencil buffer that has alpha of more than 0 will be considered completely solid.
The same goes with antialiased text.
[QUOTE=bobbleheadbob;47175868]If by "Draw a filter" you mean "Use stencils to cut pieces out of a shape" then yes you can use text and textures.
Just note that (unless they have the alphatest flag) any part of a material or which is drawn to the stencil buffer that has alpha of more than 0 will be considered completely solid.
The same goes with antialiased text.[/QUOTE]
Lol yes... I had trouble coming up with the words. Thank you VERY much!!!
Can anyone tell me any good swep tutorials for a beginner like myself?
I'd suggest it in video, if not video text form is fine
I need some help with a alert system I have, basically I want it to print to console when someone breaks a prop. It works so far but if a player breaks a generic map prop such as a vent or boards covering a hole it reports it and another issue if you break a prop with a shotgun it spams the report for every bullet that hit the prop when it was broken.
Here is my current code
[code]hook.Add( "PropBroken", "PropBroken.Alert", function(ent, attacker)
local bCooldown
if attacker:IsValid() and attacker:IsPlayer() then
if attacker:Team() == TEAM_HUMAN and not bCooldown then
bCooldown = true
PrintTranslatedMessage(HUD_PRINTCONSOLE, " "..attacker:Name().." broke prop "..ent:GetModel().." ")
timer.Simple(0.1, function() bCooldown = false end)
end
end
end )[/code]
is there any way to modify the velocity cap of phys objects? They seem to be capped at 2300u/s or something right now. Can we bend this limit?
[QUOTE=Hoffa1337;47177784]is there any way to modify the velocity cap of phys objects? They seem to be capped at 2300u/s or something right now. Can we bend this limit?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/physenv/SetPerformanceSettings]physenv.SetPerformanceSettings[/url]
[QUOTE=Fantym420;47177833][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/physenv/SetPerformanceSettings]physenv.SetPerformanceSettings[/url][/QUOTE]
thank you very much kind sir
[QUOTE=Fantym420;47177833][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/physenv/SetPerformanceSettings]physenv.SetPerformanceSettings[/url][/QUOTE]
Holy shit you just fixed a bug with the Portal Gun.
You can kinda break the game with these settings though, I made a physical bullet that modify's them, if things go too fast they fly out of the map and do very odd things.
[QUOTE=ROFLBURGER;47173499]Is there a command to check if the player has fully joined the server ie the guy can move around and see what's going on?
I'm looking at the PlayerConnect hook but im not sure if that means it's called the instant a connection is received from the server
theres also Player:IsConnected( ) but im not sure if that's the same thing[/QUOTE]
[QUOTE=bobbleheadbob;47174586]the PlayerInitialSpawn hook is when the player entity is initialized. This is the first point at which a player object is considered valid.[/QUOTE]
PlayerInitialSpawn won't work for the client because the client initializes after the server and some other options may not work either. You could use OnEntityCreated if IsValid and IsPlayer SHARED or on server then network ( but I haven't tested this so it may be the same as PlayerInitialSpawn ) but the way I do it and call PlayerFullyConnected is:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_hooks/playerfullyconnected/lua/autorun/server/sv_hook_playerfullyconnected_acecool.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_hooks/playerfullyconnected/lua/autorun/client/cl_hook_playerfullyconnected_acecool.lua.html[/url]
or using my net system:
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/hooks/playerfullyconnected/sv_gm_playerfullyconnected_logic.lua?at=master[/url]
hooks:
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/hooks/playerfullyconnected/cl_gm_playerfullyconnected.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/hooks/playerfullyconnected/sv_gm_playerfullyconnected.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/hooks/playerfullyconnected/sv_gm_syncdata.lua?at=master[/url]
Alternatively, if you only need the check on the client you can add a HUDPaint, and remove it as soon as LocalPlayer IsValid and you open vgui or whatever... If the server needs to know, I'd recommend using the Move hook as seen above...
Hello everyone, this function gets called every "think" that the player is dead. How would i only make the timer run once instead of multiple timers being created, but still have it inside the PlayerDeathThink function? Thanks!
[CODE]function GM:PlayerDeathThink( ply )
timer.Simple( 5, function()
ply:Spawn();
end )
end[/CODE]
I just can't figure it out... nothing seens broken for me
I get this:
[CODE][ERROR] addons/strange sweps/lua/weapons/weapon_modes.lua:58: 'then' expected near '='
1. unknown - addons/strange sweps/lua/weapons/weapon_modes.lua:0
[/CODE]
[CODE]
IncludeCS( "ai_translations.lua" )
IncludeCS( "sh_anim.lua" )
mode = 0
-- Variables that are used on both client and server
SWEP.Author = ""
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = ""
SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_357.mdl"
SWEP.Category = "Test"
SWEP.Spawnable = true
SWEP.AdminOnly = false
SWEP.Primary.ClipSize = 8 -- Size of a clip
SWEP.Primary.DefaultClip = 32 -- Default number of bullets in a clip
SWEP.Primary.Automatic = false -- Automatic/Semi Auto
SWEP.Primary.Ammo = "Pistol"
SWEP.Secondary.ClipSize = 8 -- Size of a clip
SWEP.Secondary.DefaultClip = 32 -- Default number of bullets in a clip
SWEP.Secondary.Automatic = false -- Automatic/Semi Auto
SWEP.Secondary.Ammo = "Pistol"
--[[---------------------------------------------------------
Name: SWEP:Initialize( )
Desc: Called when the weapon is first loaded
-----------------------------------------------------------]]
function SWEP:Initialize()
self:SetHoldType( "pistol" )
end
--[[---------------------------------------------------------
Name: SWEP:Precache( )
Desc: Use this function to precache stuff
-----------------------------------------------------------]]
function SWEP:Precache()
end
--[[---------------------------------------------------------
Name: SWEP:PrimaryAttack( )
Desc: +attack1 has been pressed
-----------------------------------------------------------]]
function SWEP:PrimaryAttack()
if mode = 1 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_AR2.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 1, 0.01 )
-- Remove 1 bullet from our clip
self:TakePrimaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
end
if mode = 2 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 9, 0.2 )
-- Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -10, 0, 0 ) )
end
if mode = 0 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 25, 0.2 )
-- Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -70, 0, 0 ) )
end
--[[---------------------------------------------------------
Name: SWEP:SecondaryAttack( )
Desc: +attack2 has been pressed
-----------------------------------------------------------]]
function SWEP:SecondaryAttack()
-- Make sure we can shoot first
if ( !self:CanSecondaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 9, 0.2 )
-- Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -10, 0, 0 ) )
end
--[[---------------------------------------------------------
Name: SWEP:Reload( )
Desc: Reload is being pressed
-----------------------------------------------------------]]
function SWEP:Reload()
mode = mode + 1
if mode > 2 then
mode = 0
end
end
[/CODE]
[QUOTE=Garr;47182024]I just can't figure it out... nothing seens broken for me
I get this:
[CODE][ERROR] addons/strange sweps/lua/weapons/weapon_modes.lua:58: 'then' expected near '='
1. unknown - addons/strange sweps/lua/weapons/weapon_modes.lua:0
[/CODE]
[CODE]
IncludeCS( "ai_translations.lua" )
IncludeCS( "sh_anim.lua" )
mode = 0
-- Variables that are used on both client and server
SWEP.Author = ""
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = ""
SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_357.mdl"
SWEP.Category = "Test"
SWEP.Spawnable = true
SWEP.AdminOnly = false
SWEP.Primary.ClipSize = 8 -- Size of a clip
SWEP.Primary.DefaultClip = 32 -- Default number of bullets in a clip
SWEP.Primary.Automatic = false -- Automatic/Semi Auto
SWEP.Primary.Ammo = "Pistol"
SWEP.Secondary.ClipSize = 8 -- Size of a clip
SWEP.Secondary.DefaultClip = 32 -- Default number of bullets in a clip
SWEP.Secondary.Automatic = false -- Automatic/Semi Auto
SWEP.Secondary.Ammo = "Pistol"
--[[---------------------------------------------------------
Name: SWEP:Initialize( )
Desc: Called when the weapon is first loaded
-----------------------------------------------------------]]
function SWEP:Initialize()
self:SetHoldType( "pistol" )
end
--[[---------------------------------------------------------
Name: SWEP:Precache( )
Desc: Use this function to precache stuff
-----------------------------------------------------------]]
function SWEP:Precache()
end
--[[---------------------------------------------------------
Name: SWEP:PrimaryAttack( )
Desc: +attack1 has been pressed
-----------------------------------------------------------]]
function SWEP:PrimaryAttack()
if mode = 1 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_AR2.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 1, 0.01 )
-- Remove 1 bullet from our clip
self:TakePrimaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
end
if mode = 2 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 9, 0.2 )
-- Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -10, 0, 0 ) )
end
if mode = 0 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 25, 0.2 )
-- Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -70, 0, 0 ) )
end
--[[---------------------------------------------------------
Name: SWEP:SecondaryAttack( )
Desc: +attack2 has been pressed
-----------------------------------------------------------]]
function SWEP:SecondaryAttack()
-- Make sure we can shoot first
if ( !self:CanSecondaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 9, 0.2 )
-- Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -10, 0, 0 ) )
end
--[[---------------------------------------------------------
Name: SWEP:Reload( )
Desc: Reload is being pressed
-----------------------------------------------------------]]
function SWEP:Reload()
mode = mode + 1
if mode > 2 then
mode = 0
end
end
[/CODE][/QUOTE]
You forgot to close off the function SWEP:PrimaryAttack() function!
Correct Code :smile: ( I added another "end" at line 114 )
[CODE]IncludeCS( "ai_translations.lua" )
IncludeCS( "sh_anim.lua" )
mode = 0
-- Variables that are used on both client and server
SWEP.Author = ""
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = ""
SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_357.mdl"
SWEP.Category = "Test"
SWEP.Spawnable = true
SWEP.AdminOnly = false
SWEP.Primary.ClipSize = 8 -- Size of a clip
SWEP.Primary.DefaultClip = 32 -- Default number of bullets in a clip
SWEP.Primary.Automatic = false -- Automatic/Semi Auto
SWEP.Primary.Ammo = "Pistol"
SWEP.Secondary.ClipSize = 8 -- Size of a clip
SWEP.Secondary.DefaultClip = 32 -- Default number of bullets in a clip
SWEP.Secondary.Automatic = false -- Automatic/Semi Auto
SWEP.Secondary.Ammo = "Pistol"
--[[---------------------------------------------------------
Name: SWEP:Initialize( )
Desc: Called when the weapon is first loaded
-----------------------------------------------------------]]
function SWEP:Initialize()
self:SetHoldType( "pistol" )
end
--[[---------------------------------------------------------
Name: SWEP:Precache( )
Desc: Use this function to precache stuff
-----------------------------------------------------------]]
function SWEP:Precache()
end
--[[---------------------------------------------------------
Name: SWEP:PrimaryAttack( )
Desc: +attack1 has been pressed
-----------------------------------------------------------]]
function SWEP:PrimaryAttack()
if mode = 1 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_AR2.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 1, 0.01 )
-- Remove 1 bullet from our clip
self:TakePrimaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
end
if mode = 2 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 9, 0.2 )
-- Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -10, 0, 0 ) )
end
if mode = 0 then
-- Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
-- Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
-- Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 25, 0.2 )
-- Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
-- Punch the player's view
self.Owner:ViewPunch( Angle( -70, 0, 0 ) )
end
end
--[[---------------------------------------------------------
Name: SWEP:SecondaryAttack( )
Desc: +attack2 has been pressed
-----------------------------------------------------------]]
function SWEP:SecondaryAttack()
-- Make sure we can shoot first
if ( !self:CanSecondaryAttack() ) then return end
-- Play shoot sound
self.Weapon:Em
[QUOTE=Garr;47182024]I just can't figure it out... nothing seens broken for me
I get this:
[CODE][ERROR] addons/strange sweps/lua/weapons/weapon_modes.lua:58: 'then' expected near '='
1. unknown - addons/strange sweps/lua/weapons/weapon_modes.lua:0
[/CODE]
code
[/QUOTE]
At line 57 where you have;[CODE] if mode = 1 then[/CODE] Change that to[CODE] if mode == 1 then[/CODE] Do the same with the others.
[QUOTE=Austin1346;47181923]Hello everyone, this function gets called every "think" that the player is dead. How would i only make the timer run once instead of multiple timers being created, but still have it inside the PlayerDeathThink function? Thanks!
[CODE]function GM:PlayerDeathThink( ply )
timer.Simple( 5, function()
ply:Spawn();
end )
end[/CODE][/QUOTE]
If you use timer.Create instead of timer.Simple, you can name your timer. If you create a timer with the same name as an existing timer, the old one gets removed automatically, so only one is left.
If you want the first one you set to reach its end, you can use timer.Exists.
However, I think this is a bad approach here! I don't know what Spawn() does exactly, but I doubt it has anything to do with player respawning since it's an [url=http://wiki.garrysmod.com/page/Entity/Spawn]Entity function[/url] and not a Player function. I don't see any straightforward way to force a player to respawn, other than forcing him to click clientside, or maybe faking it on [url=http://wiki.garrysmod.com/page/GM/PlayerTick]GM:PlayerTick[/url].
But hey, I could be wrong. Experiment with it, see what you get!
Hey everybody, I just wanted to know if anyone knows if:
[url=https://developer.valvesoftware.com/wiki/$envmap] Valve Developer Page On Entities `Lightmap Textures.`[/url]
Can be done in lua??? ... with rendertargets perhaps? Someone help me confirm the idea.
Anything helpful would be appreciated, even to an indication of this already existing. The fact that it exists, or has it not been accomplished. Either way I feel like this sort of code should be public source.
I want to have the ability to create [B][U]"'`CURRENT`'"[/U][/B] updated images to the lightmap of my cars:
[url=https://www.youtube.com/watch?v=65GoIJN66xM]My youtube Channel to see what I've been doing.[/url]
There is a way to make a entity explode after a certain time? If yes, someone could kindly tell me how?
[QUOTE=Garr;47182306]There is a way to make a entity explode after a certain time? If yes, someone could kindly tell me how?[/QUOTE]
Use the [url=http://wiki.garrysmod.com/page/Category:timer]timer library[/url] and [url=http://wiki.garrysmod.com/page/util/BlastDamage]util.BlastDamage[/url]
How do i make a gun spawn entities that i created? I tryed it right now and it say it is a null entity. Codes are necessary?
[QUOTE=EthanTheGreat;47182164]Hey everybody, I just wanted to know if anyone knows if:
[url=https://developer.valvesoftware.com/wiki/$envmap] Valve Developer Page On Entities `Lightmap Textures.`[/url]
Can be done in lua??? ... with rendertargets perhaps? Someone help me confirm the idea.
Anything helpful would be appreciated, even to an indication of this already existing. The fact that it exists, or has it not been accomplished. Either way I feel like this sort of code should be public source.
I want to have the ability to create [B][U]"'`CURRENT`'"[/U][/B] updated images to the lightmap of my cars:
[url=https://www.youtube.com/watch?v=65GoIJN66xM]My youtube Channel to see what I've been doing.[/url][/QUOTE]
Make the render target. Set it to a variable called, idk, rt or something.
[lua]
local mat = MAT_TO_MODIFY
mat:SetTexture("$envmap",rt)
[/lua]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/IMaterial/SetTexture]IMaterial:SetTexture[/url]
[editline]2/20/15[/editline]
That's how the portal gun uses RT's to update itself. The only difference is that portal gun sets $basetexture, while your idea will set $envmap. It's all the same though.
OH also you'll have to find a way to format the envmap like an unfolded cube, I think. Idk. Someone was working on reflections like that in waywo a month ago. Ask him what he did.
Sorry, you need to Log In to post a reply to this thread.