• What do you need help with? V3
    6,419 replies, posted
Is there a way you can have a player move in a direction independent of their eyeangles? Like having a playing walk North when they are pressing forward but have the eyeangles set North East? EDIT: Figured it out, run this server side [lua]function GM:SetupMove(ply, mv) mv:SetMoveAngles(Angle(0, 0, 0)) end[/lua]
I am trying to make a script that prints a message when the player goes below 30 health. I am very new to lua and this script currently only works if I run it after I have less than 30 health and prints it every tick which I guess is a cause from the "Think" hook. How should a script to do this look? [lua] local health = LocalPlayer():Health() function LowHealth() if health < 30 then print("You are on low health") end end hook.Add("Think", "HealthReminder", LowHealth) [/lua] Any help will be appreciated.
[lua] function LowHealth() local health = LocalPlayer():Health() if health < 30 then print("You are on low health") end end hook.Add("Think", "HealthReminder", LowHealth) [/lua] LocalPlayer():Health() wasn't getting called only one, it's not a pointer it returns a value so that same value was being used over and over.
[QUOTE=Jeffman12;39165039]Is there a way to detect if a player only has partial footing? Like, say they walk up to a ledge and half their player model is just suspended in the air.[/QUOTE] You could do some TraceHulls on the front of the player and on the back to check if they're partially on a ledge.
I have an entity that checks if a player using the entity has a certain weapon, yet the function doesn't work. [lua] function ENT:Use(ply) if IsValid(ply) and ply:IsPlayer() then if not table.HasValue(ply:GetWeapons(),"weapon_swep") then ply:Give("weapon_swep") self:Remove() end end end [/lua] After breif debugging, I found that the table consists of strings that appear similar to this: Weapon [32][weapon_pistol] How would I get just the entity name of a weapon table?
if not ply:HasWeapon( "weapon_swep" ) then?
I need help getting TTT to stop automatically switching maps ever. I want it to be handle completely by my in-game addons.
[QUOTE=thejjokerr;39178155]You can use :GetClass() on it, the Weapon class is based of the Entity class like players and vehicles.[/QUOTE] I tried this method, but couldn't find where it put the GetClass in my table. If only you could specify "internal" commands for functions. I was looking for this function a while ago, so this will prove useful elsewhere in the entity. [QUOTE=.\\Shadow};39178320]if not ply:HasWeapon( "weapon_swep" ) then?[/QUOTE] This one works perfectly. Thank you guys for the help!
Could someone help me make certain jobs spawn with weapons in darkrp ?
Is there a a way to overwrite the sound played when the player walks? I moved the camera far away but the footsteps are played locally so they are still as loud as if I had the camera at the model's eyes.
In gamemode development I am creating a number of tables and wanted to set some functions up like player.getId, player.load, player.insert : that would update the database or make calls. I noticed however that there is a table already called player [code] GetHumans = function: 0xabe6c630 GetAll = function: 0xabe6c668 GetByUniqueID = function: 0xabdad1e0 GetByID = function: 0xabe6c5f0 GetBots = function: 0xabe6c688 [/code] So instead of using player.load, I switched over to user.load etc. Is it considered OK or even possible to extend the player table? I just want to stick to best practices. It is also possible I haven't made it far enough to ask the right question.
[QUOTE=HarryMudd;39180796]In gamemode development I am creating a number of tables and wanted to set some functions up like player.getId, player.load, player.insert : that would update the database or make calls. I noticed however that there is a table already called player [code] GetHumans = function: 0xabe6c630 GetAll = function: 0xabe6c668 GetByUniqueID = function: 0xabdad1e0 GetByID = function: 0xabe6c5f0 GetBots = function: 0xabe6c688 [/code] So instead of using player.load, I switched over to user.load etc. Is it considered OK or even possible to extend the player table? I just want to stick to best practices. It is also possible I haven't made it far enough to ask the right question.[/QUOTE] Instead of using the player library, I'd extend the player metatable instead. [lua] local Player = FindMetaTable('Player') function Player:Load() -- your code here, the variable 'self' is the player end [/lua]
What is wrong with my code ? [code] [ERROR] lua/autorun/server/ghost.lua:2: unexpected symbol near '=' 1. unknown - lua/autorun/server/ghost.lua:0 [/code] [lua] function fix_thatshit(ply) ply:NextSpawnGhost() = true end concommand.Add("problem", fix_thatshit) [/lua] EDIT : Solved
[QUOTE=ExtReMLapin;39181311]What is wrong with my code ? [code] [ERROR] lua/autorun/server/ghost.lua:2: unexpected symbol near '=' 1. unknown - lua/autorun/server/ghost.lua:0 [/code] [lua] function fix_thatshit(ply) ply:NextSpawnGhost() = true end concommand.Add("problem", fix_thatshit) [/lua][/QUOTE] Please read the lua pil... Well here, you're trying to call a function and setting it to true like a variable. That doesn't work. If you want to call a function called NextSpawnGhost then just use ply:NextSpawnGhost(). If you want to call it with a true parameter do ply:NextSpawnGhost( true ). If you want to set the variable to true do ply.NextSpawnGhost = true.
Thanks.
Is there another way I can set the FOV without setting it in calcview? If I change it using calcview it messes up my screentovector function but if I use ply:SetFOV elsewhere it works. The problem with that is whenever the player jumps or shoots it runs SetFOV again from the starting fov of 75 so you see the camera jump way back and forth for a second. EDIT: Setting the fov in playerspawn serverside seems to do the trick. Sweps override it but I'm sure I can override that in the sweps or somewhere else.
[QUOTE=ideal-gaming;39179951]Could someone help me make certain jobs spawn with weapons in darkrp ?[/QUOTE] Maybe if you specify what job... until then here [CODE]TEAM_THEIF = AddExtraTeam("Theif", { color = Color(150, 20, 20, 255), model = "models/player/t_arctic.mdl", description = [[ Theif. Steal stuff from people, you may raid with more than just yourself.]], weapons = {"lockpick"}, // right here is where weapons go if you dont want it to have a weapon then change it to > weapons = {}, if you want more than one weapon then do this, weapons {"lockpick", "gunnamehere"}, command = "theif", max = 2, salary = 50, admin = 0, vote = false, hasLicense = false, })[/CODE] Put it in gamemodes/darkrp/shared.lua This is a "theif" class if you respond here with whatever job you wanted then I'll make it for you.
I'm having a problem where the code doesn't seem to update at all after I edit it, and I mean it doesn't load the file at all. Anybody else having that problem?
[QUOTE=Fatman55;39183218]I'm having a problem where the code doesn't seem to update at all after I edit it, and I mean it doesn't load the file at all. Anybody else having that problem?[/QUOTE] With SV_AutoRefresh set to 1? If so, [url]http://www.facepunch.com/showthread.php?t=1233767[/url]. It's been happening to a lot of people with legacy addons.
Thing is it's not even giving me an error, and I should have mentioned that I'm working on a gamemode. Also yeah I have auto refresh on. [editline]11th January 2013[/editline] Oh wow I feel stupid now, I accidentally opened steam in another drive and was running the GMod copy off of it. [editline]11th January 2013[/editline] Which would explain why it's happened a few times for me. :v:
I shall repost this. Im trying to make the player spectate when he first connects. As of right now, when someone joins they get the weird defualt model of that grey thing, even though I set them to spectate on first join. Here's my initial spawn code: [LUA]function GM:PlayerInitialSpawn( ply ) umsg.Start( "Welcome" , ply ) umsg.End() ply:ConCommand( "change_team" ) //Run the console command when the player first spawns ply:Spectate( 5 ) end [/LUA] [IMG]http://gyazo.com/cd712903a0b4f35d0bdb83d8453c8514.png?1357861650[/IMG]
Getting this error: [code] [ERROR] gamemodes/afterlife/gamemode/cl_init.lua:146: bad argument #1 to 'pairs' (table expected, got nil) 1. pairs - [C]:-1 2. unknown - gamemodes/afterlife/gamemode/cl_init.lua:146 [/code] cl_init.lua [lua] if Pay or not Job then for k, v in pairs(Jobs) do if ply:GetDTInt(1) == v.number then Pay = v.pay Job = v.job break end end end [/lua] jobs.lua [lua] Jobs = {} function A_RegisterJob(number, job, model, pay, weapon, ammo, description, max, whitelist, canbuy, itemtype) table.insert(Jobs, {number = number, job = job, model = model, pay = pay, weapon = weapon, ammo = ammo, description = description, max = max, whitelist = whitelist, canbuy = canbuy, itemtype = itemtype}) end [/lua]
Help needed, Unexpected symbol near ',' [CODE]self:DrawInformation(self.configuration)"Website URL", "ChatFont", ScrW(), ScrH(), Color(255, 255, 255, 255), 255, true, function ( x, y, width, height )[/CODE] Thanks for any help.
HELP! I wanna make it so players dont collide on deathrun but I have failed to do so after many attempts. My gamemode: [url]http://www.garrysmod.org/downloads/?a=view&id=133166[/url] I don't know what to edit I've tried many things such as adding p:SetCollisionGroup(COLLISION_GROUP_WEAPON) in init.lua but with no results. I have tried many other things but it just won't work.
Don't you have to call EnableCustomCollisions or something?
[QUOTE=lope;39183955]I shall repost this. Im trying to make the player spectate when he first connects. As of right now, when someone joins they get the weird defualt model of that grey thing, even though I set them to spectate on first join. Here's my initial spawn code: [LUA]function GM:PlayerInitialSpawn( ply ) umsg.Start( "Welcome" , ply ) umsg.End() ply:ConCommand( "change_team" ) //Run the console command when the player first spawns ply:Spectate( 5 ) end [/LUA] [IMG]http://gyazo.com/cd712903a0b4f35d0bdb83d8453c8514.png?1357861650[/IMG][/QUOTE] Have you tried adding a delay or calling GM:PlayerInitialSpawn after they've spawned?
I've tried everything I have found on google hasn't worked out. I don't know what will work. I really need this.
In my custom swep shared filed I have this shooteffect hook, it doesn't seem to be working though. Is this not where I should be using these hooks? [lua]function SWEP:ShootEffects() self:SendWeaponAnim( ACT_VM_THROW ) // View model animation self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation self.Owner:MuzzleFlash() // Crappy muzzle light end[/lua]
[QUOTE=Hyper Iguana;39185071]Have you tried adding a delay or calling GM:PlayerInitialSpawn after they've spawned?[/QUOTE] Yes, it worked, and thank you for responding.
1. Is there any documentation on making and loading GWEN skins? 2. For making a simple menu, is it practical to just use surface/draw library functions + click hooks, instead of DButtons?
Sorry, you need to Log In to post a reply to this thread.