• What do you need help with? V3
    6,419 replies, posted
[QUOTE=hellguy;39490878]I've fixed my vipspawn script, but I can't get this 1 shot glory gun to work, shouldn't hurt innocents, but it does. [CODE]function SWEP:PrimaryAttack()for k, ply in pairs( player.GetAll() ) do if ( !self:CanPrimaryAttack() ) then return end if ply:IsActiveTraitor() then self:ShootBullet( 150, 1, 0.01 ) self:TakePrimaryAmmo( 1 ) self:EmitSound("Weapon_Deagle.Single") self.Owner:ViewPunch( Angle( -1, 0, 0 ) ) end end end[/CODE][/QUOTE] Why is that player.GetAll() loop still there, if you listened to my advice instead of calling me a smartass your code would be fixed by now. [editline]6th February 2013[/editline] [QUOTE=Persious;39485376]ULX groups go under player:GetUserGroup() == "usergroup" - Or at least that works for me.[/QUOTE] Sadly that's not a function, here's how we solved it in PointShop: [url]https://github.com/adamdburton/pointshop/blob/master/lua/sh_player_extension.lua#L5[/url]
[QUOTE=Agent766;39490042]How can I set an NPC's idle animation? I'm trying to call self:SetSequence, but it only seems to be playing the animation once.[/QUOTE] I guess a better question is how do I properly play sequences? I'm trying [lua]local tab = {} tab.ID = 1 tab.Name = "Open_door_away" ref:TaskStart_PlaySequence( tab )[/lua] to play a giving animation, but the NPC dies or disappears (???) after playing the animation. No clue what's going on there. Maybe it does that after the schedule ends. And the only way I got the idle animation to work was self:SetSequence in ENT:Think. I'm fairly certain that's not right.
Is it possible to create a Derma panel that constantly stays there? Sort of like a Hud element? Or is there a way to easily render models on the HUD?
[QUOTE=Matt-;39491817]Why is that player.GetAll() loop still there, if you listened to my advice instead of calling me a smartass your code would be fixed by now. [editline]6th February 2013[/editline] I don't know how to retire playergetall loop without braking the code, if I don't place it there, when I try shooting the weapon it says 'ply' is a nil value Sadly that's not a function, here's how we solved it in PointShop: [url]https://github.com/adamdburton/pointshop/blob/master/lua/sh_player_extension.lua#L5[/url][/QUOTE]
[QUOTE=hellguy;39493787][/QUOTE] Alright, I'll help him. Your code isn't working because the do loop you have (this bit) [CODE]for k, ply in pairs( player.GetAll() ) do[/CODE] is looping through every player on the server, and detecting if they are a traitor. Because there is (presumably) always at least one traitor, it will always be true, and always fire (at least) one bullet. This obviously isn't the intended behavior, but that's okay! To fix it, I would suggest getting an eye trace before firing any bullets, and then detecting if the TraceRes entity is: a. valid, b. a player, and then c. a traitor. If it passes all of these checks, then you can fire your damaging bullet, and otherwise you can fire a very weak one or something similar. If you put in these changes, your code should look something like this: [url]http://pastebin.com/ZF2ckD7E[/url] EDIT: Oh, whoops, you're right. Fixed it in the example, I'm silly.
Hey, just started trying to learn some basic lua, and I've been tinkering around with some simple stuff using lua_run for a while now. So anyway, after finding out that you can't re-ignite something until Extinguish is called on it, I decided to try and make a simple script that ignites someone for an x amount of seconds, and then extinguishes them x+1 seconds later, however i'm having some problems with the timer function, or atleast I think that's my problem. This is what i've been doing. lua_run prop:Ignite(ignitetime):timer.Simple(ignitetime+1, function() prop:Extinguish() end) And this is the error i've been having. [ERROR] lua_run:1: function arguments expected near '.' 1. unknown - lua_run:0 Probably something super simple i've overlooked, please help.
change the colon ":" after ignite to a space (maybe a semi colon ";") EDIT: it might have to be wrapped in a function.
I need some help from some of you. I've start learning LUA today, I kind of know the basics because I'm learning C# and C++ and some things are familiar to me. Anyway I'm watching MrCosmicSeagull tutorials and I understand everything is in the tutorial. The problem is that the code is tested in Gmod 12 and I've seen that there are things that are differently like the HUD [b]FROM[/b] [LUA] surface.CreateFont("ScoreboardText", 40, 250, false, false, "MyFont") [/LUA] [b]TO[/b] [LUA] surface.CreateFont( "Myfont", { font = "DefaultBold", -- Not file name, font name size = 24, weight = 400, antialias = true, shadow = true } [/LUA] Is any place were I could find all the changes that were made in Gmod 13 ?? Or how all the coders find out what they have to write instead of the old version ?
[QUOTE=randomscript;39493984]Alright, I'll help him. Your code isn't working because the do loop you have (this bit) [CODE]for k, ply in pairs( player.GetAll() ) do[/CODE] is looping through every player on the server, and detecting if they are a traitor. Because there is (presumably) always at least one traitor, it will always be true, and always fire (at least) one bullet. This obviously isn't the intended behavior, but that's okay! To fix it, I would suggest getting an eye trace before firing any bullets, and then detecting if the TraceRes entity is: a. valid, b. a player, and then c. a traitor. If it passes all of these checks, then you can fire your damaging bullet, and otherwise you can fire a very weak one or something similar. If you put in these changes, your code should look something like this: [URL]http://pastebin.com/ReGKc9gc[/URL][/QUOTE] Thank you for being so informative and helpfull! This totally fit my needs, and I'll test it and tell you later if it works, thank you again. EDIT: Works like a charm! Thank you verryyyyy muuuuch! I only had to take that "end" before "else" to near the other "end"s, because it was making the weapon not hurt innocents at all : P.
[QUOTE=R@Rdeathmatch;39494908]I need some help from some of you. I've start learning LUA today, I kind of know the basics because I'm learning C# and C++ and some things are familiar to me. Anyway I'm watching MrCosmicSeagull tutorials and I understand everything is in the tutorial. The problem is that the code is tested in Gmod 12 and I've seen that there are things that are differently like the HUD [b]FROM[/b] [LUA] surface.CreateFont("ScoreboardText", 40, 250, false, false, "MyFont") [/LUA] [b]TO[/b] [LUA] surface.CreateFont( "Myfont", { font = "DefaultBold", -- Not file name, font name size = 24, weight = 400, antialias = true, shadow = true } [/LUA] Is any place were I could find all the changes that were made in Gmod 13 ?? Or how all the coders find out what they have to write instead of the old version ?[/QUOTE] [url]https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit?pli=1[/url] it is almost everything, it's from garrysmod.com
[QUOTE=Pandaman09;39494971][url]https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit?pli=1[/url] it is almost everything, it's from garrysmod.com[/QUOTE] I found this, but that's not everything. And if I am creating a dedicated server in server.cfg - sv_defaultgamemode or sv_gamemode are not recognized.
[QUOTE=R@Rdeathmatch;39495025]I found this, but that's not everything. And if I am creating a dedicated server in server.cfg - sv_defaultgamemode or sv_gamemode are not recognized.[/QUOTE] it's gamemode now.
Could someone help me ?? [ERROR] lua/autorun/client/hud.lua:8: attempt to index global 'GM' (a nil value) [LUA] function HUDHide(myhud) for k, v in pairs{"CHudHealth","CHudBattery"} do if myhud == v then return false end end end hook.Add("HUDShouldDraw","HUDHide",HUDHide) function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() local HP = LocalPlayer():Health() local ARM = LocalPlayer():Armor() surface.CreateFont("ScoreboardText", 40, 250, false, false, "MyFont") surface.SetTextColor(20,180,50,255) surface.SetTextPos(20,20) surface.SetFont("MyFont") surface.DrawText(HP) end [/LUA]
I still need help with my problem. I made a thread a couple of days ago and posted in here twice now and have not been able to fix it. [url]http://www.facepunch.com/showthread.php?t=1244474[/url] [b]Notes:[/b] Been tested in both Dedicated and Local Server I've had the net library (clientside) loaded before anything else It works if I reload clientside after loading in I need help fixing or just a command similar to the old "gamemode_reload_cl" would be fine with me but I do not know if the command like that exists anymore
[QUOTE=Annoyed Tree;39495197]I still need help with my problem. I made a thread a couple of days ago and posted in here twice now and have not been able to fix it. [url]http://www.facepunch.com/showthread.php?t=1244474[/url] [b]Notes:[/b] Been tested in both Dedicated and Local Server I've had the net library (clientside) loaded before anything else It works if I reload clientside after loading in I need help fixing or just a command similar to the old "gamemode_reload_cl" would be fine with me but I do not know if the command like that exists anymore[/QUOTE] Are you using any hooks? Are you sending information as soon as possible? You may need to add a timer of a few seconds (1-5 depending on when your calling it) so that the client is fully loaded before the information is sent.
[QUOTE=R@Rdeathmatch;39495178]Could someone help me ?? [ERROR] lua/autorun/client/hud.lua:8: attempt to index global 'GM' (a nil value)[/QUOTE] Aren't you supposed to hook into HUDPaint? Also, you're not using the ply variable you defined, and while it's not going to cause any errors, it's a little wasteful. You should probably use it to define your HP and armor variables, as in [CODE]local HP = ply:Health()[/CODE]
[QUOTE=Pandaman09;39495230]Are you using any hooks? Are you sending information as soon as possible? You may need to add a timer of a few seconds (1-5 depending on when your calling it) so that the client is fully loaded before the information is sent.[/QUOTE] No hooks being called and I've already tried putting a 1 second timer on it
[QUOTE=Annoyed Tree;39495288]No hooks being called and I've already tried putting a 1 second timer on it[/QUOTE] Do you know when your sending the information, I saw someone say that they wait 5 seconds before sending data files.
[b]Here is a list with almost everything that has been added,removed,fixed in gmod (Update 143)[/b] [url]https://dl.dropbox.com/u/16648713/Added%20and%20Removed.txt[/url]
[QUOTE=Pandaman09;39495365]Do you know when your sending the information, I saw someone say that they wait 5 seconds before sending data files.[/QUOTE] I first send it on PlayerInitalSpawn
[QUOTE=Annoyed Tree;39495573]I first send it on PlayerInitalSpawn[/QUOTE] That's not safe, try to do PlayerAuthed, that's what I do.
[QUOTE=randomscript;39495243]Aren't you supposed to hook into HUDPaint? Also, you're not using the ply variable you defined, and while it's not going to cause any errors, it's a little wasteful. You should probably use it to define your HP and armor variables, as in [CODE]local HP = ply:Health()[/CODE][/QUOTE] Ok, but I still get that error.
Alright. I'll try it when I get home thanks for the response though I'll let you know if it works
[QUOTE=R@Rdeathmatch;39495178]Could someone help me ?? [ERROR] lua/autorun/client/hud.lua:8: attempt to index global 'GM' (a nil value) [LUA] function HUDHide(myhud) for k, v in pairs{"CHudHealth","CHudBattery"} do if myhud == v then return false end end end hook.Add("HUDShouldDraw","HUDHide",HUDHide) function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() local HP = LocalPlayer():Health() local ARM = LocalPlayer():Armor() surface.CreateFont("ScoreboardText", 40, 250, false, false, "MyFont") surface.SetTextColor(20,180,50,255) surface.SetTextPos(20,20) surface.SetFont("MyFont") surface.DrawText(HP) end [/LUA][/QUOTE] You don't use gamemode hooks in non gamemode code, use hook.Add instead. [editline]6th February 2013[/editline] [QUOTE=Annoyed Tree;39495197]I still need help with my problem. I made a thread a couple of days ago and posted in here twice now and have not been able to fix it.[/QUOTE] Check your thread. [editline]6th February 2013[/editline] [QUOTE=Annoyed Tree;39495197]I need help fixing or just a command similar to the old "gamemode_reload_cl" would be fine with me but I do not know if the command like that exists anymore[/QUOTE] Files automatically reload now.
So i'm trying to get the slots from elevator source working on this map, it all seems to work perfect in single player, but when I put it on our server I get this. [code][ERROR] ...emode/modules/theater/ents/entities/slotmachine/init.lua:254: attempt to index local 'ply' (a nil value) 1. SendPlaying - ...emode/modules/theater/ents/entities/slotmachine/init.lua:254 2. unknown - ...emode/modules/theater/ents/entities/slotmachine/init.lua:185 [/code] Lines 163-190 [lua]function ENT:Use( ply ) if !IsValid(ply) || !ply:IsPlayer() then return end if ( ply:GetBilliardTable() ) then --GAMEMODE:PlayerMessage( ply, "Warning!", "You cannot play slots while you are in a billiards game.\nYou must quit your billiards game!" ) ply:PrintMessage( HUD_PRINTTALK, "You cannot play slots while you are in a billiards game.\nYou must quit your billiards game!" ) return end if !self:IsInUse() then self:SetupVehicle() if !IsValid(self.chair) then return end -- just making sure... ply.SeatEnt = self.chair ply.EntryPoint = ply:GetPos() ply.EntryAngles = ply:EyeAngles() ply:EnterVehicle( self.chair ) self:SendPlaying( ply ) else return end end[/lua] 236-264 [lua] function ENT:GetPlayer() local ply = player.GetByID( self.SlotsPlaying ) if IsValid(ply) && ply:IsPlayer() && self:IsInUse() then return ply end end function ENT:SendPlaying() if ( !IsValid( self ) || !IsValid(self.chair) ) then return end self.SlotsPlaying = self.chair:GetDriver():EntIndex() self.LastSpin = CurTime() local ply = self:GetPlayer() ply.SlotMachine = self local rf = RecipientFilter() rf:AddPlayer( ply ) umsg.Start("slotsPlaying", rf) umsg.Short( self:EntIndex() ) umsg.End() end [/lua] If someone can help me out with this that would be great.
try adding a [lua]if not (ply) then return end[/lua] check after it is defined
Set self.SlotsPlaying to an actual player object instead of a player id, it'll be a lot easier for you then.
[QUOTE=ZachPL;39497241]umsg.Start("slotsPlaying", rf) umsg.Short( self:EntIndex() ) umsg.End()[/QUOTE] Someone told me that umsg got removed in favor of the net library; is there any base to that claim?
[QUOTE=JVanover;39499778]Someone told me that umsg got removed in favor of the net library; is their any base to that claim?[/QUOTE] Datastream was removed not usermessages.
I tried using "resource.AddFile", also tried using this script [url]http://pastebin.com/qkMtWr6B[/url] , but nothing works, the players even seem to be downloading stuff(materials, sounds, models, and textures) from my server(dedicated), but they don't.
Sorry, you need to Log In to post a reply to this thread.