[QUOTE=ollie;37037673][lua]
[skyrp\gamemode\shared.lua:17] attempt to call method 'GetUserGroup' (a nil value)(Hook: PlayerNoClip)
[/lua]
Here is the code:
[lua]
function GM:PlayerNoClip( ply )
if ply:GetUserGroup() == "owner" or ply:GetUserGroup() == "superadmin" then
return true
else
return false
end
end
[/lua]
I don't see what i'm doing wrong, there are no errors in console when i start the server. And it worked perfectly before new update.[/QUOTE]
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4317.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4317.html[/URL]
[QUOTE=ollie;37037673][lua]
[skyrp\gamemode\shared.lua:17] attempt to call method 'GetUserGroup' (a nil value)(Hook: PlayerNoClip)
[/lua]
Here is the code:
[lua]
function GM:PlayerNoClip( ply )
if ply:GetUserGroup() == "owner" or ply:GetUserGroup() == "superadmin" then
return true
else
return false
end
end
[/lua]
I don't see what i'm doing wrong, there are no errors in console when i start the server. And it worked perfectly before new update.[/QUOTE]
Is that GetUserGroup() from ULX?
I see, so garry changed Player:GetUserGroup() to Player:IsUserGroup()?
Now i have to fix a lot of stuff :/
And nope, it was not ulx only.
Edit: Or was it? I don't have ulx here so yeah it might have been hah.
[QUOTE=ollie;37037947]I see, so garry changed Player:GetUserGroup() to Player:IsUserGroup()?
Now i have to fix a lot of stuff :/
And nope, it was not ulx only.
Edit: Or was it? I don't have ulx here so yeah it might have been hah.[/QUOTE]
What admin mod are you using?
Player:IsUserGroup("owner") can be used with ulx
GetUserGroup was never a method that was default, you always had to add it yourself.
[lua]function _R.Player:GetUserGroup()
return self:GetNWString( "UserGroup" )
end[/lua]
[QUOTE=BlackAwps;37038259]GetUserGroup was never a method that was default, you always had to add it yourself.
[lua]function _R.Player:GetUserGroup()
return self:GetNWString( "UserGroup" )
end[/lua][/QUOTE]
Thanks, really useful!
How do you find the position of the center of the map? A lot of maps don't center on 0,0,0 unfortunately.
[QUOTE=tr0ubl3mak3r;37038811]How do you find the position of the center of the map? A lot of maps don't center on 0,0,0 unfortunately.[/QUOTE]
Ah well, impossible as the center of the map is really relative. BUUUT, if you REALLY need it, get the position where the left most brush is, get the position where the right most brush is, divide by 2, do the same thing with the other 2 sides and bham, you got the relative x and y of the center of the map.
[QUOTE=Stillnex;37039328]Ah well, impossible as the center of the map is really relative. BUUUT, if you REALLY need it, get the position where the left most brush is, get the position where the right most brush is, divide by 2, do the same thing with the other 2 sides and bham, you got the relative x and y of the center of the map.[/QUOTE]
Are you saying there's a way to detect brushes in lua? Or are you saying scan around with traces? I was already considering using a tracing algorithm to attempt to get the dimensions of the map, but with underground areas it will require a lot of checking. I was hoping there was some sort of function I could use to find the map center easier.
Just iterate through func_brushes
[QUOTE=skullorz;37035593]Replace self with v, sorry.[/QUOTE]
I didn't have time to test it until today, and it doesn't work.
I added the Categories doing this:
[lua]
table.insert(Collaps, Cat1)
table.insert(Collaps, Cat2)
table.insert(Collaps, Cat3)
table.insert(Collaps, Cat4)
[/lua]
I printed the table after, and it returned:
1 = Panel: [name:Panel][class:Panel][5,5,480,50]
2 = Panel: [name:Panel][class:Panel][5,5,480,50]
3 = Panel: [name:Panel][class:Panel][5,5,480,50]
4 = Panel: [name:Panel][class:Panel][5,5,480,50]
When I press a header, it says:
[code]
[@messingaround\gamemode\base\client\main_menu.lua:61] bad argument #1 to 'pairs' (table expected, got nil) pairs [C]:-1
unknown messingaround\gamemode\base\client\main_menu.lua:61
[/code]
What's on line 56?
I'm sure you guys get this all the time, but should I learn Java or C++ before jumping into LUA? I have no experience with programming so I'm looking to start somewhere. I want to use it for more practical applications than just Gmod, so I would appreciate a starter guide for someone who's literally never coded before.
So far I've been looking through this guide: [url]http://lua.gts-stolberg.de/en/Programmieren.php[/url]
However, I doubt it'll get me far. It seems to be really simplified and probably won't help me in the long run. I just haven't had much luck finding a book or an internet source which starts from square one without assuming you know ANYTHING like what a syntax is, what a runtime environment is, etc. To get a feel for LUA I've been sifting through various addon LUA codes to see how the process is done, yet, it obviously makes little sense to me. I think doing this would be more resourceful when I actually have a grasp on the terminology of LUA and coding in general.
I appreciate any responses I can get!
[QUOTE=Rayss;37055806]I'm sure you guys get this all the time, but should I learn Java or C++ before jumping into LUA? I have no experience with programming so I'm looking to start somewhere. I want to use it for more practical applications than just Gmod, so I would appreciate a starter guide for someone who's literally never coded before.
So far I've been looking through this guide: [URL]http://lua.gts-stolberg.de/en/Programmieren.php[/URL]
However, I doubt it'll get me far. It seems to be really simplified and probably won't help me in the long run. I just haven't had much luck finding a book or an internet source which starts from square one without assuming you know ANYTHING like what a syntax is, what a runtime environment is, etc. To get a feel for LUA I've been sifting through various addon LUA codes to see how the process is done, yet, it obviously makes little sense to me. I think doing this would be more resourceful when I actually have a grasp on the terminology of LUA and coding in general.
I appreciate any responses I can get![/QUOTE]
First of all, it's called "Lua" not "LUA" (it's a name and not an acronym or something like that).
A good start to learn Lua should be this site: [URL]http://www.lua.org/pil/[/URL]
[QUOTE=pennerlord;37056883]First of all, it's called "Lua" not "LUA" (it's a name and not an acronym or something like that).
A good start to learn Lua should be this site: [URL]http://www.lua.org/pil/[/URL][/QUOTE]
Yeah I have that open actually, but it seems to be aimed at people who have experience with programming.
[QUOTE=Rayss;37057610]Yeah I have that open actually, but it seems to be aimed at people who have experience with programming.[/QUOTE]
Yeah I never really used it, I started out in a similar way, no previous programming experience at all (infact, learning Lua was what led me into learning C++/PHP/Java), and I always found the `official` Lua documentation long winded & over-complicated.
The tutorials on the old GMod wiki were pretty good, there are quite a few on the [url=http://wiki.garrysmod.com/page/Lua/Tutorials]new one[/url] too.
I learned from a combination of those, trial & error, the old Questions subforum (rip in peace) and other peoples stuff.
Hi, I'm having issues with scripted entities. When I set the model of a model with a ragdoll like say, [url]http://www.garrysmod.org/downloads/?a=view&id=115389[/url] the physics model is rotated 90 degrees on all axis away. This means I need to fiddle about with bone matrices, which are annoying and time consuming. Is there some kind of physics type I need to use aside from the usual SOLID_VPHYSICS?
[url]http://steamcommunity.com/id/ylsid/s...24819578009375[/url]
[url]http://steamcommunity.com/id/ylsid/s...24819578007546[/url]
Having issues with derma. Whenever I click on something other than the panel list, the panel list goes behind the derma frame.
Pic related.
[IMG]http://img98.imageshack.us/img98/6215/57199736.png[/IMG]
[lua]
function DrawAssassinGunMenu()
function Categoryitemgetname()
if categoryitemselected == nil then
return "Pick A Weapon"
else
return categoryitemselected
end
end
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetSize( 600, 325 )
DermaPanel:SetTitle( "Gun Menu" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( false )
DermaPanel:ShowCloseButton( true )
DermaPanel:Center()
DermaPanel:MakePopup()
DermaPanel:SetBackgroundBlur( true )
local TestingPanel = vgui.Create( "DPanel", DermaPanel )
local x,y = DermaPanel:GetPos()
TestingPanel:SetPos( 5, 25 )
TestingPanel:SetSize( 590, 132 )
TestingPanel.Paint = function() -- Paint function
--Set our rect color below us; we do this so you can see items added to this panel
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect
end
local Panel2 = vgui.Create( "DPanel", DermaPanel )
local x,y = DermaPanel:GetPos()
Panel2:SetPos( 5, 163 )
Panel2:SetSize( 590, 150 )
Panel2.Paint = function() -- Paint function
--Set our rect color below us; we do this so you can see items added to this panel
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 0, 0, Panel2:GetWide(), Panel2:GetTall() ) -- Draw the rect
end
local PrimaryLabel = vgui.Create("Label", DermaPanel )
local x,y = DermaPanel:GetPos()
PrimaryLabel:SetText("Primary Weapon")
PrimaryLabel:SetFont("defaultbold")
PrimaryLabel:SetPos(9, 28)
PrimaryLabel:SizeToContents()
local DescLabel = vgui.Create( "Label", Panel2 )
DescLabel:SetText("Pick A Weapon")
DescLabel:SetFont("defaultbold")
DescLabel:SetPos(5, 5)
DescLabel:SizeToContents()
local DescLabel2 = vgui.Create( "Label", Panel2 )
DescLabel2:SetText("Description text here you fucking clownshoe")
DescLabel2:SetPos(5, 20)
DescLabel2:SizeToContents()
local DermaList = vgui.Create( "DPanelList", TestingPanel )
local x,y = DermaPanel:GetPos()
DermaList:SetPos( x + 12, y + 45 )
DermaList:SetSize( DermaPanel:GetWide() - 25, 100 )
DermaList:SetSpacing( 5 ) -- Spacing between items
DermaList:EnableHorizontal( true ) -- Only vertical items
DermaList:EnableVerticalScrollbar( false ) -- Allow scrollbar if you exceed the Y axis
DermaList:MakePopup()
local CreditLabel = vgui.Create( "DLabel", Panel2 )
CreditLabel:SetFont("defaultbold")
CreditLabel:SetPos( 5, 82 )
CreditLabel:SetText("Credits to Unlock")
CreditLabel:SizeToContents()
local Credits = vgui.Create( "DProgressBar", Panel2)
Credits:SetSize( 300, 40 )
Credits:SetPos( 3, 100 )
Credits:SetMin( 0 )
Credits:SetMax(1000)
Credits:SetValue(10)
local CategoryItem1Panel = vgui.Create( "DPanel", DermaList )
CategoryItem1Panel:SetSize(100,100)
CategoryItem1Panel.Paint = function() -- Paint function
surface.SetDrawColor( 100, 100, 100, 255 )
surface.DrawOutlinedRect( 0, 0, 100, 100)
end
local CategoryItem1Gun = vgui.Create( "DModelPanel", CategoryItem1Panel )
CategoryItem1GunCost = 30
CategoryItem1Gun:SetPos(1,1)
CategoryItem1Gun:SetSize(98,98)
CategoryItem1Gun:SetModel( "models/weapons/w_rif_ak47.mdl" )
CategoryItem1Gun:SetToolTip("AK-47")
CategoryItem1Gun:SetCamPos( Vector( 40, 40, 0 ) )
CategoryItem1Gun:SetLookAt( Vector( 0, 7, 0 ) )
CategoryItem1Gun.OnMousePressed = function()
DescLabel:SetText("AK-47")
DescLabel2:SetText("It costs $200,000 to fire this weapon for twelve seconds.".."\n".."Pew Pew")
DescLabel2:SizeToContents()
Credits:SetMin( 0 )
Credits:SetMax(CategoryItem1GunCost)
end
DermaList:AddItem( CategoryItem1Panel )
local CategoryItem2Panel = vgui.Create( "DPanel", DemaList )
CategoryItem2Panel:SetSize(100,100)
CategoryItem2Panel.Paint = function()
surface.SetDrawColor( 100, 100, 100, 255 )
surface.DrawOutlinedRect( 0, 0, 100, 100)
end
local CategoryItem2Gun = vgui.Create( "DModelPanel", CategoryItem2Panel )
CategoryItem2GunCost = 50
CategoryItem2Gun:SetPos(1,1)
CategoryItem2Gun:SetSize(98,98)
CategoryItem2Gun:SetModel( "models/weapons/w_rif_m4a1.mdl" )
CategoryItem2Gun:SetToolTip("M4A1")
CategoryItem2Gun:SetCamPos( Vector( 40, 40, 0 ) )
CategoryItem2Gun:SetLookAt( Vector( 0, 7, 0 ) )
CategoryItem2Gun.OnMousePressed = function()
DescLabel:SetText("M4A1")
DescLabel2:SizeToContents()
DescLabel2:SetText("Standard issue army stuff.")
Credits:SetMin( 0 )
Credits:SetMax(CategoryItem2GunCost)
end
DermaList:AddItem( CategoryItem2Panel )
end
[/lua]
I really need help with 3d2d, the text is flat on the ground, how do I make it flat on a wall to face me?
[lua]Ang:RotateAroundAxis(Ang:Up(), 90)
cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11)[/lua]
Can someone tell me what I'm doing wrong here? I'm using WorldToLocal to get the position of one vector-angle pair (V1, A1) relative to another vector-angle pair. (V2, A2)
With V1 = [0, 0, -20], A1 = [315, 0, 0], V2 = [0, 0, -20], A2 = [0,0,0], I expected the resulting local vector to be [0,0,0] because V1 and V2 are equal. Instead, WorldToLocal(V1, A1, V2, A2) returns a vector [0, 6.8, -18.7].
EDIT: Solved. The compiler was reading my code better than I was; local entang, entpos = ent:getPos(), ent:getAng()
[QUOTE=tr0ubl3mak3r;37038811]How do you find the position of the center of the map? A lot of maps don't center on 0,0,0 unfortunately.[/QUOTE]
AFAIK there's no way of detecting map boundaries, but [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe357.html]util.IsInWorld[/url] can tell you what positions are within the map. You can iterate using that function over the whole map space (-16384 to 16384 xyz, obviously NOT one unit at a time D:) to gain a rough idea of where the boundaries are. This approach isn't cheap, and guessing how expensive that function is I'd recommend only doing that upon map loading :v:
Agh, right now I have a hud with text alignments on each side accordingly, like text that's on the right side of my screen is aligned to the right, but i'm confused on how i would make icons/textures appear the same way it's dynamically moving with the length of the text, can anyone give some tips?
So, I wanted to create a set of HL2 Sweps with drastically different damage and rate of fire.
Jvs kindly pointed me to the SWEP base in garrysmod's .gcf, but I can't wrap my head around it. Can someone please help me out?
Sorry if this isn't the right place but I don't browse this section often
[QUOTE=NitronikALT;37069081]So, I wanted to create a set of HL2 Sweps with drastically different damage and rate of fire.
Jvs kindly pointed me to the SWEP base in garrysmod's .gcf, but I can't wrap my head around it. Can someone please help me out?
Sorry if this isn't the right place but I don't browse this section often[/QUOTE]
You wouldn't need a them to be created again you can easily do this(If this applies to the HL2 weapons):
Weapon = ents.Create("weapon_357") --replace
Weapon.Primary.Damage = 999
Weapon.Primary.Delay = 0.1
Weapon.Primary.ClipSize = 100
Can you guys help me. I keep getting Error: !IsValidGamemode. When I try to load my gamemode.. Help!?
If a networked variable is set before the client loads into the server, does that networked variable get sent to the player on load? My code returns the empty string from running GetNWString() on the client. SetNWString() was run before I load my client onto the server. I tried running SetNWString() after the client was loaded and it succeeded.
I would like the variables to be global for all players, but it should only be synced to all players if it changes. How could the NW variable be set without resending to everyone in the server again? Please let me know if you have any links to helpful information, and thank you!
How can I get a point relative to another point and angle? I want to know the relative x and y positions to an angled square, from a point on the square found with an eye trace.
I feel I can do this using the angle from the center of the square to the eye trace point, but I cannot find the angle. Dotp, maga, and magb all print fine to the console, but ang prints #IND (indefinite?), and the game crashes if I try to use it.
[lua]
local dotp = ent:GetPos():DotProduct(tr.HitPos)
local maga = math.sqrt(ent:GetPos().x+ent:GetPos().y+ent:GetPos().z)
local magb = math.sqrt(tr.HitPos.x+tr.HitPos.y+tr.HitPos.z)
local ang = math.acos(dotp/(maga*magb))
print("dotp "..dotp)
print("maga "..maga)
print("magb "..magb)
print("ang "..ang)
testselectorent:SetPos(Angle(0,ang,0):Forward()*75)[/lua]
As cos can never be greater than 1 or less than -1, arccos is only defined for -1 <= x <= 1, check what dotp/(maga*magb) is, I'll bet it isn't in that range.
Can you re-word exactly what you're trying to do? I don't quite understand.
Also assuming maga means magnitude, shouldn't it be root(x^2 + y^2 + z^2) not root( x + y + z )? That could explain the invalid value being thrown to arccos.
[editline]4th August 2012[/editline]
OH you're trying to find the angle between two vectors, yeah that should work when you fix the magnitude calculation.
Thanks, that solved it not working. I do not understand the values I'm getting back, though.
While I'm not getting #IND or anything, the formula's output angle really must not be correct at all for some reason. For instance, it varies strongly depending on where the square is in the world, and which part of a straight line from the center I am looking at.
Maybe I am misunderstanding what this formula does. What I need is a way to find the angle from the center of a plane to a point on the plane determined by the player's eyetrace. I want to use this angle to later find the x and y position of the point, using the length of the line (I plan to put this angle and its length around the world center, then read the X and Y of the point).
[img]http://i47.tinypic.com/dq3aki.png[/img]
I am hoping to find that angle without having to worry about the angle of the plane as a whole in world space.
Sorry, you need to Log In to post a reply to this thread.