I'm trying to use a non-player model as a player model by setting up the animations my self but for some reason the model wont turn, dose anyone know how to fix this?
Edit: Never mind i found it, you can just use Entity.SetRenderAngles
How to prone addon with player.sethull?
So I'm trying to give myself an imaginary STD
[lua]
function getSTD( ply, cmd, args )
local type = args[1]
ply:SetNWBool("std",1)
if type == 1 then
ply:ChatPrint("You've contracted Gonorrhea!")
timer.Create("gtimer",1,0, function()
if !ply:GetNWBool("std") then timer.Destroy("gtimer") return end
local grand=math.random(100)
if grand==1 then
ply:Ignite(5,1)
ply:ChatPrint("Your Gonorrhea is kicking in!")
end
end)
end
if type == 2 then
ply:ChatPrint("You've contracted Jumping Anus Syndrome!")
timer.Create("jatimer",1,0, function()
if !ply:GetNWBool("std") then timer.Destroy("jatimer") return end
local jarand=math.random(100)
end)
if jarand==1 then
ply:ChatPrint("Your Jumping Anus Syndrome is kicking in!")
for i = 1, 10 do
timer.Simple(i,ply:ConCommand("+jump"))
timer.Simple(i+0.25,ply:ConCommand("-jump"))
end
end
end
if type == 3 then
ply:ChatPrint("You've contracted Numblegs!")
ply:SetNWBool("hb",1)
ply:SetRunSpeed(ply:GetRunSpeed() / 2)
ply:SetWalkSpeed(ply:GetWalkSpeed() / 2)
end
if type == 4 then
ply:ChatPrint("You've contracted prolapsed anus!")
ply:SetMaxHealth(25)
ply:SetNWBool("pa",1)
if ply:Health() >> 50 then
timer.Create("bleed",1,0, function()
if ply:Health() <= 25 then return end
ply:SetHealth(ply:Health()-1)
end)
end
end
if !ply:Alive() or ply:GetNWBool("std") == 0 then
if ply:GetNWBool("hb") == 1 then
ply:SetRunSpeed(ply:GetRunSpeed()*2)
ply:SetWalkSpeed(ply:GetWalkSpeed()*2)
ply:SetNWBool("hb",0)
end
if ply:GetNWBool("pa") == 1 then
ply:SetMaxHealth(25)
timer.Destroy("bleed")
ply:SetNWBool("pa",0)
end
end
end
concommand.Add( "getSTD", getSTD )
[/lua]
Problem is that when I enter getSTD 1, nothing happens.
Any problems with this?
All args are passed as strings, do local type = tonumber( args[1] )
[QUOTE=Drakehawke;37571039]All args are passed as strings, do local type = tonumber( args[1] )[/QUOTE]
Thanks sexy
How would I go about using animated materials for my hud (Ie something like [url=http://facepunch.com/showthread.php?t=1187879&p=36245199&viewfull=1#post36245199]this[/url])?
I know how to make the materials, but how do I control their progress through the animation?
[QUOTE=sabreman;37572998]How would I go about using animated materials for my hud (Ie something like [url=http://facepunch.com/showthread.php?t=1187879&p=36245199&viewfull=1#post36245199]this[/url])?
I know how to make the materials, but how do I control their progress through the animation?[/QUOTE]
What do you mean? It looks like they're all different materials being swapped out depending on whats happening...
-snip-, about 8 hours late.
[QUOTE=sabreman;37572998]How would I go about using animated materials for my hud (Ie something like [url=http://facepunch.com/showthread.php?t=1187879&p=36245199&viewfull=1#post36245199]this[/url])?
I know how to make the materials, but how do I control their progress through the animation?[/QUOTE]
[code]
--At the top of the script
local mat = Material( "your/animated/material" )
local FRAMES = frames_in_your_material - 1 --Since they are frames 0 -> n-1
--In your hud
surface.SetMaterial( mat )
mat:SetMaterialInt( "$frame", math.Clamp( flValue * FRAMES, 0, FRAMES ) )
surface.DrawTexturedRect( x, y, w, h )
[/code]
Be sure to set $vertexcolor and $vertexalpha to 1 in the vmt.
As long as you change $frame before drawing the material, you can repeatedly draw it with different frames, which is how I do the darkened bit to show deltas.
-snip-
-snip-
[QUOTE=Kogitsune;37574768]
-magic-[/QUOTE]
Thanks man, that's exactly what I was looking for!
[code] DComboBox = vgui.Create('DComboBox', ReportFrame)
DComboBox:SetPos(12, 108)
DComboBox:SetSize(160, 20)
DComboBox:AddChoice("ouhjsadohsadf", "data")
[/code]
Trying to port over to GM13. I had a couple of DMultiChoice boxes I needed to convert. Since Multichoice was renamed to ComboBox, I did the name change
The frame (not shown in code above) appears, and so does the ComboBox. However, no options appear when I click on the combobox itself, or the arrow next to it. Are comboboxes (formerly known as MultiChoice boxes) broken, or am I being a prat?
Thanks!
Hi I need help with finding the right way to set up a STool. I've looked around but I just can't seem to get it to work. I have the basic STool structure from the GMod Wiki, but it seems broken. I set up the following code in the file path "garrysmodbeta/lua/weapons/gmod_tool/stools/GFG.lua" Here's my code [code]
TOOL.Category = "Space Build"
TOOL.Name = "Gravity Field Generator"
TOOL.Command = nil
TOOL.ConfigName = "" --Setting this means that you do not have to create external configuration files to define the layout of the tool config-hud
TOOL.ClientConVar[ "Gravity"] = "0"
TOOL.ClientConVar[ "Height" ] = 500
function TOOL:LeftClick( trace )
print("click")
return true
end
function TOOL:RightClick( trace )
end
function TOOL.BuildCPanel( panel )
panel:AddControl("Header", { Text = "Example TOOL", Description = "Just an little example" })
panel:AddControl("CheckBox", {
Label = "A Boolean Value",
Command = "example_bool"
})
panel:AddControl("Slider", {
Label = "Example Number",
Type = "Float",
Min = "0",
Max = "10000",
Command = "example_number"
})
panel:AddControl("Color", {
Label = "A Color",
Red = "example_color_r",
Blue = "example_color_b",
Green = "example_color_g",
Alpha = "example_color_a",
ShowHSV = 1,
ShowRGB = 1,
Multiplier = 255 --You can change this to make the rgba values go up to any value
})
end [/code]
I'm new to GMod scripting but I'm not new to Lua. I'll left click and absolutely nothing will happen. Also the name and the description are not working either.
[QUOTE=Trumple;37583966][code] DComboBox = vgui.Create('DComboBox', ReportFrame)
DComboBox:SetPos(12, 108)
DComboBox:SetSize(160, 20)
DComboBox:AddChoice("ouhjsadohsadf", "data")
[/code]
Trying to port over to GM13. I had a couple of DMultiChoice boxes I needed to convert. Since Multichoice was renamed to ComboBox, I did the name change
The frame (not shown in code above) appears, and so does the ComboBox. However, no options appear when I click on the combobox itself, or the arrow next to it. Are comboboxes (formerly known as MultiChoice boxes) broken, or am I being a prat?
Thanks![/QUOTE]
They are fine, but what you did there is retarded unless [i]DComboBox[/i] is a [b]local[/b] in your case.
Garry made each Derma control a global table so you can use their functions in your own controls.
[QUOTE=vercas;37589842]They are fine, but what you did there is retarded unless [i]DComboBox[/i] is a [b]local[/b] in your case.
Garry made each Derma control a global table so you can use their functions in your own controls.[/QUOTE]
DComboBox (as in the var name) is a local, defined elsewhere
Which functions are you referring to in your second line?
Also, I found out why it wasn't working. I had stupidly managed to over write one of the key functions of the Combo box
Thanks
[QUOTE=Trumple;37590684]DComboBox (as in the var name) is a local, defined elsewhere
Which functions are you referring to in your second line?
Also, I found out why it wasn't working. I had stupidly managed to over write one of the key functions of the Combo box
Thanks[/QUOTE]
The controls are initialized with a table which contains their functions.
That table is later turned into a global by Garry's Derma code.
Messing around with render.RenderView, I encoutered a strange crash, it resulted in an uncommon minidump:
hl2_20120908_213426_1_InvalidParameterHandler.mdmp
What are these stuff, and how shall I interpret them?
Do you have multi-core rendering on?
[QUOTE=Shenesis;37592312]Can entities have different IDs in server/client?
(i.e I get 950 in server, but 0 (null entity) in client.)[/QUOTE]
if the entity is not in the client's view leaf then it'll be null
Which files do I use to edit which weapon an NPC spawns with by default on the beta?
I've got the tmysql4 module working, however doesn't matter what function I use apart from "initialize" i get the error attempt to call method 'query' < a nill value >. I've tried using these functions kindly listed by Ruzza.
[lua]
tmysql.initialize( host, user, password, database, socket ) -- returns database metatable, socket is for linux only
tmysql.Connect = tmysql.initalize -- identical as above
tmysql.escape( string ) -- returns escaped string
tmysql.GetTable() -- returns all connections
tmysql.PollAll() -- i think forces all queries to run?
database.Query( query, callbackfunc, flags, callbackref ) -- callbackfunc = results, stats, error
database.Disconnect() -- disconnects from connection
database.SetCharset( charset ) -- sets charset
database.Poll() -- again, i think it forces the query to run?
--Some variables set
QUERY_SUCCESS = true
QUERY_FAIL = false
QUERY_FLAG_ASSOC = 1
QUERY_FLAG_LASTID = 2
MYSQL_VERSION -- returns mysql version
MYSQL_INFO -- returns a table of mysql info
[/lua]
Are someone able to post an example of how to run a query?
i'm attempting
[lua]
tmysql.query("UPDATE `time` SET `value`='" .. os.time() .. "' LIMIT 1");
[/lua]
[QUOTE=kragmars102;37595980]I've got the tmysql4 module working, however doesn't matter what function I use apart from "initialize" i get the error attempt to call method 'query' < a nill value >. I've tried using these functions kindly listed by Ruzza.
[lua]
tmysql.initialize( host, user, password, database, socket ) -- returns database metatable, socket is for linux only
tmysql.Connect = tmysql.initalize -- identical as above
tmysql.escape( string ) -- returns escaped string
tmysql.GetTable() -- returns all connections
tmysql.PollAll() -- i think forces all queries to run?
database.Query( query, callbackfunc, flags, callbackref ) -- callbackfunc = results, stats, error
database.Disconnect() -- disconnects from connection
database.SetCharset( charset ) -- sets charset
database.Poll() -- again, i think it forces the query to run?
--Some variables set
QUERY_SUCCESS = true
QUERY_FAIL = false
QUERY_FLAG_ASSOC = 1
QUERY_FLAG_LASTID = 2
MYSQL_VERSION -- returns mysql version
MYSQL_INFO -- returns a table of mysql info
[/lua]
Are someone able to post an example of how to run a query?
i'm attempting
[lua]
tmysql.query("UPDATE `time` SET `value`='" .. os.time() .. "' LIMIT 1");
[/lua][/QUOTE]
[lua]
DB, ERR = tmysql.initialize( host, user, password, database, socket )
DB:Query("UPDATE `time` SET `value`='" .. os.time() .. "' LIMIT 1")
[/lua]
[QUOTE=A Lost Sandwich;37596077][lua]
DB, ERR = tmysql.initialize( host, user, password, database, socket )
DB:Query("UPDATE `time` SET `value`='" .. os.time() .. "' LIMIT 1")
[/lua][/QUOTE]
Thank you very much !
One last question "LocalPlayer()" isn't working on Garry's Mod 13, and it's running completely clientside.
Here's something I can use some help with. I want my weapons to be either unselectable when empty, or to be stripped when empty. Nothing worse than going to a firefight with an empty weapon, right?
Anyway, right now I'm using this timer set weapon stripper code in my hack job of a base. Every time I use it, I get timer errors in console. The weapon strips fine, I just want a better way to get rid of the weapon without spamming errors every time.
I should note here that these errors only show up when in multiplayer.
CheckWeaponsAndAmmo is called on primary fire, and swep:gun points to the name of the weapon.
[lua]
function SWEP:CheckWeaponsAndAmmo()
if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 then
timer.Simple(.01, self.NotYours, self)
end
end
function SWEP:NotYours()
self.Owner:StripWeapon(self.Gun)
end
[/lua]
These are the errors I get when this happens:
[lua]Timer Error: [<bullshit>\shared.lua:126] attempt to call method 'StripWeapon' (a nil value)
[/lua]
line 26 points to self.Owner:StripWeapon. My goal was to have the weapon stripper called on the next frame, but I'm obviously doing something wrong.
Anybody have any ideas?
edit: And if you're wondering, skipping the timer all together and going straight to stripweapons gives me this error:
[lua][<bullshit>\shared.lua:121] attempt to call method 'StripWeapon' (a nil value)
[/lua]
[QUOTE=me-name-bob;37598050]-snip-[/QUOTE]
Use this:
[lua]
function SWEP:CheckWeaponsAndAmmo()
local wep = self.Weapon
local owner = self.Owner
if wep:Clip1() == 0 && owner:GetAmmoCount(wep:GetPrimaryAmmoType()) == 0 then
timer.Simple(0.2, NotYours, owner)
end
end
function SWEP:NotYours()
local owner = self.Owner
owner:StripWeapon(self.Weapon:GetClass())
end
[/lua]
SNPCs seem to be completely non-functional in garry's mod 13.
What is going on?
EDIT:
schdChase:EngTask( "FindEnemy", { Class = "player", Radius = 10000000 })
schdChase:EngTask( "TASK_GET_PATH_TO_ENEMY", 0 )
schdChase:EngTask( "TASK_RUN_PATH_TIMED", 0.1 )
schdChase:EngTask( "TASK_WAIT", 0.1 )
these 4 lines cause the console to spam errors pertaining to a completely different series of scripts in the ai base, and ai modules.
the worst part is, I really need these in my code
Error:
[lua/includes/modules/ai_task.lua:90] attempt to call upvalue 'GetTaskID' (a nil value)
1. lua/includes/modules/ai_task.lua:90 (Start)
2. gamemodes/base/entities/entities/base_ai/schedules.lua:137 (StartTask)
3. gamemodes/base/entities/entities/base_ai/schedules.lua:104 (SetTask)
4. gamemodes/base/entities/entities/base_ai/schedules.lua:127 (NextTask)
5. gamemodes/base/entities/entities/base_ai/schedules.lua:75 (DoSchedule)
6. gamemodes/base/entities/entities/base_ai/schedules.lua:22 (unknown)
Is there a way to give draw.RoundedBox an outline?
I just started scripting in Gmod 13, is lua_openscript, still the way to go?
[QUOTE=Gamz365;37600733]I just started scripting in Gmod 13, is lua_openscript, still the way to go?[/QUOTE]
Serverside entity and gamemode scripts update realtime, but that's it from my experience.
[editline]9th September 2012[/editline]
[code]Entity:PhysicsInit() - Failed to create physics for entity[/code]
I keep getting this in my console whenever I create an entity. It works fine, and has physics, but all this big red text in my console is a bother. What causes this?
Sorry, you need to Log In to post a reply to this thread.