Where can I find weapon model list?
For the default models that come with GMod? I just use the spawnmenu in-game. (Right click -> Copy to Clipboard)
I mean models that I can use in ViewModels and WorldModels
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?
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.
Thank you! Helped a lot!
But now:
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 )
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.
SLAM maybe?
Well, I feel dumb. lol thanks.
How would I check to see if something is inside of ents.FindInSphere?
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
Edited:
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.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
Okay, now, is there any restriction about console command name?
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
function money (SteamID, ply) sql.query( "INSERT INTO perp_users, "cash"VALUE ("500000")") concommand.Add("Money", money)
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.Charg e")
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.
concommand.Add calls the function with 3 parameters: Player, Command, Arguments.
For example, to get the steamid, you can use this code:
concommand.Add("YourName", function(ply, cmd, args) local steamid = ply:SteamID() end)
So its gonna look likes this:
concommand.Add("Money", function(ply, cmd, args) local SteamID = ply:SteamID sql.query( "INSERT INTO perp_users (`cash`)VALUES ('500000')" )
Your sql query is still wrong. I recommend to you to read this sql tutorial:
http://maurits.tv/data/garrysmod/wik...QLite_Tutorial
Can you please explain what i have done wrong because i'm new to lua and im getting an args error.
It should be:
concommand.Add("GiveMoney", function(ply, cmd, args) local steamID = ply:SteamID(); sql.Query("UPDATE perp_users SET Cash = 50000 WHERE SteamID = "..steamID); end)
Assuming that the fields I used are correct.
Ok i will try it, and thanks! :)
EDIT: Just tryed it and the money is not going into my bank or cash pile.
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
Maybe?
###
When I use :
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:
First What works
Antlion's scale just fine, this is a normal first person shot.
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.
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.
and now...
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.
This is from first sky box cam, again, she is full sized, =(
and last from the close up camera.
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.
--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
Thanks for any help.
And what function would that be?
is it thisfunction PLAYER:SetCash ( value, stopSendToClient) self:SetPrivateInt("cash", value, stopSendToClient); end
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)
It doesn't emit the sound. No clue what I'm doing wrong tho.
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?
if string.find( text, k ) then ply:EmitSound(Sounds[k], 500, 100) return text
How would I create a ragdoll to be the model in a SENT? I've tried before and it does this weird hull dragging thing..
He can use either. He does need to add .Destination, though:
if ply:IsValid() then for k,v in pairs(Sounds) do if string.find( text, k ) then ply:EmitSound(Sounds[k].Destination, 500, 100) -- or v.Destination return text end end end
yea, i've tried this before too and all I got was the ragdoll in a T pose, I think the functions to fix this are in the beta. But since I don't have the beta I can't test it.
I think these functions are it:
from beta update 14 list
Added Ent:SetHitboxSet( i | string )
Added Ent:GetHitboxSet() (returns i, str)
Added Ent:GetHitboxSetCount()
Added Ent:GetHitboxBone()
Added Ent:GetBoneController( i ) (returns float)
Added Ent:SetBoneController( i, float )
at least I hope so because ragdoll SENTs would be fun to mess with.
I can't see firstperson reload animations!
self.Owner:SetAnimation( PLAYER_RELOAD) --firstperson, not working self.Weapon:SendWeaponAnim( ACT_VM_RELOAD ) --thirdperson, working
any idea how to repair it?
Thanks both. I thought I missed something like that.
Edited:
Hm, still isn't emiting the sound.
function SoundPlayer.ChatFunction( ply, text ) if ply:Alive() then for k,v in pairs(Sounds) do if string.find( text, k ) then ply:EmitSound(Sounds[k].Destination, 500, 100) -- or v.Destination return text end end end end hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
Any idea how I would add 10 bucks to their player when they press it?function ItemPickUpMenu() local ItemPickUpFrame = vgui.Create( "DFrame" ) -- Creates the frame itself ItemPickUpFrame:SetPos( 50,50 ) -- Position on the players screen ItemPickUpFrame:SetSize( 200, 100 ) -- Size of the frame ItemPickUpFrame:SetTitle( "" ) -- Title of the frame ItemPickUpFrame:SetVisible( true ) ItemPickUpFrame:SetDraggable( true ) -- Draggable by mouse? ItemPickUpFrame:ShowCloseButton( true ) -- Show the close button? ItemPickUpFrame:MakePopup() -- Show the frame ItemPickUpFrame:Center() local ItemPickUpPList = vgui.Create("DPanelList", ItemPickUpFrame) ItemPickUpPList:SetPos(2,24) ItemPickUpPList:SetSize(200-4,100-26) ItemPickUpPList:SetPadding(5) Icon = vgui.Create("SpawnIcon") --Create the icon Icon:SetPos(20, 20) Icon:SetModel("models/FoodNHouseholdItems/bacon_2.mdl") Icon.OnMousePressed = function()--This is the function to use. Icon:Remove()--return false to disable the pressing effect LocalPlayer():ChatPrint("Icon Removed") LocalPlayer():AddMoney(10) LocalPlayer():ChatPrint("10bucks") end ItemPickUpPList:AddItem(Icon) end concommand.Add("dotu_item_pickup", ItemPickUpMenu)
Icon:Remove()--return false to disable the pressing effect LocalPlayer():ChatPrint("Icon Removed") LocalPlayer():AddMoney(10) LocalPlayer():ChatPrint("10bucks")
The addmoney command is serverside i cant run clientside unless i use console commands.
local ItemPickUpPList = vgui.Create("DPanelList", ItemPickUpFrame) ItemPickUpPList:SetPos(2,24) ItemPickUpPList:SetSize(200-4,100-26) ItemPickUpPList:SetPadding(5) Icon = vgui.Create("SpawnIcon") --Create the icon Icon:SetPos(20, 20) Icon:SetModel("models/FoodNHouseholdItems/bacon_2.mdl") Icon.OnMousePressed = function()--This is the function to use. Icon:Remove()--return false to disable the pressing effect LocalPlayer():ChatPrint("Icon Removed") if SERVER then self.Owner:AddMoney(10) end LocalPlayer():ChatPrint("10bucks") end ItemPickUpPList:AddItem(Icon) end concommand.Add("dotu_item_pickup", ItemPickUpMenu)
Maybe something like this.