[QUOTE=NiandraLades;46241037]
[code]
//Gender
GENDER_MALE = 1
GENDER_FEMALE = 0
[/code]
[/QUOTE]
Holy fuck you cis white privileged scum did you not realize the implications of this terrible coding? You are only reinforcing the patriarchy and insulting womyn everywhere
I wanted to add energy recharge function to my swep, It would recharge 1 energy per second with a cap of 100.
As total Lua newfag i failed with timers and loops. :tinfoil:
Help greatly apericiated. SFBE.
Something like this should do, see if you can understand it
[lua]SWEP.ChargeSpeed = 1
function SWEP:Recharge()
self.Recharging = true -- To keep track of when the SWEP is recharging
timer.Simple( self.ChargeSpeed, function()
if self.Charge >= 100 then self.Recharging = false return end -- Assuming that self.Charge is its charge
self.Charge = self.Charge +1
self:Recharge() -- Restart the recharging loop
end )
end[/lua]
[QUOTE=Handsome Matt;46252701]sick timer.[/QUOTE]
Am I being retarded again?
[QUOTE=Internet1001;46252613]Something like this should do, see if you can understand what I'm doing
[lua]SWEP.ChargeSpeed = 1
function SWEP:Recharge()
self.Recharging = true -- To keep track of when the SWEP is recharging
timer.Simple( self.ChargeSpeed, function()
if self.Charge >= 100 then self.Recharging = false return end -- Assuming that self.Charge is its charge
self.Charge = self.Charge +1
self:Recharge() -- Restart the recharging loop
end )
end[/lua][/QUOTE]
sorry m8, i meant the player's armor energy.
[QUOTE=BlackMadd;46243414]Can someone help me with particle systems? I am trying to use a particle system in my game but cant seem to get it to work without errors :(
My serverside code on the Gamemode is
[code]
PrecacheParticleSystem("devtest.pcf")
PrecacheParticleSystem("advisor.pcf")
[/code]
And in a clientside file I have this.
[code]
ParticleEffect("test_lighting",Vector(-1008.854370,1594.918457,-2494.968750),Angle(0,0,0))
ParticleEffect("advisor_object_charge_bits",Vector(-1008.854370,1594.918457,-2494.968750),Angle(0,0,0))
[/code]
My console shows these errors
[code]
Attemped to precache unknown particle system "test_lighting"!
Attemped to precache unknown particle system "advisor_object_charge_bits"!
[/code][/QUOTE]
Well removing the .pcf from the server side code removes the errors, but the particle effect just shows up as the error particle (Red X's) I have moved the devtest and advisor.pcf files into my Gmod particles folder and updated my particle manifest file but I am still not seeing the particles in game.
Anyone know why?
EDIT: Nvm errors are back
[code]
Attemped to precache unknown particle system "devtest"!
Attemped to precache unknown particle system "advisor"!
[/code]
[QUOTE=DingDong;46252948]sorry m8, i meant the player's armor energy.[/QUOTE]
Then it should be as replacing what I did with self.Charge using the functions [url=http://wiki.garrysmod.com/page/Player/Armor]self.Owner:Armor()[/url] to get the player's armour and [url=http://wiki.garrysmod.com/page/Player/SetArmor]self.Owner:SetArmor()[/url], if you didn't know those functions before.
You could alternatively create a timer unique to the SWEP, something like this should do
[lua]SWEP.Timer = "Recharge_" .. self:EntIndex() -- Unique name for your timer
SWEP.RechargeDelay = 1
function SWEP:Initialize() -- Create timer on initialize
timer.Create( self.Timer, self.RechargeDelay, 0, function()
if not IsValid( self.Owner ) or self.Owner:Armor() >= 100 then timer.Pause( self.Timer ) end -- Pause if owner isn't valid or their armour is already 100
self.Owner:SetArmor( self.Owner:Armor() +1 ) -- Add armour
end )
timer.Pause( self.Timer ) -- Pause instantly after timer is created
end
function SWEP:Recharge() -- Method to restart the timer
timer.UnPause( self.Timer )
end
function SWEP:OnRemove() -- Remember to destroy the timer OnRemove
-- You don't want a bunch of unused timers
timer.Destroy( self.Timer )
end [/lua]
[QUOTE=DingDong;46252948]sorry m8, i meant the player's armor energy.[/QUOTE]
I believe you would use usermessages/net messages to do that, seeing as it's both im(practical(?)) and dangerous (haaax) to change those values clientside.
Or you could maybe use if SERVER then and check the player that is using your weapon and recharging?
Anyone has a good idea to fix this?
Basically, the camera near plane is clipping with the stencil buffer quad. I'm just wondering if anyone has a good solution to this.
I've read up on it and most people suggest using a depth mask. But of course, this is Garry's Mod, we don't have those fancy toys!
[video=youtube;YUXpZyqy9Co]http://www.youtube.com/watch?v=YUXpZyqy9Co&feature=youtu.be[/video]
No matter what mode I set spectator to, it doesn't work.
All it does is make me spawn like a normal person, be invisible (or sometimes have the grey gordon model) and have a very weird third person but first person viewmodel cam view that's super jarring. How would I get it to follow people like it should instead of that mess?
How would I go about declaring a function as Shared in lua/autorun? I put it in a seperate lua file without any if CLIENT/SERVER thans but calling it on the client returns nil errors
[QUOTE=Exho;46256294]How would I go about declaring a function as Shared in lua/autorun? I put it in a seperate lua file without any if CLIENT/SERVER thans but calling it on the client returns nil errors[/QUOTE]
Check your PN btw. i know you are browsing here with your phone.
A bit of Question: The only way to make useable seats are to script SCARs or is there some blackmagic that i don't know?
Hello,
I have a weird problem,
If I do:
[code]
local s = weapon_tool:GetToolObject():GetHelpText()
print( s )
[/code]
It will print the correct help text
But if I try to upper() it,
[code]
local s = weapon_tool:GetToolObject():GetHelpText()
print( s:upper() )
[/code]
Then it will print for example:
[quote]
#TOOL.AXIS.0
[/quote]
Or for other tools such as Wiremod tools, it will print as if I didn't call upper().
Looking at the GetHelpText function, I understand why it happens:
[code]
function ToolObj:GetHelpText()
return "#tool." .. GetConVarString( "gmod_toolmode" ) .. "." .. self:GetStage()
end
[/code]
But is there any way to make the true help text uppercase?
[b]Edit: I just found function language.GetPhrase, and it solved the problem ;)[/b]
try language.GetPhrase?
[LUA]language.GetPhrase( s ):upper()[/LUA]
[editline]17th October 2014[/editline]
k
[lua]if LocalPlayer():GetEyeTrace().Entity == ply then[/lua]
Obviously it only executes if you're looking directly at ply. But what I want it to do is if you're looking in the "general direction" of ply (~45 degrees) that it would execute. How would I do this?
[QUOTE=RonanZer0;46265196]Obviously it only executes if you're looking directly at ply. But what I want it to do is if you're looking in the "general direction" of ply (~45 degrees) that it would execute. How would I do this?[/QUOTE]
[URL="http://wiki.garrysmod.com/page/ents/FindInCone"]ents.FindInCone[/URL]
[QUOTE=RonanZer0;46265196][lua]if LocalPlayer():GetEyeTrace().Entity == ply then[/lua]
Obviously it only executes if you're looking directly at ply. But what I want it to do is if you're looking in the "general direction" of ply (~45 degrees) that it would execute. How would I do this?[/QUOTE]
Darkrp does something like this to draw names.
take a look at [url]https://github.com/FPtje/DarkRP/blob/master/gamemode/modules/hud/cl_hud.lua#L320[/url]
-snip-
My player classes simply are not working. If I make it print something outside of player loadout func it prints on player spawn. If it's inside player loadout in the player class, not working.
[lua]DEFINE_BASECLASS( "player_default" )
local plyer = {}
//ply.WalkSpeed = 200
//ply.RunSpeed = 200
print("er")
function plyer:Loadout()
self.Player:SetModel("models/player/combine_soldier.mdl")
print("um")
end
player_manager.RegisterClass( "player_assault", ply, "player_default" )[/lua]
Prints er on player spawn but not um. Obviously it's included and set.
I want to make it so when my weapon shoots a zombie dead it never drops a living headcrab, but it always drops a headcrab ragdoll gib. I'm trying to find a damage type that will do this, but DMG_ALWAYSGIB doesn't do anything differently, and I don't want the zombie to split in half like DMG_BLAST does.
[editline]18th October 2014[/editline]
Recap: On zombie death, Headcrab never alive. Headcrab ragdoll always falls off. Body does not split in half.
DMG_ALWAYSGIB doesn't work, and DMG_BLAST doesnt fit the criteria.
[QUOTE=RonanZer0;46270725][lua]player_manager.RegisterClass( "player_assault", ply, "player_default" )[/lua]
Prints er on player spawn but not um. Obviously it's included and set.[/QUOTE]
replace 'ply' with 'plyer' to make it work
but you should rather stop using 'plyer' and just go with 'ply'
[QUOTE=WalkingZombie;46270903]I want to make it so when my weapon shoots a zombie dead it never drops a living headcrab, but it always drops a headcrab ragdoll gib. I'm trying to find a damage type that will do this, but DMG_ALWAYSGIB doesn't do anything differently, and I don't want the zombie to split in half like DMG_BLAST does.
[editline]18th October 2014[/editline]
Recap: On zombie death, Headcrab never alive. Headcrab ragdoll always falls off. Body does not split in half.
DMG_ALWAYSGIB doesn't work, and DMG_BLAST doesnt fit the criteria.[/QUOTE]
A ghetto way you could do it is delay until the next tick (0 seconds) and then perform a tiny ents.FindInSphere where the zombie's head would be, then kill any headcrabs in that sphere (which would usually only be like one headcrab)
Can someone do me a favour? I'm trying to get this font to show up in-game, and I've tried the file name, font name and various but can't get it to show. I can't tell if it's the font itself or if I'm doing it wrong
Trying to avoid using Lobster since it's a bit overused :v:
[url]http://www.dafont.com/motion-picture.font[/url]
[QUOTE=NiandraLades;46271383]Can someone do me a favour? I'm trying to get this font to show up in-game, and I've tried the file name, font name and various but can't get it to show. I can't tell if it's the font itself or if I'm doing it wrong
Trying to avoid using Lobster since it's a bit overused :v:
[url]http://www.dafont.com/motion-picture.font[/url][/QUOTE]
Try the actual font name (which would be "Motion Picture Personal Use" according to font viewer)
[QUOTE=BFG9000;46271254]A ghetto way you could do it is delay until the next tick (0 seconds) and then perform a tiny ents.FindInSphere where the zombie's head would be, then kill any headcrabs in that sphere (which would usually only be like one headcrab)[/QUOTE]
Thanks for the idea. That ensures that there will never be a living headcrab, but I want a 100% chance that in some way, as a ragdoll or as a NPC, a headcrab comes off the head. (if I kill it manually, then it can be just the NPC)
[QUOTE=Khub;46270945]replace 'ply' with 'plyer' to make it work
but you should rather stop using 'plyer' and just go with 'ply'[/QUOTE]
No I had it set all to ply a little bit ago. It still didn't work, just forgot to chance it again after changing everything to plyer to test.
[code]lua/includes/modules/net.lua:92: bad argument #1 to 'pairs' (table expected, got nil)[/code]
Can i find out where this stack is coming from? It's obviously nothing wrong with the net library.
[QUOTE=Giraffen93;46276027][code]lua/includes/modules/net.lua:92: bad argument #1 to 'pairs' (table expected, got nil)[/code]
Can i find out where this stack is coming from? It's obviously nothing wrong with the net library.[/QUOTE]
Not that I know of, but you can look up the function in the net.lua file, then search through your code to find where you use it. Then you'll have to do some debugging to find out where the error originates from.
There's probably better ways to do this, if anyone has one, please let us know!
[QUOTE=Giraffen93;46276027][code]lua/includes/modules/net.lua:92: bad argument #1 to 'pairs' (table expected, got nil)[/code]
Can i find out where this stack is coming from? It's obviously nothing wrong with the net library.[/QUOTE]
The error isn't giving you a stack trace? Sounds like it's being called from RunString/SendLua/BroadcastLua.
[QUOTE=Metamist;46277075]Not that I know of, but you can look up the function in the net.lua file, then search through your code to find where you use it. Then you'll have to do some debugging to find out where the error originates from.
There's probably better ways to do this, if anyone has one, please let us know![/QUOTE]
i use writetable a lot, not worth the effort of searching through everything
[QUOTE=Willox;46277164]The error isn't giving you a stack trace? Sounds like it's being called from RunString/SendLua/BroadcastLua.[/QUOTE]
i never use those
Sorry, you need to Log In to post a reply to this thread.