• What do you need help with? V3
    6,419 replies, posted
Trying to fix a SWEP for GMOD 13: [lua] [ERROR] addons/gimnade/lua/weapons/weapon_gimnade/shared.lua:363: attempt to call method 'SecondThink' (a nil value) 1. unknown - addons/gimnade/lua/weapons/weapon_gimnade/shared.lua:363 [/lua] Here is that bit [lua] function SWEP:Think() self:SecondThink() if (self.Owner:KeyDown(IN_SPEED) and self.Owner:GetNetworkedInt("Primed") == 0) or self.Weapon:GetNetworkedBool("Holsted") then if self.Rifle or self.Sniper or self.Shotgun then if (SERVER) then self:SetWeaponHoldType("passive") end elseif self.Pistol then if (SERVER) then self:SetWeaponHoldType("normal") end end else if (SERVER) then self:SetWeaponHoldType(self.HoldType) end end if (self.Owner:GetNetworkedInt("Primed") == 1 and not self.Owner:KeyDown(IN_ATTACK)) then if self.Owner:GetNetworkedInt("Throw") < CurTime() then self.Owner:SetNetworkedInt("Primed", 2) self.Owner:SetNetworkedInt("Throw", CurTime() + 1.5) if not self.Owner:Crouching() then self.Weapon:SendWeaponAnim(ACT_VM_THROW) end self.Owner:SetAnimation(PLAYER_ATTACK1) timer.Simple(0.35, function() if not self.Owner then return end self:ThrowGrenade() self.Owner:ViewPunch(Vector(math.Rand(1, 2), math.Rand(0, 0), math.Rand(0, 0))) end) end end if self.Owner:GetNetworkedBool("Cooked") and self.Owner:GetNetworkedBool("LastShootCook") < CurTime() then if ((SinglePlayer() and SERVER) or CLIENT) then self.Weapon:SetNetworkedFloat("LastShootTime", CurTime()) self.Owner:EmitSound("npc/dog/dog_idle3.wav") end self.Owner:SetNetworkedBool("LastShootCook", CurTime() + 1) end end [/lua] I appreciate the time you give to this, thanks a ton.
[QUOTE=Apozen;39605331]Trying to fix a SWEP for GMOD 13: [lua] [ERROR] addons/gimnade/lua/weapons/weapon_gimnade/shared.lua:363: attempt to call method 'SecondThink' (a nil value) 1. unknown - addons/gimnade/lua/weapons/weapon_gimnade/shared.lua:363 [/lua] Here is that bit [lua] function SWEP:Think() self:SecondThink() if (self.Owner:KeyDown(IN_SPEED) and self.Owner:GetNetworkedInt("Primed") == 0) or self.Weapon:GetNetworkedBool("Holsted") then if self.Rifle or self.Sniper or self.Shotgun then if (SERVER) then self:SetWeaponHoldType("passive") end elseif self.Pistol then if (SERVER) then self:SetWeaponHoldType("normal") end end else if (SERVER) then self:SetWeaponHoldType(self.HoldType) end end if (self.Owner:GetNetworkedInt("Primed") == 1 and not self.Owner:KeyDown(IN_ATTACK)) then if self.Owner:GetNetworkedInt("Throw") < CurTime() then self.Owner:SetNetworkedInt("Primed", 2) self.Owner:SetNetworkedInt("Throw", CurTime() + 1.5) if not self.Owner:Crouching() then self.Weapon:SendWeaponAnim(ACT_VM_THROW) end self.Owner:SetAnimation(PLAYER_ATTACK1) timer.Simple(0.35, function() if not self.Owner then return end self:ThrowGrenade() self.Owner:ViewPunch(Vector(math.Rand(1, 2), math.Rand(0, 0), math.Rand(0, 0))) end) end end if self.Owner:GetNetworkedBool("Cooked") and self.Owner:GetNetworkedBool("LastShootCook") < CurTime() then if ((SinglePlayer() and SERVER) or CLIENT) then self.Weapon:SetNetworkedFloat("LastShootTime", CurTime()) self.Owner:EmitSound("npc/dog/dog_idle3.wav") end self.Owner:SetNetworkedBool("LastShootCook", CurTime() + 1) end end [/lua] I appreciate the time you give to this, thanks a ton.[/QUOTE] [lua] self:SecondThink() [/lua] seems this is a nil function.
I want a Derma Panel to pop up on Death, but how would you call for the panel to appear without using a concommand as I would not want anyone to use the command when they are not dead? Would I use a convar?
[QUOTE=Gaming_Unlim;39605832]I want a Derma Panel to pop up on Death, but how would you call for the panel to appear without using a concommand as I would not want anyone to use the command when they are not dead? Would I use a convar?[/QUOTE] Use the [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbdc5.html"]PlayerDeath[/URL] hook and then code a derma panel.
Does anyone know how I can seperate the contents of derma panels/lists from it's parent by putting them into different lua files? I tried using include, but didn't get any working results.. The contents are there, but they won't parent to the DermaList. Gives me the basic [code] [ERROR] gamemodes/darkrp/gamemode/client/ammo.lua:192: attempt to index global 'StoreList' (a nil value) [/code] I'm doing this because I hit the maximum number of local variables [B]Edit:[/B] Nevermind, fixed it. I had to create a new global function and then call it in my first function.
Little pattern help required here: I need a pattern that on a string such as "abcd" matches the substrings "ab, bc, cd" Any ideas? Using ".." returns "ab, cd" which is not what I want
I'm trying to find where the Q menu (Build menu) is disabled on the ZE gamemode. Link to folder [url]http://soapface.x10.mx/gmod-dl/gamemodes/ZombieEscape/gamemode/[/url] Can't seem to find it.
[QUOTE=Loures;39608173]Little pattern help required here: I need a pattern that on a string such as "abcd" matches the substrings "ab, bc, cd" Any ideas? Using ".." returns "ab, cd" which is not what I want[/QUOTE] You can't do that with a pattern [lua] function substrings(str) local subStr = {} for i=1, #str-1 do subStr[i] = str:sub(i, i+1) end return subStr end [/lua]
Yeah, thought so, thanks ralle!
[QUOTE=soupface;39608452]I'm trying to find where the Q menu (Build menu) is disabled on the ZE gamemode. Link to folder [url]http://soapface.x10.mx/gmod-dl/gamemodes/ZombieEscape/gamemode/[/url] Can't seem to find it.[/QUOTE] The gamemode isn't derived from Sandbox: [url]http://soapface.x10.mx/gmod-dl/gamemodes/ZombieEscape/gamemode/shared.lua[/url] line 5
[QUOTE=_Undefined;39608460]The gamemode isn't derived from Sandbox: [url]http://soapface.x10.mx/gmod-dl/gamemodes/ZombieEscape/gamemode/shared.lua[/url] line 5[/QUOTE] Ah, is it possible to enable it for Admins only?
[QUOTE=soupface;39608542]Ah, is it possible to enable it for Admins only?[/QUOTE]Not being derived from sandbox means it is not derived from base meaning there is no spawn menu.
[QUOTE=soupface;39608542]Ah, is it possible to enable it for Admins only?[/QUOTE] No, you'd most likely have lots of fixing to do.
I want to know how to get the server/host's tick rate. That means I want to retrieve the rate that the game acts, per second, and use it. Supposedly think is faster than tick, so getting how often that happens would be nice, too. I've noticed that in Mario, when you jump it keeps going up at the same rate as you hold the button down, until you get so high, and I want to imitate that. To do it properly, I need these values and every time I use a timer it breaks. I just need to know one of them, tick rate or think rate of the localplayer.
I need help with a function that prints a message on your screen if someone gets x amount of kills in under x amount of minutes. Any help would be appreciated.
Trying to create a weapon that will switch between hold-types using SetWeaponHoldType when a key is pressed (a simple holster system so to speak) Everything with the SWEP works, except the hold-type does not change for other players; In third-person I can see the hold-type change on the client, but SetWeaponHoldType is not changing the hold type for other clients, I am running it on both the client and server. I've tried a lot of combinations of things to get this to work and am having no luck, SetWeaponHoldType only seems to work when setting it during the SWEP's Init, Can I use SetWeaponHoldType like this to update the hold-type so other players can see the change as well? If someone could show and example of how to get this to work I'd be grateful.
Could someone help me? Getting this error: [CODE][ERROR] LuaCmd:1: ')' expected near 's' 1. unknown - LuaCmd:0 [/CODE] Here is my code: [url]http://pastebin.com/J5MMTDzv[/url]
-snip-
[QUOTE=TheDeadlyHaze;39612046]I need help with a function that prints a message on your screen if someone gets x amount of kills in under x amount of minutes. Any help would be appreciated.[/QUOTE] Okay, here's roughly how I would do it: I would create a variable, the time you want to use, and another one, the time we started checking, and one more, the total kills. The time we want to use, we divide it into the kills you want. If that much time passes and there is no new kill, we reset the total kills to 0. If total kills equals the amount you want AND curtime() = start time + the time you want, you print the message. When you print it, if you want it to print again, if it happens again, then reset all of the variables to their defaults at that time. If there's anything where you don't know how to do it, check the wiki (I prefer the Maurits one since it actually has a search bar) [editline]16th February 2013[/editline] Anyways, just to re-iterate my question since it's getting lost in the slew of posts... :tinfoil: I just need to know one of these, tick rate (Time per tick or ticks per second) or think rate (without next think time being set, the default rate at which the think function runs, per second or the time between thinks) of the localplayer. So, how to find the server/host tick rate with lua, or the think rate (which is faster,) again, with lua.
Can someone post a snippet of code showing how to use 3D2D? I've been playing around with it but can't really get it working.
[lua] hook.Add( "PostDrawOpaqueRenderables", "GraffitiDraw", function() cam.Start3D2D( Vector(0,0,0), Angle(0,0,0), 1 ) draw.DrawText("Test", "TargetIDSmall", 0, 0, Color(175,0,0), TEXT_ALIGN_CENTER ) cam.End3D2D() end) [/lua] You need to play around with the angle and vector.
[QUOTE=theVendetta;39614481][lua] hook.Add( "PostDrawOpaqueRenderables", "GraffitiDraw", function() cam.Start3D2D( Vector(0,0,0), Angle(0,0,0), 1 ) draw.DrawText("Test", "TargetIDSmall", 0, 0, Color(175,0,0), TEXT_ALIGN_CENTER ) cam.End3D2D() end) [/lua] You need to play around with the angle and vector.[/QUOTE] thank you sir, much obliged.
My previous developer seems to have modified this... Whenever the door charge is used in-game, the door respawns without a handle and it removes the owner that was previously on the door... Any ideas? Code is below for door respawning: [code] function GM:RespawnDoor(tr) -- if IsValid(tr) then if ( tr.Entity:GetClass( ) == "prop_door_rotating") then local old_pos = tr.Entity:GetPos() local door = ents.Create("prop_door_rotating") /* local children = tr.Entity:GetChildren() --CountChildren() for i=1,#children do local temp_child=tr.Entity:GetChild(i) temp_child:SetParent(door) end */ door:SetModel( tr.Entity:GetModel( ) ) door:SetSkin( tr.Entity:GetSkin( ) ) door:SetAngles( tr.Entity:GetAngles( ) ) door:Spawn() tr.Entity:Remove() timer.Simple( GAMEMODE.Config.door_respawn, function( ) door:SetPos(old_pos) door:Activate() end ) end end [/code]
[QUOTE=Gotty;39614624]My previous developer seems to have modified this... Whenever the door charge is used in-game, the door respawns without a handle and it removes the owner that was previously on the door... Any ideas? Code is below for door respawning: -snip code- [/QUOTE] [code]timer.Simple( GAMEMODE.Config.door_respawn, function( ) [/code] would make the door respawn and the owner is never grabbed/set when the door is respawned.
If my memory serves me any justice, doesn't 3D2D convert 2D information into a 2D image in 3D space? IE: If I told it's pos to be LocalPlayer():GetShootPos()+(LocalPlayer():GetAimVector()*3) and I made it's angle face directly at the shoot pos, I could draw a HUD right in front of the player's eyes? I think in that case, only the local player can see it. Oh, wait, seeing as how everyone thinks I can't do anything with Lua, I suppose I should say "Someone with decent Lua experience, and a good memory of it..."
Im trying to get a model from garrysmod.org to appear in game in my gamemode as a test but it refuses to show up for whatever reason. Heres what it says: Model missing: models/characters/Nanosuit2/NanoSuit_player.mdl I don't know why but still, it's frustrating me. I just don't know what to do! I mean, I have it in my gamemodes' folder, in my models folder and it still won't show up... Edit: Also, for some reason, the weapons that i have downloaded from garrysmod.org won't show up in my gamemode. Again, no clue why. [CODE][AddCSLuaFile] Couldn't find 'weapons/famas/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/famasscript/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/g36c/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/g36cscript/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/lk05/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/lk05particles/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/lk05script/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/scar/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/scarscript/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/spas-12/shared.lua' (<nowhere>) [/CODE]
[QUOTE=joshuadim;39614897]Im trying to get a model from garrysmod.org to appear in game in my gamemode as a test but it refuses to show up for whatever reason. Heres what it says: Model missing: models/characters/Nanosuit2/NanoSuit_player.mdl I don't know why but still, it's frustrating me. I just don't know what to do! I mean, I have it in my gamemodes' folder, in my models folder and it still won't show up... Edit: Also, for some reason, the weapons that i have downloaded from garrysmod.org won't show up in my gamemode. Again, no clue why. [CODE][AddCSLuaFile] Couldn't find 'weapons/famas/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/famasscript/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/g36c/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/g36cscript/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/lk05/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/lk05particles/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/lk05script/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/scar/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/scarscript/shared.lua' (<nowhere>) [AddCSLuaFile] Couldn't find 'weapons/spas-12/shared.lua' (<nowhere>) [/CODE][/QUOTE] Are they located in gamemodes/folder/gamemode/lua or gamemodes/folder/lua, folder/models or folder/gamemode/models? They should be located in folder/entities/weapons and your models in gamemodes/folder/content/models Does that clear anything up? [editline]17th February 2013[/editline] They must be located in garrysmod/garrysmod/gamemodes/yourgamemode/content/models (MDL), textures in garrysmod/garrysmod/gamemodes/yourgamemode/content/materials (VTF&VMT) Weapons must be located in garrysmod/garrysmod/gamemodes/yourgamemode/entities/weapons (Lua)
[QUOTE=luavirusfree;39615395]Are they located in gamemodes/folder/gamemode/lua or gamemodes/folder/lua, folder/models or folder/gamemode/models? They should be located in folder/entities/weapons and your models in gamemodes/folder/content/models Does that clear anything up? [editline]17th February 2013[/editline] They must be located in garrysmod/garrysmod/gamemodes/yourgamemode/content/models (MDL), textures in garrysmod/garrysmod/gamemodes/yourgamemode/content/materials (VTF&VMT) Weapons must be located in garrysmod/garrysmod/gamemodes/yourgamemode/entities/weapons (Lua)[/QUOTE] My weapons are located exactly where you just said: in entities/weapons. But... my model is located in garrysmod/garrysmod/gamemodes/mygamemode/entities/models
Yeah. the models go in content/models as for the weapons, it's possible they just have some sort of errors that don't even get printed in the console, thusly the weapon just won't ever be known to the game except when loading; I've had that problem. [editline]17th February 2013[/editline] I hope I helped you.
[QUOTE=luavirusfree;39615638]Yeah. the models go in content/models as for the weapons, it's possible they just have some sort of errors that don't even get printed in the console, thusly the weapon just won't ever be known to the game except when loading; I've had that problem. [editline]17th February 2013[/editline] I hope I helped you.[/QUOTE] So pretty much i have to make a new folder named content and then put the model in that? P.S.: You helped alot <3
Sorry, you need to Log In to post a reply to this thread.