GMod 13:
Does os.date() not work or am I just doing it wrong
[lua]file.Append("logging/" .. os.date("%d-%m-%y") .. "/" .. Modes[mode].Text .. ".txt", str .. "\n")[/lua]
It doesn't create a folder with the date. :[
Works for me.
[Img]http://puu.sh/17uh3[/Img]
[QUOTE=Persious;37758536]GMod 13:
Does os.date() not work or am I just doing it wrong
[lua]file.Append("logging/" .. os.date("%d-%m-%y") .. "/" .. Modes[mode].Text .. ".txt", str .. "\n")[/lua]
It doesn't create a folder with the date. :[[/QUOTE]
folders aren't created automatically anymore
Ah, thank you!
[QUOTE=101kl;37757358]LocalPlayer() is client-side.
Take a look [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexecc2.html"]Here[/URL] for what you need.[/QUOTE]
Would the end result be [code]A = Player:Health()
print(A)[/code]
I'm quite confused right now. I read a couple of lua tutorials and they didn't go into this at all.
Edit: Really joker? going to rate dumb instead of helping? Thanks.
[QUOTE=a1steaksa;37759907]Would the end result be [code]A = Player:Health()
print(A)[/code]
I'm quite confused right now. I read a couple of lua tutorials and they didn't go into this at all.
Edit: Really joker? going to rate dumb instead of helping? Thanks.[/QUOTE]
If you're running it on the server, you need to get the player you are getting the health of. On [del]single player[/del] clientside, you use LocalPlayer().
How can I convert this:
[CODE]http.Get([url]www.example.com[/url], " ", function ( C ))[/CODE]
Into GMod 13 new http module?
New GMod 13 http module:
[CODE]http.Fetch(url, onsuccess, onfailure)
http.Post(url, params, onsuccess, onfailure)[/CODE]
Old GMod 12 http module:
[CODE]http.Get(url, headers, callback, ...)[/CODE]
I'm just starting to convert all my scripts over to GM13 after not really having look at exactly what has changed. I have made a lot of progress but have a few issues which I cant find on the wiki or changelog:
1. Was gui.OpenURL removed? I use it for a few scripts right now because HTML panels have been so unreliable recently.
2. How do console commands added on the server work now? I run my concommands through the server console but when I try to run them in-game I just get "Unknown Command: '(command)'"
3. Lastly, does HTML work properly in Garrysmod 13 right now?
Thanks!
1. gui.OpenURL was disabled for security reasons I believe
2. Same exact way as 12
3. Not sure sorry
[QUOTE=Banana Lord.;37763167]1. gui.OpenURL was disabled for security reasons I believe
2. Same exact way as 12
3. Not sure sorry[/QUOTE]
Thanks. I'm not entirely sure what the deal is with these console commands then, the one I was testing worked totally fine when I was running it through the server console, but I keep getting 'unknown command' when it run it in-game.
*EDIT*
Seems to be working now even though I have literally changed nothing except for closing the server for a bit. Is there anything about the way lua files are loaded on mapchange etc I should know about?
well there's a file in the GCF in lua/test.lua so you can't name your file test.lua and put it in the root lua dir, besides that I don't believe so
Anyone else having problems with servers hanging on boot? Even happens with a fresh install.
[img]http://flapadar.co.uk/img/2012-09-23-00-48-41.png[/img]
[QUOTE=BorisJ;37765522]Anyone else having problems with servers hanging on boot? Even happens with a fresh install.
[img]http://flapadar.co.uk/img/2012-09-23-00-48-41.png[/img][/QUOTE]
At that exact point, too. Don't worry, we all have it
I'd send you the previous binaries but it looks like you're running windows, while I only have linux ones
Can you no longer give default CSS weapon with Gmod 13 without making sweps?
I mean, ply:Give("weapon_deagle") used to work but it's not working on GM13.
[QUOTE=MonkeysLP;37765658]Can you no longer give default CSS weapon with Gmod 13 without making sweps?
I mean, ply:Give("weapon_deagle") used to work but it's not working on GM13.[/QUOTE]
the default CSS weapons were removed
[QUOTE=Trumple;37765631]At that exact point, too. Don't worry, we all have it
I'd send you the previous binaries but it looks like you're running windows, while I only have linux ones[/QUOTE]
could you send me a copy too please?
[editline]22nd September 2012[/editline]
(linux)
<3
[QUOTE=skullorz;37765907]the default CSS weapons were removed[/QUOTE]
:C
[editline]23rd September 2012[/editline]
Trying to make a swep for GM13.
[code]
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
end
if ( CLIENT ) then
SWEP.PrintName = "AK-47"
SWEP.Slot = 3
SWEP.SlotPos = 1
SWEP.IconLetter = "b"
killicon.AddFont( "jb_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
end
SWEP.HoldType = "ar2"
SWEP.Base = "jb_base"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl"
SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Sound = Sound( "Weapon_AK47.Single" )
SWEP.Primary.Recoil = 2.5
SWEP.Primary.Damage = 70
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0.02
SWEP.Primary.ClipSize = 25
SWEP.Primary.Delay = 0.07
SWEP.Primary.DefaultClip = 50
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "smg1"
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.IronSightsPos = Vector( 6.1, -7, 2.5 )
SWEP.IronSightsAng = Vector( 2.8, 0, 0 )
[/code]
This results in getting a left-handed AK47 that doesn't shoot when I click. Any idea?
Is there any way to remove halos from entities once they're added?
[editline]22nd September 2012[/editline]
[QUOTE=MonkeysLP;37766053]:C
[editline]23rd September 2012[/editline]
Trying to make a swep for GM13.
[code]
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
end
if ( CLIENT ) then
SWEP.PrintName = "AK-47"
SWEP.Slot = 3
SWEP.SlotPos = 1
SWEP.IconLetter = "b"
killicon.AddFont( "jb_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
end
SWEP.HoldType = "ar2"
SWEP.Base = "jb_base"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl"
SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Sound = Sound( "Weapon_AK47.Single" )
SWEP.Primary.Recoil = 2.5
SWEP.Primary.Damage = 70
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0.02
SWEP.Primary.ClipSize = 25
SWEP.Primary.Delay = 0.07
SWEP.Primary.DefaultClip = 50
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "smg1"
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.IronSightsPos = Vector( 6.1, -7, 2.5 )
SWEP.IronSightsAng = Vector( 2.8, 0, 0 )
[/code]
This results in getting a left-handed AK47 that doesn't shoot when I click. Any idea?[/QUOTE]
Iirc, the CSS viewmodels were based on the left side and flipped to the right side ingame.
[lua]
SWEP.ViewModelFlip = true
[/lua]
should work to flip, and you have to use SWEP.PrimaryAttack ([url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8ca2.html[/url]) to make it shoot.
How do u make a Zombie NPC. I know how to make regular npc with "npc_citizen" and "npc_combine_s" but is there a code for a zombie? Thanks in advance :)
[QUOTE=BeeHiveOfDeat;37766452]How do u make a Zombie NPC. I know how to make regular npc with "npc_citizen" and "npc_combine_s" but is there a code for a zombie? Thanks in advance :)[/QUOTE]
[url]https://developer.valvesoftware.com/wiki/Category:Half-Life_2_NPCs[/url]
Thanks!
[editline]23rd September 2012[/editline]
How do you get the name of the weapon used in GM:EntityTakeDamage(ent, inflictor, attacker, amount, dmginfo) ?
I've tried, for instance, to reduce the damage caused by crowbars with [code]if(inflictor:GetClass() == "weapon_crowbar") then bla bla but that doesn't seem to work.
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe50a.html[/url]
from the dmginfo
[editline]22nd September 2012[/editline]
And try printing the inflictor to see what it's giving you
[editline]22nd September 2012[/editline]
-snip-
Nvm, fail on me...
I managed to convert most of my hatstore UI stuff to GM13, but I'm having a bit of an issue with the preview panels in the shop. Essentially nothing but the base HL2 props display properly now, even the roundedboxes just appear as weird splats, when they are at the very end of the function and not affected by anything else.
[img_thumb]http://puu.sh/17IVl[/img_thumb]
The preview panels using a player doll and a hat work totally fine and use pretty much the same cam.Start3D/End3D stuff, which makes me inclined to think it has something to do with the new CreateClientProp replacing ents.Create on the client.
[lua]
pan.Model = ClientsideModel( tab.Model )
pan.Model:SetNoDraw( true )
local rmodel = ents.CreateClientProp( tab.Model )
pan.Render = ( rmodel:OBBMins() - rmodel:OBBMaxs() ):Length()
pan.LookAt = rmodel:LocalToWorld( rmodel:OBBCenter() )
SafeRemoveEntity( rmodel )
[/lua]
*EDIT*
Yeah, OBBMins() and OBBMaxs() appears to be returning 0s, on TF2 models at least. Its still temperamental with just the HL2 props, sometimes it does and sometimes it doesnt. GetModelBounds() does the exact same thing, returns nothing until it gets to the HL2 skull gib.
So I made a 512x512 texture.
I'm drawing it on an entity using surface.DrawTexturedRect(x,y,width,height).
Strange thing is, it only draws correctly width and height are 511, and this leaves 1-pixel border around the texture.
If I use width and height of 512, it covers the entire model (screen), but the texture becomes stretched and distorted.
I have two possible explanations:
1) I somehow made a 511x511 texture,
2) Wire screen that I'm drawing this on in lua is actually 513x513
Neither of which make any sense.
I guess I could live with it, but really, what's going on?
Also, the texture draws fine with surface.DrawTexturedRect, but I can't use it with my material tool on other props.
Good evening, gentiles.
I'm currently learning how GMod is put together and where everything is organized. Currently I'm facing a simple frustration that someone mentioned on the last page.
I'm using GMod13 Beta and I'm writing a basic function that follows the old "NPC Shop Tutorial" for gmod 12, it hooks the ENT:Initialize() function, yet when I do so I get the console error "attempt to index global 'ENT' (a nil value)"
[code]
function ENT:Initialize() --This function is run when the entity is created so it's a good place to setup our entity.
self:SetModel( "models/humans/group01/female_01.mdl" ) -- Sets the model of the NPC.
self:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things.
self:SetHullSizeNormal( )
self:SetNPCState( NPC_STATE_SCRIPT )
self:SetSolid( SOLID_BBOX ) -- This entity uses a solid bounding box for collisions.
self:CapabilitiesAdd( CAP_ANIMATEDFACE | CAP_TURN_HEAD ) -- Adds what the NPC is allowed to do ( It cannot move in this case ).
self:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use.
self:DropToFloor()
self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once.
print("Initialized entity!")
end
[/code]
Console:
[code]
[gamemodes/odaat/gamemode/init.lua:77] attempt to index global 'ENT' (a nil value)
[cpp] Couldn't Load Init Script: 'odaat/gamemode/init.lua'
[/code]
Any ideas? I'm guessing this is a Gmod 12->13 thing. The information right now is scattered and rarely relevant, so I'm struggling to build a working model of Gmod's extension via Lua
VVVVVV: AAAAUGGHHHHHHHHHHHHHHHHHHHHH
that code is for a scripted entity (SENT) and you are using it inside the gamemode :)
[QUOTE=Banana Lord.;37767993]that code is for a scripted entity (SENT) and you are using it inside the gamemode :)[/QUOTE]
Thank you very much. I'm struggling to get consistent resources/explanations on how to get comfortable with Lua in Gmod, it's very chaotic coming from environments I'm more used to (UDK, Unity, etc).
edit: My next struggle would be that ~2 days ago, I was doing a basic 3rd person camera trick via the "GM:ShouldDrawLocalPlayer()" trick in the clientside, except following yesterday's update, all it draws is a shadow.
I know I've read this before, but how do would you open a link in the steam overlay?
You cannot use ENT in gamemodes. You appear to not understand the code structure of the modding environment. If you are going to use ENT: in something, it needs to be part of an entity's code, not the gamemode's.
[editline]23rd September 2012[/editline]
whoops late
Sorry, you need to Log In to post a reply to this thread.