[QUOTE=ShadowRanger;45832019]What animations are you trying to use?[/QUOTE]
I tried multiple things and I made sure to print it to make sure it was not a invalid animation.
One of the things I tried
[code]
ACT_HL2MP_WALK
[/code]
[QUOTE=bran92don;45832530]I tried multiple things and I made sure to print it to make sure it was not a invalid animation.
One of the things I tried
[code]
ACT_HL2MP_WALK
[/code][/QUOTE]
Forgive me if this is a useless post, but have you tried taking a look at anything that uses its own animation system instead of Garry's? Like NutScript or Tiramisu(I believe?) they have a table of animations that is applied to players.
EDIT: A quick glance and I found this in sh_animation.lua inside NutScript/lib
[code]
local playerMeta = FindMetaTable("Player")
if (SERVER) then
function playerMeta:SetOverrideSeq(sequence, time, startCallback, finishCallback)
local realSeq, duration = self:LookupSequence(sequence)
time = time or duration
if (!realSeq or realSeq == -1) then
return
end
self:SetNetVar("seq", sequence)
if (startCallback) then
startCallback()
end
if (time > 0) then
timer.Create("nut_Seq"..self:UniqueID(), time, 1, function()
if (IsValid(self)) then
self:ResetOverrideSeq()
if (finishCallback) then
finishCallback()
end
end
end)
end
return time, realSeq
end
function playerMeta:ResetOverrideSeq()
self:SetNetVar("seq", false)
end
end
function playerMeta:GetOverrideSeq()
return self:GetNetVar("seq", false)
end
[/code]
i want to use ply in serverside. ex: ply:SetHealth()
how i can do this?
[QUOTE=DaRkWoRlD1337;45833543]i want to use ply in serverside. ex: ply:SetHealth()
how i can do this?[/QUOTE]
You'll need to be more specific. What player do you want to manipulate? Is there any specific moment you would want to manipulate them?
The basic principle is that you need a player object to run methods on them (SetHealth() is one of them).
One way is to iterate through player.GetAll(), which returns a table of all the player objects currently in the server, so you could do this
[lua]for k, ply in pairs( player.GetAll() ) do -- k is the key in the table, ply is the object
ply:SetHealth( 100 )
end[/lua]
[CODE][ERROR] addons/levelz/lua/autorun/derma.lua:26: bad argument #1 to 'pairs' (tabl
e expected, got function)
1. pairs - [C]:-1
2. unknown - addons/levelz/lua/autorun/derma.lua:26[/CODE]
i got error.
[editline]29th August 2014[/editline]
Code :
[CODE]AddCSLuaFile('cl_derma.lua')
include('autorun/shared.lua')
hook.Add('PlayerSay', 'derma', function( ply, text)
text = string.lower( text )
if ( string.sub( text, 1, 6) == '!level' ) then
ply:ConCommand("level_menu")
end
end )
XP = 0
level = 0
function levelup(ply)
XP=XP+1
if XP==10 then
level=level+1
for k, ply in pairs( player.GetAll ) do -- k is the key in the table, ply is the object
ply:SetHealth(100)
end
end
if XP==20 then
level=level+1
end
if XP==50 then
level=level+1
end
end
timer.Create("levelupper", 1, 0, levelup)[/CODE]
[QUOTE=DaRkWoRlD1337;45833613][CODE][ERROR] addons/levelz/lua/autorun/derma.lua:26: bad argument #1 to 'pairs' (tabl
e expected, got function)
1. pairs - [C]:-1
2. unknown - addons/levelz/lua/autorun/derma.lua:26[/CODE]
i got error.[/QUOTE]
Ah sorry player.GetAll() is a function - you need the parentheses to call it
thanks, it worked. i have a another problem, i cant include shared.lua,
include("shared.lua")
error :
Couldn't include file 'shared.lua' (File not found) (@addons/levelz/lua/autorun/cl_derma.lua (line 2))
If you're doing that in a client side file you'll need to call AddCSLuaFile( "shared.lua" ) first.
same
What is your file structure? AddCSLuaFile is a server function, you'll need to run in in a server side file, eg. /lua/autorun/server/myfile.lua
[QUOTE=TheDeadlyHaze;45831462][IMG]http://puu.sh/bbrVZ/fd35daf858.jpg[/IMG]
Is this a good buy? I've recently purchased this to accompany the PIL[/QUOTE]
You can do amazing stuff with just lua (Implying that glua it's something else)
If you can dominate Lua itself, you'll do awesome stuff with this learning in depth the languaje
First off, I'd like to start by saying I'm not certain if my issue is a misunderstanding of how SWEPs work, or an actual bug that I've caused.
Some background (in the case of it being important):
So, I'm relatively new at making code, so I decided to started messing around with TTT earlier this week for experience. I made some sweps, and poked around in the code, and changed a lot of things. I started having an issue where one of my sweps wouldn't pick up ammo.
Here's where the important part starts:
I've completely redownloaded my gmod hoping to fix the issue, but the issue still persisted. I ended up tracing the problem to the type of ammo the gun had.
In other words, for a gun set with " SWEP.Primary.Ammo = "357" " and " SWEP.AmmoEnt = "item_ammo_357_ttt" ", the max backup ammo capacity is set to 20 regardless of what "SWEP.Primary.ClipMax" is set to. For added clarity, [URL="http://pastebin.com/TagPe0qJ"]this[/URL] (note:not my code, but is a good example of what I'm talking about) creates a weapon that starts with 20 bullets but only picks up 20 extra bullets (20+20), despite "SWEP.Primary.ClipMax" being set to 40. Weapons with SMG ammo are forced to x+60, weapons with shotgun ammo are forced to x+24, etc.
I don't expect anyone to magically come up with an answer based on what little I've provided, but instead, is there anyway to decipher what's going on? I'm at the end of my wits trying to figure out what's going on.
I am getting this weird thing where GetRagdollEntity() just returns nil. I am trying to call it server side. Anyone know why this happens.
I'm having issues with creating ropes. Creating this, the rope does not constrain the entities, but it does cause both to rotate if one rotates. The rope is not visually connecting them, and is instead spazzing out in the distance.
[lua] local pos1 = self:GetPos() + Vector(0,0,0)
local pos2 = plug1:GetPos() + Vector(0,0,0)
local plug1rope = constraint.Rope( self, plug1, 0, 0, pos1, pos2, ( pos1 - pos2):Length(), 0, 0, 1, "cable/cable2", false ) [/lua]
[B]FACEPALM[/B]
Realised that I was using world positions in a local position argument.
Heey guys, I got a little problem with my SWEP, Silent AWP weapon. It keeps saying that weapon slot 7 is already in use while you're not using this slot, I know you have to drop your weapon at slot 3 to buy this, but shouldn't their be a way that you can buy the silent awp into slot 7 just like the AK and other traitor weapons?
Yes i did; SWEP.Kind = WEAPON_EQUIP1
Code looks like this : [CODE]if SERVER then
AddCSLuaFile( "shared.lua" )
end
SWEP.HoldType = "ar2"
if CLIENT then
SWEP.PrintName = "Silent AWP"
SWEP.Slot = 6
SWEP.Icon = "VGUI/ttt/icon_scout"
end
SWEP.Kind = WEAPON_EQUIP1
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.LimitedStock = true -- only buyable once
SWEP.Base = "weapon_tttbase"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Kind = WEAPON_HEAVY
SWEP.WeaponID = AMMO_SAWP
SWEP.IsSilent = true
SWEP.Primary.Delay = 1.5
SWEP.Primary.Recoil = 7
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "357"
SWEP.Primary.Damage = 2000
SWEP.Primary.Cone = 0.005
SWEP.Primary.ClipSize = 2
SWEP.Primary.ClipMax = 2 -- keep mirrored to ammo
SWEP.Primary.DefaultClip = 2
SWEP.HeadshotMultiplier = 4
SWEP.AutoSpawnable = false
SWEP.ViewModel = "models/weapons/v_snip_awp.mdl"
SWEP.WorldModel = "models/weapons/w_snip_awp.mdl"
SWEP.Primary.Sound = Sound ("Weapon_M4A1.Silenced")
SWEP.Secondary.Sound = Sound("Default.Zoom")
SWEP.IronSightsPos = Vector( 5, -15, -2 )
SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 )[/CODE]
[QUOTE=NoFearzz;45844056]Heey guys, I got a little problem with my SWEP, Silent AWP weapon. It keeps saying that weapon slot 7 is already in use while you're not using this slot, I know you have to drop your weapon at slot 3 to buy this, but shouldn't their be a way that you can buy the silent awp into slot 7 just like the AK and other traitor weapons?
-snip-[/CODE][/QUOTE]
Maybe try to add a SWEP:SlotPos line
f.exp(
[LUA]SWEP.SlotPos = 1[/LUA]
)
Just keep in mind that you are not editing the base you are working on a spinoff , of the weapon_ttt_base
Has anyone noticed SWEP:Think not being called when you run out of ammo and the weapon has clipsize -1 or 0 after you switch from it and back to it?
[QUOTE=sm69baller;45845018]Maybe try to add a SWEP:SlotPos line
f.exp(
[LUA]SWEP.SlotPos = 1[/LUA]
)
Just keep in mind that you are not editing the base you are working on a spinoff , of the weapon_ttt_base[/QUOTE]
i've Added [code]SWEP.Slotpos = 7 [/code]
Into the shared.lua to make it go into slot 7, but it still says the same.
[QUOTE=Robotboy655;45845620]Has anyone noticed SWEP:Think not being called when you run out of ammo and the weapon has clipsize -1 or 0 after you switch from it and back to it?[/QUOTE]
Well putting a bool on the think hook did the trick for me ; D
[LUA]
SWEP:Think(b)
if !(b) then return end
--bla bla
end[/LUA]
[QUOTE=sm69baller;45845715]Well putting a bool on the think hook did the trick for me ; D
[LUA]
SWEP:Think(b)
if !(b) then return end
--bla bla
end[/LUA][/QUOTE]
Ehh, what is this got to do with it? The hook itself is never called if I switch to a weapon with ClipSize of -1.
I have no idea what causes it, I just started getting it in Dev.
[editline]30th August 2014[/editline]
Ok, so it's a little bit different than I thought. If your SWEP fully runs out of ammo, you switch from it and to it, SWEP:PrimaryAttack and SWEP:Think ( and possibly other hooks ) will not be called until you get more ammo for it and switch from that SWEP and back to it.
It happens with weapon_base. Can anyone confirm on Dev?
Does my file name actually determine the scope of the file?
Like sv_hoobalooba would be Serverside and cl_shamallama would be Clientside
[QUOTE=Exho;45849591]Does my file name actually determine the scope of the file?
Like sv_hoobalooba would be Serverside and cl_shamallama would be Clientside[/QUOTE]
No. It's just for tidyness. You can just make an sv_whatever file clientsided by running AddCSLuaFile("sv_whatever")
It looks like ragdolls don't have interpolation (both dev and main branches). GetPos calls are interpolated, so anything attached to them lags behind. Is there a fix?
I'm confused to how include() works
basically I coded this 22KB file and I think it's a clusterfuck so I split it up into 8 different lua files that fit.
In one file, I'm including all of it together. And made this one file in autorun/server with the following code
[code]
include("autorun/server/sv_class_falldamage.lua")
include("autorun/server/sv_class_perks_damage.lua")
include("autorun/server/sv_class_perks_passive.lua")
include("autorun/server/sv_class_spawning.lua")
include("autorun/server/sv_class_sprint.lua")
include("autorun/server/sv_class_tablesearcher.lua")[/code]
And it doesn't work. Is there something I did wrong?
[editline]49[/editline]
nvm forgot to add a single line of code that included an important hook
[QUOTE=Reyjr43;45832577]Forgive me if this is a useless post, but have you tried taking a look at anything that uses its own animation system instead of Garry's? Like NutScript or Tiramisu(I believe?) they have a table of animations that is applied to players.
[/QUOTE]
I just tried looking at robot boys code for his animation tool gun and tested out some snippits of his codes to see if it will work on the player model and it still isn't yielding any results. This honestly is starting to make me wonder why Garrys mod doesn't just have some already built in easy library for controlling the animations on players and other models.
His tool: [url]http://steamcommunity.com/sharedfiles/filedetails/?id=104604709[/url]
It works just fine on npcs the animation entity he made for ragdolls it just doesn't do anything for your current playermodels.
I also tried messing with the function and looking at examples in nutscripts code to see how they did it but I couldn't get it to work.
[QUOTE=ROFLBURGER;45850387]I'm confused to how include() works
basically I coded this 22KB file and I think it's a clusterfuck so I split it up into 8 different lua files that fit.
In one file, I'm including all of it together. And made this one file in autorun/server with the following code
[code]
include("autorun/server/sv_class_falldamage.lua")
include("autorun/server/sv_class_perks_damage.lua")
include("autorun/server/sv_class_perks_passive.lua")
include("autorun/server/sv_class_spawning.lua")
include("autorun/server/sv_class_sprint.lua")
include("autorun/server/sv_class_tablesearcher.lua")[/code]
And it doesn't work. Is there something I did wrong?
[editline]49[/editline]
nvm forgot to add a single line of code that included an important hook[/QUOTE]
You don't include files from autorun/server that are in autorun/server, everything in autorun/server is executed automatically.
Hello everyone,
I am having a problem with freezing a spawned entity (a default hl2 weapon that is) in Mr. Gash deathrun.
Code to load/spawn the weapons from a text file:
[CODE]
local function LoadWeapons()
if not File then File = "deathrun/"..game.GetMap()..".txt" end
if not Load then
if not file.Exists( File, "DATA" ) then return end
local read = file.Read( File, "DATA" )
read = util.JSONToTable(read)
if not read then
file.Delete( File )
ServerLog( "Deleting "..File.." because of some weird as shit error.\n" )
return
end
Load = read
end
for k, v in pairs( Load ) do
local ent = ents.Create( v.ent )
if not IsValid(ent) then
MsgN( "Could not create "..v.ent.."! Please fix "..File )
continue
end
ent:SetPos( v.pos )
ent:SetAngles( v.ang )
ent:Spawn()
end
end
[/CODE]
Now, I did try to disable the motion of the weapon, just aswell as welding the weapon to the world, but without any luck!
I want it so, that weapons are frozen solid and cannot be moved with a shot or a crowbar hit, for example.
Thank you for reading!
Can we see the serialized structure?
Ok quick question how do I create a fake deathnotice?
I'm looking at this one weapon that does it and using some of the code doesn't work. It's also a mess so I don't understand what is going on.
This is the code I copied:
[code] umsg.Start( "PlayerKilledByPlayer" )
umsg.Entity( ply )
umsg.String( ply:GetActiveWeapon():GetClass() )
umsg.Entity( ply )
umsg.End()[/code]
[editline]31st August 2014[/editline]
It complains that it's an unhanded usermessage
[QUOTE=ROFLBURGER;45857970]Ok quick question how do I create a fake deathnotice?
I'm looking at this one weapon that does it and using some of the code doesn't work. It's also a mess so I don't understand what is going on.
This is the code I copied:
[code] umsg.Start( "PlayerKilledByPlayer" )
umsg.Entity( ply )
umsg.String( ply:GetActiveWeapon():GetClass() )
umsg.Entity( ply )
umsg.End()[/code]
[editline]31st August 2014[/editline]
It complains that it's an unhanded usermessage[/QUOTE]
You must be looking at old code. [url]https://github.com/garrynewman/garrysmod/blob/a4b68ce3e07f4a8f016343f65216debae6a03cd6/garrysmod/gamemodes/base/gamemode/player.lua#L184-L190[/url]
Sorry, you need to Log In to post a reply to this thread.