[QUOTE=Willox;45858164]You must be looking at old code. [url]https://github.com/garrynewman/garrysmod/blob/a4b68ce3e07f4a8f016343f65216debae6a03cd6/garrysmod/gamemodes/base/gamemode/player.lua#L184-L190[/url][/QUOTE]
Oh you are jesus.
Yeah the code was 1680 days old
[LUA]
local traceData = { ply:GetPos(), ply:GetPos() - Vector(0,0,1000) }
local tr = util.TraceLine( traceData )
PrintTable( tr )
if tr.Hit then MsgN("ASDDASD") end
[/LUA]
Am I doing tracelines all wrong?
This isn't hitting anything at all, ever.
[url]http://puu.sh/bgpHz/55f96f3dc3.png[/url]
First line shows ply:GetPos(), everything else is just coming up default.
traceData needs to have named keys, not just numbers.
Cheers
So trying to make a job npc(just like a f4 menu job but on a npc. ) So I took all the code from crazyscouters f4 menu(btw great f4 menu dude :D) and added it to npc and It works great. Though I'm trying to make it only government jobs show up, which I've accomplished! My only problem is the positioning.
This was default
[CODE]
for i, job in pairs(RPExtraTeams) do
if (GAMEMODE.CivilProtection[i]) then
local item = vgui.Create("DButton", jobsScroll);
item:SetSize(jobsScroll:GetWide(), 50);
item:SetPos(0, (i-1) 55);
item:SetText(" ");[/CODE] Now if I do that then it will become like this [t]http://i.imgur.com/PpnAHOs.jpg[/t]
And If I do this
[CODE]
local setpos = 0
for i, job in pairs(RPExtraTeams) do
if (GAMEMODE.CivilProtection[i]) then
local item = vgui.Create("DButton", jobsScroll);
item:SetSize(jobsScroll:GetWide(), 50);
item:SetPos(0, 55 + setpos );
item:SetText(" ");
setpos = setpos + 55
[/CODE] then it will become like larger and larger after everytime you open the menu.
Any able to help me out with creating a trigger entity?
Basically, I want to make a region defined by two points (the corners of the "box" region), where when a player enters (startTouch) I can do things with it.
I haven't seen any examples of creating a trigger entity, so if someone could point out the basics it would be great.
[QUOTE=PaellaPablo;45867423]Any able to help me out with creating a trigger entity?
Basically, I want to make a region defined by two points (the corners of the "box" region), where when a player enters (startTouch) I can do things with it.
I haven't seen any examples of creating a trigger entity, so if someone could point out the basics it would be great.[/QUOTE]
[url]http://facepunch.com/showthread.php?t=1415391[/url]
[QUOTE=wh1t3rabbit;45867442][url]http://facepunch.com/showthread.php?t=1415391[/url][/QUOTE]
The way that works is through timers and FindInBox, is there no way to actually just create a trigger entity rather than check every 0.5 seconds to see if there's players in one of the regions?
[QUOTE=PaellaPablo;45867477]The way that works is through timers and FindInBox, is there no way to actually just create a trigger entity rather than check every 0.5 seconds to see if there's players in one of the regions?[/QUOTE]
I have a slightly similar question, for my own future reference. Essentially a trigger would be just like checking for collision, reacting especially when intersecting. I've tried to use every collision type out there and failed miserably, but I'm sure there's a way? You speak of just one box, but I even imagine complex trigger shapes like ones that might be formed with brushes in hammer editor.
[editline]1st September 2014[/editline]
Oh, and a 2 point box as you described would not be capable of rotation. That would always be strictly aligned by the world coordinates, not local coordinates; maybe I word that wrong, but the box formed would have sides that are perfectly parallel to the real world coordinate vectors.
Does anyone have any cool [I]large[/I] fire sprites? I need to simulate spreading fire, and I don't really want to use some cheesy looking effect.
CS:Go and CS:S have some nice effects. I don't have them listed off hand, but they're what I'll be using once my fire system is done. They include actual flames, flames for walls / ground, etc..
[QUOTE=PaellaPablo;45867477]The way that works is through timers and FindInBox, is there no way to actually just create a trigger entity rather than check every 0.5 seconds to see if there's players in one of the regions?[/QUOTE]
just use a brush ent
Anyone know how I would go about treating values indexed on an object like a weapon, entity, or other class as a table? As in, do stuff like loop through them.
[QUOTE=BFG9000;45868727]Anyone know how I would go about treating values indexed on an object like a weapon, entity, or other class as a table? As in, do stuff like loop through them.[/QUOTE]
Lua is based around tables. The x.values should mean you can treat x as a table. If it is a custom type, create an iterator.
[QUOTE=Acecool;45868770]Lua is based around tables. The x.values should mean you can treat x as a table. If it is a custom type, create an iterator.[/QUOTE]
so then how come it gives me this whenever I try doing anything table-related other than look-up and storing values?
[code]
> for key,value in pairs(player.GetByID(1):GetActiveWeapon()) do print(value) end...
[ERROR] lua_run:1: bad argument #1 to 'pairs' (table expected, got userdata)
1. pairs - [C]:-1
2. unknown - lua_run:1
[/code]
[QUOTE=BFG9000;45868801]so then how come it gives me this whenever I try doing anything table-related other than look-up and storing values?
[code]
> for key,value in pairs(player.GetByID(1):GetActiveWeapon()) do print(value) end...
[ERROR] lua_run:1: bad argument #1 to 'pairs' (table expected, got userdata)
1. pairs - [C]:-1
2. unknown - lua_run:1
[/code][/QUOTE]Player:GetActiveWeapon() doesn't return a table. Instead, it returns the weapon the player has active.
[QUOTE=BFG9000;45868801]so then how come it gives me this whenever I try doing anything table-related other than look-up and storing values?
[code]
> for key,value in pairs(player.GetByID(1):GetActiveWeapon()) do print(value) end...
[ERROR] lua_run:1: bad argument #1 to 'pairs' (table expected, got userdata)
1. pairs - [C]:-1
2. unknown - lua_run:1
[/code][/QUOTE]
Because the weapon it returns is a 'userdata' object and not a Lua table/object and [URL="https://www.google.com.au/search?output=search&sclient=psy-ab&q=lua%20for%20pairs%20userdata&=&=&oq=&gs_l=&pbx=1"]pairs doesn't work on userdata[/URL].
To grab the table of a Weapon, use weapon:GetTable( ), you can also look through the weapons table and get the same results by using the class as a key ( if I recall correctly ).
-snip-
Moving to its own thread.
Hello all,
Is there any way to restart my server programmatically (when changing map is not enough to fix a problem) ? I would like to add a !voterestart command.
When a changemap is not enough though?
I think you can run something like __restart console command or something on the server.
restart concommand doesn't seem to work for me...
Here's a few commands I wrote:
[url]https://bitbucket.org/Acecool/acecooldev_base/src/[/url]
relevel <map> <gamemode> and remap <map> <gamemode>
If map is "" or the command is typed by itself, it'll use current map. remap uses map command which kicks players ( server restarting ). relevel is changelevel, no users get kicked.
Concommand file:
[url]https://bitbucket.org/Acecool/acecooldev_base/src/8e49df5b114e26033f38f96f8b83e587043610b1/gamemode/addons/_concommands/sv_rcon_commands.lua?at=master[/url]
And those call these hooks:
[url]https://bitbucket.org/Acecool/acecooldev_base/src/8e49df5b114e26033f38f96f8b83e587043610b1/gamemode/server/gm_restartmap.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/8e49df5b114e26033f38f96f8b83e587043610b1/gamemode/server/gm_restartlevel.lua?at=master[/url]
_restart works fine. I don't think your using the right command. Make sure you've got the underscore with it, just one.
Gotcha. _restart does work ( but "restart" is listed in "find restart" ). But, it doesn't re-launch the server, so you'd need to create a bat file that auto launches, or use seDirector or whatever.
Thank you guys, _restart worked ;)
[QUOTE=wh1t3rabbit;45868906]Because the weapon it returns is a 'userdata' object and not a Lua table/object and [URL="https://www.google.com.au/search?output=search&sclient=psy-ab&q=lua%20for%20pairs%20userdata&=&=&oq=&gs_l=&pbx=1"]pairs doesn't work on userdata[/URL].[/QUOTE]
I know, that's why I was asking in the first place.
I guess for the moment Acecool's solution will do for what I'm trying to do.
I can just loop through the weapon:GetTable() and for each key in that table lookup the corresponding value in the actual weapon object.
Thanks all.
I am trying to draw a sphere using the render library but I don't know which drawing hook to use.
Not that it seriously matters, there are workarounds but is there an effective way to check if a number is undefined?
Input:
lua_run_cl print(( 0/0 ), type( 0/0))
Output:
nan number
[B][U]EDIT:[/U][/B]
Input:
lua_run_Cl print(( 0/0 ), tonumber( "nan" ), type( 0/ 0 ), type( tonumber( "nan" )))
Output:
nan nan number number
Input:
lua_run_Cl print(( 0/0 ) == tonumber( "nan" ))
Output:
false
Hmmm, I guess that works. :)
[QUOTE=EthanTheGreat;45873804]Not that it seriously matters, there are workarounds but is there an effective way to check if a number is undefined?
Input:
lua_run_cl print(( 0/0 ), type( 0/0))
Output:
nan number
Is there an easy way I can check if a number is undefined?[/QUOTE]
Not sure if this is what you're getting at, but 0/0 == 0/0 always returns false
[lua]
function isnan (x)
return x ~= x
end
[/lua]
[QUOTE=Bnadm;45873576]I am trying to draw a sphere using the render library but I don't know which drawing hook to use.[/QUOTE]
PostDrawOpaqueRenderables
or I think you can even do it in RenderScreenspaceEffects if you wrap it in start3D(?)
I could be wrong though, and RenderScreenspaceEffects doesn't write Z either as far as I know.
Sorry, you need to Log In to post a reply to this thread.