[QUOTE=Trumple;38694674]Thanks for the info. I looked it up a little, however I couldn't get anything to show up....
[lua]
cam.Start3D2D( Vector(0, 0, 0), Angle(0, 0, 0), 1 )
draw.SimpleText( "Hello!", "SBTextHead", 0, 0, Color(0,0,0), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
cam.End3D2D()
[/lua]
That didn't show up anywhere, am I doing something wrong?
Cheers
[editline]4th December 2012[/editline]
[B]Called in a HUDPaint hook, and the hook is working correctly[/B][/QUOTE]
That's your problem. If you want to use it in HUDPaint, you will also need cam.Start3D/cam.End3D to create the 3D space.
You probably want to just draw a quad in one of the world rendering hooks (PostDrawTranslucentEntities?). Don't know why you would want to futz around with 2D stuff.
[lua]
local tr = util.TraceLine(tracestuff)
render.SetMaterial(matCircle)
render.DrawQuadEasy(tr.HitPos + tr.HitNormal, tr.HitNormal, 32, 32, color_white, 0)
[/lua]
[QUOTE=BlackAwps;38697115]That's your problem. If you want to use it in HUDPaint, you will also need cam.Start3D/cam.End3D to create the 3D space.[/QUOTE]
Ah ok, thanks! I'll give it a go later
I don't know if this is a lua problem or source engine but:
I am making a env_headcrabcanister entity and it works.
But when it lands, sometimes it causes the server to crash.
Does anyone know why ? I tried googling it but didn't find anything useful. (Call me Jeffrey if you find it in 2 seconds.)
Is it possible to hook a collision check to a "no-collide with everything" entity? Like when another entity tries to touch the no-collide entity. I tried the ShouldCollide hook but it didnt seem to work at all with anything
How would you write server side lua to block a client from running a console command?
[QUOTE=centran;38700761]How would you write server side lua to block a client from running a console command?[/QUOTE]
What do you want to block?
--nvm, figured it out --
Could anyone please tell me how to force unscope a SWEP about 0.2 seconds after it is fired? Would be most appreciated. Searching the wiki etc is finding zero results.
[QUOTE=Darkwater124;38700868]What do you want to block?[/QUOTE]
Well the actual command didn't really matter for my question but since you ask, I want to block players from using the act commands.
[QUOTE='[GM] Gaw;38701441']Could anyone please tell me how to force unscope a SWEP about 0.2 seconds after it is fired? Would be most appreciated. Searching the wiki etc is finding zero results.[/QUOTE]
show your code
[QUOTE=amkoc;38701696]show your code[/QUOTE]
For the scope?
[code]function SWEP:SecondaryAttack()
if not self.IronSightsPos then return end
if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
bIronsights = not self:GetIronsights()
self:SetIronsights( bIronsights )
if SERVER then
self:SetZoom(bIronsights)
else
self:EmitSound(self.Secondary.Sound)
end
self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
self.Weapon:SetNextPrimaryFire( CurTime() + 0.75)
end[/code]
[IMG]http://puu.sh/1x5xe[/IMG]
[lua]
print(pos:WithinAABox(start,stop))
[/lua]
Yet it returns false, I can't get my head around this stuff.
It probably has something to do about the rotation of the box.
Here's the vectors:
start = 464.608063 116.650543 291.452698
stop = 187.604889 -85.528511 106.157623
pos = 294.689453 -32.781403 88.056396
[QUOTE=ollie;38701928][IMG]http://puu.sh/1x5xe[/IMG]
[lua]
print(pos:WithinAABox(start,stop))
[/lua]
Yet it returns false, I can't get my head around this stuff.
It probably has something to do about the rotation of the box.
Here's the vectors:
start = 464.608063 116.650543 291.452698
stop = 187.604889 -85.528511 106.157623
pos = 294.689453 -32.781403 88.056396[/QUOTE]
Your position's Z value is too low. It's outside the box.
[QUOTE=ollie;38701928][IMG]http://puu.sh/1x5xe[/IMG]
[lua]
print(pos:WithinAABox(start,stop))
[/lua]
Yet it returns false, I can't get my head around this stuff.
It probably has something to do about the rotation of the box.
Here's the vectors:
start = 464.608063 116.650543 291.452698
stop = 187.604889 -85.528511 106.157623
pos = 294.689453 -32.781403 88.056396[/QUOTE]
Have you tried swapping the order of the Start and Stop arguments in the function? If so try this:
[lua]
function WithinAABB( Start, Stop, Point )
local x = ( Point.x > Stop.x and Point.x < Start.x ) or ( Point.x < Stop.x and Point.x > Start.x )
local y = ( Point.y > Stop.y and Point.y < Start.y ) or ( Point.y < Stop.y and Point.y > Start.y )
local z = ( Point.z > Stop.z and Point.z < Start.z ) or ( Point.z < Stop.z and Point.z > Start.z )
return ( x and y and z )
end
[/lua]
haven't tested it so consider it pseudo-code, but My best guess is the that the arguments could need to be in a different order.
Edit: Ninja, I didn't bother checking your values.
Hmm, I tried switching them to start,stop and it printed correctly.
But I have 2 different positions I'm checking and the other one's layout is following:
[IMG]http://puu.sh/1x6bs[/IMG]
So now it works for the other but not for that one.
Not even
[lua]
print((pos:WithinAABox(start,stop) or pos:WithinAABox(stop,start)))
[/lua]
worked.
I'll try your code now.
EDIT:
Your code works, thank you so much!
Quick question;
Is there a way to assign a function to be called when a ConVar (created by CreateConVar()) was changed?
[QUOTE=ief014;38705391]Quick question;
Is there a way to assign a function to be called when a ConVar (created by CreateConVar()) was changed?[/QUOTE]
[B][URL="http://wiki.garrysmod.com/page/Libraries/cvars/AddChangeCallback"]Cvars.AddChangeCallback [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B]
Damn, how did I miss that :v:
Thanks
Hey guys what'd be the best way to fade in a derma panel?
[QUOTE=C0MMUNIZT;38706477]Hey guys what'd be the best way to fade in a derma panel?[/QUOTE]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb753.html[/url]
[QUOTE=centran;38700761]How would you write server side lua to block a client from running a console command?[/QUOTE]
So I thought this might be as simple as adding a concommand with the same name to override the command but it is looking to be more difficult the more I try to research this.
I thought that some of the white/black list style anti-cheat/hack blocked certain commands by overriding them and that I could the same. However, I think that is only for commands the user has created and you can't do that for built in commands.
Anyone have any ideas about this?
Okay, so I just found out about [URL="http://wiki.garrysmod.com/page/Player_Classes"]the new Player Classes[/URL] and I'm trying to implement them into my gamemode, but it isn't working and I know next to nothing about lua so I can't figure out how to make it work without any documentation.
Essentially, I have a derma menu with buttons, and each button is supposed to change your class; the derma function is in client, and the class change is in server. There isn't any documentation that explains how to make it work and I have no examples to use or look at.
Here is the relevant client code:
[CODE]-- Medic
bdBluClass7 = vgui.Create( "DButton" )
bdBluClass7:SetText( "Medic - M416" )
bdBluClass7.DoClick = function()
surface.PlaySound( "jessev92/bf2/menu/kitSelect.wav" )
RunConsoleCommand("bd_mode_medic416") -- Run command
frame:Close()
end
CategoryList:AddItem( bdBluClass7 ) [/CODE]
Here is the relevant server code:
[code]function class_Medic()
MsgN("Test1") -- This prints
player_manager.SetPlayerClass( ply, "soldier_medic" ) - This gives no error
end
concommand.Add("bd_mode_medic416", class_Medic)[/code]
No errors are given.
The custom class name is 'soldier_medic'.
Edit:
any errors I do get are the same every time:
[code]lua/includes/modules/player_manager.lua:148: attempt to index local 'ply' (a nil value)[/code]
[QUOTE=pedrus24;38675642]Can someone tell me if it is possible to create a controllable NPC? And I mean as good as the player, with smooth and precise aiming and movement.
I need to know that before I go further into my gamemode. I plan to make the player control some NPCs and make them use custom weapons.[/QUOTE]
Anyone?
[QUOTE=TNOMCat;38700655]Is it possible to hook a collision check to a "no-collide with everything" entity? Like when another entity tries to touch the no-collide entity. I tried the ShouldCollide hook but it didnt seem to work at all with anything[/QUOTE]
?
How do I hide the message it says when I change server cvar?
Example: sbox_godmode 1
Server cvar value changed: sbox_godmode -> 1
I need to reproduce SetModelScale().
I can't figure out a new offset for my model scale. I think it's because the Matrix():Scale(vec) function [b]just scales[/b], and SetModelScale() did actualy [b]set[/b] the scale.
This was the former code.
[lua]
self.leftwing:SetModelScale(Vector(1,0.5,1)*self.Size*self.WingSize)
self.rightwing:SetModelScale(Vector(1,0.5,1)*self.Size*self.WingSize)
self.bleftwing:SetModelScale(Vector()*(self.Size/3*self.WingSize))
self.brightwing:SetModelScale(Vector()*(self.Size/3*self.WingSize))
[/lua]
This is the current code. (fucked up the model scale)
[lua]
local vec = Vector(1,0.5,1)*self.Size*self.WingSize
local vec2 = Vector()*(self.Size/3*self.WingSize)
local mat = Matrix()
mat:Scale(vec)
self.leftwing:EnableMatrix("RenderMultiply", mat)
self.rightwing:EnableMatrix("RenderMultiply", mat)
mat:Scale(vec2)
self.bleftwing:EnableMatrix("RenderMultiply", mat)
self.brightwing:EnableMatrix("RenderMultiply", mat)[/lua]
So basicaly I have to make a function which actualy sets the scale, basicaly like the old function.
Help please!
SV_CreatePacketEntities: GetEntServerClass failed for ent 551
What does that mean?
I'm having a problem. I set some models' render origin and angles via the SetRenderOrigin|Angles. It works great.
The models are drawing at a specified player's head pos and angles.
The problem is that when this player turns at a specified angle, the model stops drawing until he turns at some other specified angle. Ideas?
Sorry, you need to Log In to post a reply to this thread.