Hey, I'm trying to set the weapons clipsize using this way
[lua]
x.Primary.ClipSize = math.random( 1, 10 )
[/lua]
x is the weapon ( took it out of a loop )
It works and all, but once I pick up the weapon from the ground it goes back to it's default clip, and when I reload (I can reload even if clip is full, aka default/default) it then shows the real clipsize. ( which I set in the loop )
Any ideas what's wrong?
Even if the clip gets set to 1, it still goes back to default and you can shoot how many times the default clip allows you to.
Weapon table:
[lua]
Primary:
ClipSize = 10
Automatic = false
Damage = 35
DefaultClip = 60
[/lua]
Bumping this up.
Are you editing the SWEP's properties externally, or within the SWEP's lua file?
Externally.
[editline]17th November 2013[/editline]
Just found out that apparently editing it externally ( on server) doesn't sync with client?
Can anyone shed some light on this?
Here's the rough idea of what I'm trying to do.
[lua]
function changePrim()
for _, x in pairs(ents.GetAll())
if x:IsWeapon() and x.Primary then
x.Primary.Damage = 1
x.Primary.ClipSize = math.random(1, 10)
end
end
end
hook.Add("OnEntityCreated", "hi facepunch", changePrim )
[/lua]
I stuck a print inside the function, it prints the right values just fine.
[lua]
lua_run_cl for _, x in pairs(ents.GetAll()) do if x:IsWeapon() and x.Primary then print(x.Primary.Damage) end end
[/lua]
This however prints the default values. I even stuck prints at the top of my server and client files to see what runs first (server obviously won)
Heck I even put my client file inside a "PostDrawOpaqueRenderables" hook which runs every frame iirc.
Client file is the same as the line I run using lua_run_cl.
Sorry, you need to Log In to post a reply to this thread.