• What do you need help with V4
    639 replies, posted
[QUOTE=Drakehawke;35286560]For the default models that come with GMod? I just use the spawnmenu in-game. (Right click -> Copy to Clipboard)[/QUOTE] I mean models that I can use in ViewModels and WorldModels
[QUOTE=Krizzu;35287183]I mean models that I can use in ViewModels and WorldModels[/QUOTE] Yep, they're in there, search for "weapon" and you get most of them, the view models mostly begin with v_, the world models mostly begin with w_.
You can also use the "Model Viewer" from Source SDK.
Okay, got it. Thanks. Now, I want to delay some action. Any Snippets?
[QUOTE=Proclivitas;35285878]What are some entry level/intermediate things to code? I don't want to be creating massive gamemodes here, I just purely want to do this for hobby as I haven't learned lua yet.[/QUOTE] Code a simple deathmatch gamemode. The hardest part will be the currency and round system. So it should give you a bit of a challenege depending on how intricate you make the gamemode.
[QUOTE=Krizzu;35288534]Okay, got it. Thanks. Now, I want to delay some action. Any Snippets?[/QUOTE] [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa75a.html?title=Timer[/url]
Thank you! Helped a lot! But now: [LUA] function SWEP:SecondaryAttack() concommand.Run (self.Owner,"testframe") end function testframe() local frame1 = vgui.Create("DFrame") --This is line 75 frame1:SetPos(100,100) frame1:SetSize(200,200) frame1:SetTitle("Test") frame1:MakePopup() end concommand.Add( "testframe", testframe ) [/LUA] [QUOTE]lua\weapons\russian_roulette_v1\shared.lua:75: attempt to index global 'vgui' (a nil value)[/QUOTE]
It has to be clientside.
-snip- solved :)
Does anyone know the name of the tripmine ammo? I know the mine itself is npc_tripmine but can't find the "ammo" for it or whatever you'd use to spawn it.
[QUOTE=NnyAskC;35298926]Does anyone know the name of the tripmine ammo? I know the mine itself is npc_tripmine but can't find the "ammo" for it or whatever you'd use to spawn it.[/QUOTE] SLAM maybe?
[QUOTE=Hyper Iguana;35299273]SLAM maybe?[/QUOTE] Well, I feel dumb. lol thanks.
How would I check to see if something is inside of ents.FindInSphere? [lua] function CheckSpawnZones() for k, vector in pairs(SpawnZone) do local entity = ents.FindInSphere(vector.Vector,300); for _, class in pairs(CheckFor) do local ent = tostring(entity:GetClass()); if (class == ent) then return; end end end return true; end [/lua] [editline]26th March 2012[/editline] [lua] function CreateSpawn(ply,cmd, args) local trace = ply:GetEyeTrace(); if (trace.HitWorld) && (#args == 2) then AddSpawnZone(trace.HitPos, args[1], args[2], #SpawnZone + 1); else ply:ChatPrint("You must enter two arguments and look at the world!\n I.E. create_spawnpoints 'class' 'true/false'"); end timer.Create("SpawnZoneThink", 0.5, 0, function() local RandomX = math.random(-100,100); local RandomY = math.random(-100,100); for k, v in pairs(SpawnZone) do if (CheckSpawnZones() == false) then return end CreateNPC(v.Class, v.Vector + Vector(RandomX, RandomY, 0)) end end); end concommand.Add("create_spawnpoints", CreateSpawn); function CreateNPC(class, vector) local ent = ents.Create(class); ent:SetPos(vector); ent:Spawn(); end function CheckSpawnZones() for k, vector in pairs(SpawnZone) do local entity = ents.FindInSphere(vector.Vector,175); for _, class in pairs(CheckFor) do for k, v in pairs(entity) do if v == class then return true else return false end end end end end [/lua] I solved the first part. How do I make it so it doesn't only spawn when something is isnt in any of the spheres and just the sphere where the spawn is? I can be in one zombies spawn, and others will spawn is what I mean. For now it only spawns in the 2 spawn I create and not in the third or fourth.
Okay, now, is there any restriction about console command name? [QUOTE]concommand.Add( "testframe", testframe ) [/QUOTE] When I put "testframe" it says there no such a function. When I put "qwe" it's working. O.o
So I want to create a command for perp when a player runs it, it gives them 500k but I can't figure out how to make it set to a specific person that runs the command. So far I have [lua] function money (SteamID, ply) sql.query( "INSERT INTO perp_users, "cash"VALUE ("500000")") concommand.Add("Money", money) [/lua]
I suppose it's a tiny problem but I can't seem to make it happen. AT ALL. the code is as follows: function SWEP:SecondaryAttack() if ( !self:CanSecondaryAttack() ) then return end timer.Simple(0.3,function() self.Weapon:EmitSound("Weapon_MegaPhysCannon.Charge") local shoot={} [1]=(timer.Simple(0.3, self:ShootBullet( 4, 9, 0.06 )) [2]=(self:TakeSecondaryAmmo( 1 )) [3]=(self.Owner:ViewPunch(Angle(math.random(-0.5, -0.1))) ) [4]=(self.Weapon:SetNextSecondaryFire( CurTime() + 0.3 ) ) [5]=(local muzzle2 = EffectData() ) end -- fruitlessly trying to put a different muzzle effect for a different shot. muzzle2:SetEntity(self.Weapon) muzzle2:SetOrigin(self.Owner:GetShootPos()) muzzle2:SetNormal(self.Owner:GetAimVector()) muzzle2:SetAttachment(1) util.Effect("HelicopterMuzzleFlash", muzzle2) end Wanted a delay on the secondary fire, which was going to be a shotgun. Tried to use a table, failed. At my wit's fucking end. HELP!!!
All of the indexes aren't part of a table. It should be: local myTable = {}; myTable[1] = "Hello"; myTable[2] = "World"; myTable[3] = "stuff."; And so on.
[QUOTE=silenced deat;35320453]So I want to create a command for perp when a player runs it, it gives them 500k but I can't figure out how to make it set to a specific person that runs the command. So far I have [lua] function money (SteamID, ply) sql.query( "INSERT INTO perp_users, "cash"VALUE ("500000")") concommand.Add("Money", money) [/lua][/QUOTE] concommand.Add calls the function with 3 parameters: Player, Command, Arguments. For example, to get the steamid, you can use this code: [lua] concommand.Add("YourName", function(ply, cmd, args) local steamid = ply:SteamID() end) [/lua]
[QUOTE=pennerlord;35328046]concommand.Add calls the function with 3 parameters: Player, Command, Arguments. For example, to get the steamid, you can use this code: [lua] concommand.Add("YourName", function(ply, cmd, args) local steamid = ply:SteamID() end) [/lua][/QUOTE] So its gonna look likes this: [lua] concommand.Add("Money", function(ply, cmd, args) local SteamID = ply:SteamID sql.query( "INSERT INTO perp_users (`cash`)VALUES ('500000')" ) [/lua]
[QUOTE=silenced deat;35328099]So its gonna look likes this: [lua] concommand.Add("Money", function(ply, cmd, args) local SteamID = ply:SteamID sql.query( "INSERT INTO perp_users (`cash`)VALUES ('500000')" ) [/lua][/QUOTE] Your sql query is still wrong. I recommend to you to read this sql tutorial: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb23a.html?title=LUA:SQLite_Tutorial[/url]
[QUOTE=pennerlord;35328456]Your sql query is still wrong. I recommend to you to read this sql tutorial: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb23a.html?title=LUA:SQLite_Tutorial[/url][/QUOTE] Can you please explain what i have done wrong because i'm new to lua and im getting an args error.
It should be: [lua] concommand.Add("GiveMoney", function(ply, cmd, args) local steamID = ply:SteamID(); sql.Query("UPDATE perp_users SET Cash = 50000 WHERE SteamID = "..steamID); end) [/lua] Assuming that the fields I used are correct.
[QUOTE=Chessnut;35335905]It should be: [lua] concommand.Add("GiveMoney", function(ply, cmd, args) local steamID = ply:SteamID(); sql.Query("UPDATE perp_users SET Cash = 50000 WHERE SteamID = "..steamID); end) [/lua] Assuming that the fields I used are correct.[/QUOTE] Ok i will try it, and thanks! :) EDIT: Just tryed it and the money is not going into my bank or cash pile.
[QUOTE=silenced deat;35339146]Ok i will try it, and thanks! :) EDIT: Just tryed it and the money is not going into my bank or cash pile.[/QUOTE] Make sure those entries are the correct ones that perp uses in its SQL
why doesn't he just use the function PERP uses to give players money instead of updating a SQL row which will be overwritten when the player reconnects anyway
[QUOTE=Banana Lord.;35341713]why doesn't he just use the function PERP uses to give players money instead of updating a SQL row which will be overwritten when the player reconnects anyway[/QUOTE] [QUOTE=silenced deat;35333666]Can you please explain what i have done wrong because i'm new to lua and im getting an args error.[/QUOTE] Maybe? ### When I use : [QUOTE]chat.AddText()[/QUOTE] I got chat spam. How to avoid it? (Just one or four messages should be fine instead of 10k)
Ok, so I have a few issues that are giving me hell, not really sure they can be fixed either but I thought I'd try and get some assistance. Firstly I am making a map that has a 3D Sky box that you can enter, and then the actual map shows in the middle of the 3D Sky box with everything at 1/64th scale, and when you are in the map and look up you see out of the glass case in the middle of the Sky box and see everything there 64x normal size, there is a teleport that take you between them. So far I can draw the player, props, vehicles, and some SENTs in miniature but I can't seem to redraw some things like fire and explosion effects, and this is the part I don't think I can do at all. The part I think I can fix is with my npc's some will scale just fine, but all humanish characters don't scale, i've brought and illustration: [b]First What works[/b] Antlion's scale just fine, this is a normal first person shot. [t]http://cloud.steampowered.com/ugc/578952027376897221/D4666F83077B11CF841B5A0511E14093E63B49B4/[/t] This shot is from a camera in the sky box room, me and the antlion are in the bottom left to the right of the health display, tiny just as they should be. [t]http://cloud.steampowered.com/ugc/578952027376891561/19BD250182F5EC7A8D1CCC226D25E1EECFA5FBDC/[/t] This shot is from the camera seen in the lower left of the last shot, this camera is also in the sky box room but it is just beyond the inside wall to get a close up. [t]http://cloud.steampowered.com/ugc/578952027376893936/8D22B3F4C9F8C6B7EEDDA6E6805D9405DDB8EC30/[/t] [b]and now...[/b] These next 3 are exactly the same but with mossman, she doesn't scale. First person shot, you can see the full size model being drawn in sky box room. [t]http://cloud.steampowered.com/ugc/578952027376889368/3CD8924604DFEACED4236B3DBC507D0A8800F317/[/t] This is from first sky box cam, again, she is full sized, =( [t]http://cloud.steampowered.com/ugc/578952027376898728/54BE12E131558472ACFFBA854F067DF74BD70C98/[/t] and last from the close up camera. [t]http://cloud.steampowered.com/ugc/578952027376901132/3268DEC05974EE8B10C07C4E564777BEB4CB5EA4/[/t] Any way here's the code, it's not pretty at the moment and there's shit in there that is only there because i'm trying to fix this, and it's all in one file till I get this working the way I want, then I'll clean it all up. [lua] --doesn't scale --zombine --zombie --fast zombie --antlion guard --antlion worker (wings) --roller mine (effect) --ragdolls renderClasses = { "prop", "npc", "player", "rag", "env", "meteor", "weapon" } function IsClass( ent, class ) if ent == nil then return false end if ent == NULL then return false end if !ent:IsValid() then return false end local result = nil local isClass = false if type(class) == "table" then for k,v in pairs(class) do result = string.find(ent:GetClass(),v) if !(result == nil) then isClass = true end result = nil end else --print("Is " .. ent:GetClass() .. " a " .. class .. " : " .. tostring(!(result == nil))) result = string.find(ent:GetClass(), class) if !(result == nil) then isClass = true end end return isClass end if CLIENT then tankPos = Vector(0,0,0) renderEnts = {} hook.Add("OnEntityCreated", "get_it", function(ent) if IsClass(ent, "class") then table.insert(renderEnts, ent:EntIndex()) end end) for k,v in pairs(ents.GetAll()) do if IsClass(ent, "class") then table.insert(renderEnts, ent:EntIndex()) end end function getRenderEnts(msgData) local newEnt = msgData:ReadShort() if table.HasValue(renderEnts, newEnt) then return end table.insert(renderEnts,newEnt) end usermessage.Hook("get_render_ents", getRenderEnts) function getTankPos(msgData) tankPos = msgData:ReadVector() print("tankPos: " .. tostring(tankPos)) end usermessage.Hook("get_tank_pos", getTankPos) hook.Add("PostDrawOpaqueRenderables", "fuckinA", function() local scale = 1 / 64 cam.Start3D(EyePos(), EyeAngles()) for k,v in pairs(renderEnts) do local rendEnt = ents.GetByIndex(v) if !(rendEnt == NULL) and !(rendEnt:IsWorld()) then local curPos = rendEnt:GetPos() local rendPos = tankPos + (curPos * scale) --Draw Mini rendEnt:SetPos(rendPos) --rendEnt:SetRenderOrigin(rendPos) rendEnt:SetModelScale(Vector(scale,scale,scale)) if IsClass(rendEnt, "npc") or IsClass(rendEnt, "rag") then rendEnt:InvalidateBoneCache() rendEnt:SetupBones() end if rendEnt.DrawModel then rendEnt:DrawModel() end if rendEnt.Draw then rendEnt:Draw() end if rendEnt.DrawTranslucent then rendEnt:DrawTranslucent() end if rendEnt:IsPlayer() and ValidEntity(rendEnt:GetActiveWeapon()) then rendEnt:GetActiveWeapon():DrawModel() end --Draw Normal rendEnt:SetPos(curPos) rendEnt:SetModelScale(Vector(1,1,1)) if !IsClass(rendEnt, "npc") then rendEnt:DrawModel() end else table.remove(renderEnts, k) end end cam.End3D() return false end) end if SERVER then local renderEnts = {} function addRenderEnt(ent) if !table.HasValue(renderEnts,ent) then table.insert(renderEnts, ent) end umsg.Start("get_render_ents") umsg.Short(ent:EntIndex()) umsg.End() end hook.Add("SetupPlayerVisibility", "fert", function(ply, ent) AddOriginToPVS(Vector(0,0,0)) for k,v in pairs(renderEnts) do if ValidEntity(v) then AddOriginToPVS(v:GetPos()) else table.remove(renderEnts,k) end end end ) for k,v in pairs(ents.GetAll()) do if v:GetName() == "tank_middle" then umsg.Start("get_tank_pos") umsg.Vector(v:GetPos()) umsg.End() end if !v:IsWorld() then if v.GetPhysicsObject then local vPhys = v:GetPhysicsObject() if vPhys and vPhys.IsValid and vPhys:IsValid() then addRenderEnt(v) end end end end hook.Add("OnEntityCreated", "get_it", function(ent) timer.Simple(0.01, checkEnt, ent) end) function checkEnt(ent) if ValidEntity(ent) then if !ent:IsWorld() then if ent.GetPhysicsObject then local vPhys = ent:GetPhysicsObject() if vPhys and vPhys.IsValid and vPhys:IsValid() then addRenderEnt(ent) end else if IsClass(ent, "env_") then addRenderEnt(ent) end end end end end hook.Add("PlayerInitalSpawn", "see_it", function(ply) for k,v in pairs(renderEnts) do umsg.Start("get_render_ents") umsg.Short(v:EntIndex()) umsg.End() end end) end [/lua] Thanks for any help.
[QUOTE=Banana Lord.;35341713]why doesn't he just use the function PERP uses to give players money instead of updating a SQL row which will be overwritten when the player reconnects anyway[/QUOTE] And what function would that be? is it this [lua]function PLAYER:SetCash ( value, stopSendToClient) self:SetPrivateInt("cash", value, stopSendToClient); end[/lua]
[lua] local SoundPlayer = {} local Sounds = {} function SoundPlayer.AddSound(Text, Destination) table.insert(Sounds, {Text = Text, Destination = Destination}) end SoundPlayer.AddSound("lol", "vo/eli_lab/al_laugh02.wav") function SoundPlayer.ChatFunction( ply, text ) if ply:IsValid() then for k,v in pairs(Sounds) do if string.find( text, k ) then ply:EmitSound(Sounds[k], 500, 100) return text end end end end hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction) [/lua] It doesn't emit the sound. No clue what I'm doing wrong tho.
[QUOTE=Persious;35349442][lua] local SoundPlayer = {} local Sounds = {} function SoundPlayer.AddSound(Text, Destination) table.insert(Sounds, {Text = Text, Destination = Destination}) end SoundPlayer.AddSound("lol", "vo/eli_lab/al_laugh02.wav") function SoundPlayer.ChatFunction( ply, text ) if ply:IsValid() then for k,v in pairs(Sounds) do if string.find( text, k ) then ply:EmitSound(Sounds[k], 500, 100) return text end end end end hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction) [/lua] It doesn't emit the sound. No clue what I'm doing wrong tho.[/QUOTE] I have a question, why do you use k and then Sounds[k]? shouldnt it be the variables k and v since you are using the loop? [lua] if string.find( text, k ) then ply:EmitSound(Sounds[k], 500, 100) return text [/lua]
Sorry, you need to Log In to post a reply to this thread.