[QUOTE=jaooe;39587821]I've never used data tables before so I don't have a clue either.
If I were you I would try
[lua]
function SWEP:SetupDataTables()
self.holstered = false
end
function SWEP:PrimaryAttack()
if !self.holstered then
print("yes")
self.holstered = !self.holstered
else
print("no")
self.holstered = !self.holstered
end
end
[/lua]
That will toggle the value of self.holstered between true and false, starting at false.[/QUOTE]
I'm pretty sure that's not how datatables work, but I'll try doing it like that.
Wow, that actually worked, thanks man!
[QUOTE=Science;39586276]What would be the equivilent of DNumSlider in Gmod13?
All i can seem to use is DSlider which to be honest, is plain awful.[/QUOTE]
DNumSlider is still valid
I'm getting this error when i press z to remove my entity:
[CODE][ERROR] LuaCmd:1: ')' expected near 's'
1. unknown - LuaCmd:0
[/CODE]
I have no clue what it means. Help would be appreciated :)
Client particle emitters don't seem to work for me.
Here is cl_init.lua in castparticles
[lua]EFFECT.Origin=vector_origin
function EFFECT:Init(effectdata)
self.Origin=effectdata:GetOrigin()
self:SetPos(self.Origin)
local em = ParticleEmitter(self.Origin)
for i=1, 20 do
local part = em:Add("sprites/light_glow02_add",centr)
if part then
part:SetColor(255,255,255,math.random(255))
part:SetVelocity(Vector(math.random(-1,1),math.random(-1,1),math.random(-1,1)):GetNormal() * 20)
part:SetDieTime(0.5)
part:SetLifeTime(0)
part:SetStartSize(10)
part:SetEndSize(0)
end
end
em:Finish()
end
function EFFECT:Think()
return true
end
function EFFECT:Render()
end[/lua]
Here is the code used to spawn it
[lua]
local plraimv=LocalPlayer():GetAimVector()
local aimv=util.AimVector( plraimv:Angle(), LocalPlayer():GetFOV(), pos.x, pos.y, ScrW(), ScrH() )
local pos=LocalPlayer():EyePos()
local effectdata=EffectData()
effectdata:SetOrigin(pos+aimv*100)
--util.Effect("HelicopterMegaBomb",effectdata)
util.Effect("castparticles",effectdata)
[/lua]
For some reason it works with the helicoptermegabomb, but not with the particle effect. Can someone please tell me why? Thanks!
So I'm moving some bones around in a view model to make a different view model, but the issue is that ManipulateBonePosition doesnt seem to be working correctly or something.
Depending on where I am on the map, this shit happens
[img]http://puu.sh/22y7K[/img]
I can still see the hand, even though it should be behind my head
[lua]
SWEP.ViewModel = Model( "models/weapons/v_knife_t.mdl" )
SWEP.BonesToHide = {"v_weapon.knife_Parent",
"v_weapon.Knife_Handle",
"v_weapon.Left_Arm"}
function SWEP:ViewModelDrawn(vm)
for k, v in ipairs( self.BonesToHide ) do
local bone = vm:LookupBone( v )
if bone and bone >= 0 then
vm:ManipulateBonePosition( bone, EyePos( ) - EyeAngles( ):Forward( ) * 300 )
vm:ManipulateBoneScale( bone, vector_origin )
end
end
[/lua]
Any thoughts?
[QUOTE=Feihc;39589531]So I'm moving some bones around in a view model to make a different view model, but the issue is that ManipulateBonePosition doesnt seem to be working correctly or something.
Depending on where I am on the map, this shit happens
[img]http://puu.sh/22y7K[/img]
I can still see the hand, even though it should be behind my head
[lua]
SWEP.ViewModel = Model( "models/weapons/v_knife_t.mdl" )
SWEP.BonesToHide = {"v_weapon.knife_Parent",
"v_weapon.Knife_Handle",
"v_weapon.Left_Arm"}
function SWEP:ViewModelDrawn(vm)
for k, v in ipairs( self.BonesToHide ) do
local bone = vm:LookupBone( v )
if bone and bone >= 0 then
vm:ManipulateBonePosition( bone, EyePos( ) - EyeAngles( ):Forward( ) * 300 )
vm:ManipulateBoneScale( bone, vector_origin )
end
end
[/lua]
Any thoughts?[/QUOTE]
Maybe the vector_origin has something to do with it? Here's an easier workaround: scale all the bones in the arm to 0 instead
[QUOTE=Ylsid;39589622]Maybe the vector_origin has something to do with it? Here's an easier workaround: scale all the bones in the arm to 0 instead[/QUOTE]
:| vector_origin = Vector(0,0,0)
And I don't really have to scale the bones anyway, if I move them then I shouldn't be able to see them either way, but at certain positions and angles I can.
My first attempt was to scale ALL of the bones in the left hand to 0, but there were some floating ghost bones that I couldn't get rid of that left a bit of the glove just floating there.
[QUOTE=Feihc;39589660]:| vector_origin = Vector(0,0,0)
And I don't really have to scale the bones anyway, if I move them then I shouldn't be able to see them either way, but at certain positions and angles I can.
My first attempt was to scale ALL of the bones in the left hand to 0, but there were some floating ghost bones that I couldn't get rid of that left a bit of the glove just floating there.[/QUOTE]
Maybe manipulateboneposition takes local coords instead of global ones, perhaps? Is it because you're doing * 300 instead of * -300?
[QUOTE=Ylsid;39589753]Maybe manipulateboneposition takes local coords instead of global ones, perhaps?[/QUOTE]
Good idea, but it seems like even if I toworld the data, it just changes the position/angles at which the hand is visible.
Does anyone know if there's a certain way to stop entities and things like that from rendering if they're a certain distance away or they're not visible? Should significantly decrease lag on certain gamemodes if I'm not mistaken.
Did anyone read my question above? I seem to be getting ignored whenever i ask for help here :/
[QUOTE=Mr Cookieman;39590094]Did anyone read my question above? I seem to be getting ignored whenever i ask for help here :/[/QUOTE]
Mostly because with what you gave us doesn't give us shit to go on, give us your code and which line of that the error appears on.
[QUOTE=Donkie;39590500]Mostly because with what you gave us doesn't give us shit to go on, give us your code and which line of that the error appears on.[/QUOTE]
If you read the error you would understand that i dont know where the error is. I have no clue what it is about!
You could explain us if you added something, or what the last thing you did was before the error popped up..
[QUOTE=Persious;39590689]You could explain us if you added something, or what the last thing you did was before the error popped up..[/QUOTE]
I also said that. If you read the message properly, then you would have known that i said this:
I'm getting this error when i press z to remove my entity:
[CODE][ERROR] LuaCmd:1: ')' expected near 's'
1. unknown - LuaCmd:0
[/CODE]
I have no clue what it means. Help would be appreciated :)
[QUOTE=>>;39590054]Does anyone know if there's a certain way to stop entities and things like that from rendering if they're a certain distance away or they're not visible? Should significantly decrease lag on certain gamemodes if I'm not mistaken.[/QUOTE]
This is actually done automatically by the game already
also does anyone know about my particle bug?
I'm not working in Garry's Mod but I thought here would be the best place to ask anyway. Lua is a lot different from the other languages I'm used to and the documentation isn't always much help.
How would I retrieve the amount of lines in a string?
I wanted to position my view model in gmod, so i got out the swep construction kit, and i did everything to my liking, then it spat the code in the console:
[code]
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/c_models/c_flamethrower/c_flamethrower.mdl"
SWEP.WorldModel = "models/weapons/c_models/c_flamethrower/c_flamethrower.mdl"
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelBoneMods = {
["weapon_bone"] = { scale = Vector(1, 1, 1), pos = Vector(0.317, -17.143, -13.334), angle = Angle(-3.81, 0, 0) }
}
[/code]
I pasted it in my lua file, then tested it,but the model stayed didn't move, its still in the same position as it was before i put down this code. What is wrong?
[QUOTE=reevezy67;39591214]I'm not working in Garry's Mod but I thought here would be the best place to ask anyway. Lua is a lot different from the other languages I'm used to and the documentation isn't always much help.
How would I retrieve the amount of lines in a string?[/QUOTE]
Try doing a string.find or something? Might work
Max jobs limits for darkrp, need help
Here my example code of sv_maxjobs.lua
[LUA]
local MAX_POLICE = 0
function CalculateMaxJobs()
local TotalPlayers = table.Count(player.GetAll())
if TotalPlayers >= 40 then
MAX_POLICE = 8
elseif TotalPlayers >= 30 then
MAX_POLICE = 7
elseif TotalPlayers >= 20 then
MAX_POLICE = 6
elseif TotalPlayers >= 10 then
MAX_POLICE = 5
elseif TotalPlayers < 10 then
MAX_POLICE = 3
end
end
hook.Add("PlayerInitialSpawn", "CalculateMaxJobsOnSpawn", CalculateMaxJobs)
hook.Add("PlayerDisconnect", "CalculateMaxJobsOnDisconnect", CalculateMaxJobs)
hook.Add("InitPostEntity", "CalculateMaxJobsOnStartUp", CalculateMaxJobs)
[/LUA]
My problem is when i paste MAX_POLICE to shared.lua it doesn't work.
Help, how to make this work, because i can't understand.
[QUOTE=Feihc;39589660]:| vector_origin = Vector(0,0,0)
And I don't really have to scale the bones anyway, if I move them then I shouldn't be able to see them either way, but at certain positions and angles I can.
My first attempt was to scale ALL of the bones in the left hand to 0, but there were some floating ghost bones that I couldn't get rid of that left a bit of the glove just floating there.[/QUOTE]
I remember reading somewhere that setting the size of a bone to 0 caused some fuckups, try with a very small number like 0.0001
[QUOTE=Ylsid;39591266]Try doing a string.find or something? Might work[/QUOTE]
Ah right you can find the escape sequence, don't know why I thought it wouldn't.
Thanks.
[QUOTE=lua_error;39591286]Max jobs limits for darkrp, need help
Here my example code of sv_maxjobs.lua
[LUA]
local MAX_POLICE = 0
function CalculateMaxJobs()
local TotalPlayers = table.Count(player.GetAll())
if TotalPlayers >= 40 then
MAX_POLICE = 8
elseif TotalPlayers >= 30 then
MAX_POLICE = 7
elseif TotalPlayers >= 20 then
MAX_POLICE = 6
elseif TotalPlayers >= 10 then
MAX_POLICE = 5
elseif TotalPlayers < 10 then
MAX_POLICE = 3
end
end
hook.Add("PlayerInitialSpawn", "CalculateMaxJobsOnSpawn", CalculateMaxJobs)
hook.Add("PlayerDisconnect", "CalculateMaxJobsOnDisconnect", CalculateMaxJobs)
hook.Add("InitPostEntity", "CalculateMaxJobsOnStartUp", CalculateMaxJobs)
[/LUA]
My problem is when i paste MAX_POLICE to shared.lua it doesn't work.
Help, how to make this work, because i can't understand.[/QUOTE]
Instead of doing this go directly into DarkRP and check the OnJobChange function, i'm sure there is one.
Do the checks there, and also use #player.GetAll() not table.Count because it's not necessary in this case because player.GetAll is a hash table that increments by 1 that starts from 1.
[QUOTE=Ylsid;39590846]This is actually done automatically by the game already
also does anyone know about my particle bug?[/QUOTE]
But how can you [b]modify[/b] the distance
[QUOTE=brandonj4;39591510]Instead of doing this go directly into DarkRP and check the OnJobChange function, i'm sure there is one.
Do the checks there, and also use #player.GetAll() not table.Count because it's not necessary in this case because player.GetAll is a hash table that increments by 1 that starts from 1.[/QUOTE]
I tried many things, it doesn't read value MAX_POLICE, i don't know why
How would I go about emitting a sound from a moving entity? The sound is 2.5 seconds long, which is plenty of time for a player to pick up and move the entity and make the sound innacurate. I'm currently using sound.Play(), but it doesn't seem to provide any way to account for this situation.
What do I have to do to make a SENT's eyes posable with Entity:SetEyeTarget()? I've asked this question here a number of times and gotten nothing, is it just not possible?
[QUOTE=>>;39591539]But how can you [b]modify[/b] the distance[/QUOTE]
Oh, in the entity code you can do something with [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe77d.html[/url] to change this. Only works in scripted ents.
This is something very miniscule, but can someone assist me to stop this error.
[CODE]hook.Add("PropBreak", "DRP_PropBreakGuard", function(a, e)
if !IsValid(e) then return false end
local PhysObj = e:GetPhysicsObject()
if !IsValid(PhysObj) then return false end
constraint.RemoveAll(e)
end)
[/CODE]
[CODE][ERROR] lua/includes/modules/constraint.lua:167: Tried to use invalid object (type IPhysicsObject) (Object was NULL or not of the right type)
EnableCollisions - [C]:-1
SetPhysicsCollisions - lua/includes/modules/constraint.lua:167
RemoveAll - lua/includes/modules/constraint.lua:231
fn - gamemodes/darkrp/gamemode/shared/workarounds.lua:111
unknown - addons/ulib/lua/ulib/shared/hook.lua:168
[/CODE]
I'm just curious, what other safety checks should I be doing exactly?
Hey, i am making my first HUD and i am using silk icons in it, its for my gamemode, how could i make the player download the icons?
And second question, i want to draw players avatar on the HUD but i dont know how to get around the memory leaking since its derma and HUDPaint will call the function every tick.
Sorry, you need to Log In to post a reply to this thread.