[QUOTE=Internet1001;45787179]I believe that people were using [url=http://wiki.garrysmod.com/page/Vector/WithinAABox]Vector/WithinAABox[/url] with [url=http://wiki.garrysmod.com/page/Global/OrderVectors]OrderVectors[/url] for a more efficient method.
Try this
[lua]meta = FindMetaTable( "Player" )
local box = {
Vector( 1, 1, 1 ),
Vector( 2, 2, 2 )
}
function meta:InBox( box )
OrderVectors( box[1], box[2] )
return ply:GetPos():WithinAABox( box[1], box[2] )
end[/lua][/QUOTE]
Originally it didn't like the 'ply' in return ply, changed that to meta. Then it seems to complain about GetPos.
Code:
[code]
meta = FindMetaTable( "Player" )
function meta:InBox( box )
OrderVectors( box[1], box[2] )
return meta:GetPos():WithinAABox( box[1], box[2] )
end
function BlackOpsKOSarea()
local plys = {}
for k, v in pairs( team.GetPlayers( 1 ) ) do
local box = { Vector(-1516.791748, 484.499115, -90.906036), Vector(-647.333740, 198.264969, 259.077789) }
if v:InBox( box ) and !v.sent then
umsg.Start( "EnterKOS", v )
umsg.End()
v.sent = true
v.sent2 = false
end
end
.....
[/code]
[QUOTE=Adzter;45787479]Originally it didn't like the 'ply' in return ply, changed that to meta. Then it seems to complain about GetPos.
Code:
[code]
meta = FindMetaTable( "Player" )
function meta:InBox( box )
OrderVectors( box[1], box[2] )
return meta:GetPos():WithinAABox( box[1], box[2] )
end
function BlackOpsKOSarea()
local plys = {}
for k, v in pairs( team.GetPlayers( 1 ) ) do
local box = { Vector(-1516.791748, 484.499115, -90.906036), Vector(-647.333740, 198.264969, 259.077789) }
if v:InBox( box ) and !v.sent then
umsg.Start( "EnterKOS", v )
umsg.End()
v.sent = true
v.sent2 = false
end
end
.....
[/code][/QUOTE]
Use self, not meta.
Looks like it's working, but since the table containing the players gets reset when the function is ran then a umsg will be sent everytime the function is ran.
[QUOTE=Adzter;45787552]Looks like it's working, but since the table containing the players gets reset when the function is ran then a umsg will be sent everytime the function is ran.[/QUOTE]
Did you try my code above? I think that should work for you.
So I recently used Source SDK Base 2007 to create a nav mesh for a map I'm working on. The nav mesh works fine if deposited directly in the garrysmod/maps/ folder, but if I put it inside an addon (.gma file), I get the error:
[code]Nav File is wrong or something (1)
[/code]
Any ideas? I've tried googling to no avail. I know this might be more of a mapping question but I saw the NextBot thread and all the Gmad.exe posts in this forum so I thought I'd try here as well.
EDIT:
Great news!
I had tried packing the .nav directly into the map, and it was coming up with the same error. However, it appears that my map file was not packing correctly. VIDE is based on Pakrat and I have heard that packing multiple times can cause errors. I originally did one packing job in which I removed faulty cubemaps and added custom content in one swoop - but then added the nav mesh in a separate packing job. Apparently, you need to do ALL your packing in one go, or the map file will corrupt slightly (or at least, the Nav mesh won't work.)
Packing into .gma's still doesn't work at all, but at least I know I can pack the .nav straight into the map. Hope this helps someone out there.
How do you make file.Read only read serverside files I've tried reading it serverside and sending it using net.write table but it still won't work.
[QUOTE=Icejjfish;45788067]How do you make file.Read only read serverside files I've tried reading it serverside and sending it using net.write table but it still won't work.[/QUOTE]
What do you mean?
Using file.Read serverside can read files on the server. Using it on the client can read files on the client it's used on.
Something is going wrong with my gamemode causing clients to time out. I can only assume it's something clientside that's breaking everything, as the server doesn't crash.
Users can sit idle in console or in the pause menu without any crashing, but on random intervals of 2 to 5 minutes the server says the client times out.
I'm getting feedback that gmod is literally just closing straight to desktop without any warning, and have just recently been subject to the same. Anyone have any ideas where I should start diagnosing this because I'm stumped
[QUOTE=solid_jake;45791369]Something is going wrong with my gamemode causing clients to time out. I can only assume it's something clientside that's breaking everything, as the server doesn't crash.
Users can sit idle in console or in the pause menu without any crashing, but on random intervals of 2 to 5 minutes the server says the client times out.
I'm getting feedback that gmod is literally just closing straight to desktop without any warning, and have just recently been subject to the same. Anyone have any ideas where I should start diagnosing this because I'm stumped[/QUOTE]
You'd have to give us quite a bit more information to go on. Such as the gamemode, addons, and provide in depth details about both of those things.
[QUOTE=Jeezy;45791427]You'd have to give us quite a bit more information to go on. Such as the gamemode, addons, and provide in depth details about both of those things.[/QUOTE]
-snip-
Nevermind, converting all the NWInts into umsgs seemed to do the trick. Complicated but there's no more overflows
[QUOTE=solid_jake;45791628]-snip-
Nevermind, converting all the NWInts into umsgs seemed to do the trick. Complicated but there's no more overflows[/QUOTE]
Try to use [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]the Net Library[/URL] instead of umsgs. If you need any help with net messages you can ask.
EDIT: [URL="http://facepunch.com/showthread.php?t=1304676"]and this is why Net is better than usermessages[/URL]
I'm starting work on a HUD that uses surface.DrawPoly for drawing it and I have separate functions to generate each of the elements. While some of the elements are static, the health display would need to change every time the player loses or gains hp. Will running the functions to generate tables greatly reduce performance?
If so, will precaching the player's hp work? Sort of like this:
[lua]
local oldHp, hpT
hook.Add( "HUDPaint", "DrawHUD", function()
local hp = ply:Health()
if ( not oldHp ) or oldHp != hp or ( not hpT ) then
oldHp = hp
hpT = GenerateHealthTable( x, y, w, h ) // let's pretend these are real args
end
end )
[/lua]
And noob question, but for png images, do I use surface.SetMaterial or SetTexture?
Oh my god this is driving me INSANE!!!
as written:
[code]/*---------------------------------------------------------
SetIronsights
---------------------------------------------------------*/
function SWEP:SetIronsights(b)
if !self.CanIron then return end
self.Weapon:SetNWBool("Ironsights", b)
end
function SWEP:GetIronsights()
return self.Weapon:GetNWBool("Ironsights")
end
/*---------------------------------------------------------
SetSpecial
---------------------------------------------------------*/
function SWEP:SetSpecial(b)
local ToPrint = "false"
if b then ToPrint = "true" end
print( "Setting to "..ToPrint )
self.Special = b
if !self.CanIron then return end
self.Weapon:SetNWBool("Special", b)
end
function SWEP:GetSpecial()
print( self.Weapon:GetNWBool("Special")
return self.Weapon:GetNWBool("Special")
end[/code]
[code]...
if string.lower( self.SpecialType ) == "silencer" then
if !self:GetSpecial() then
self:SendWeaponAnim( self.SpecialActivate )
timer.Simple( self.Owner:GetViewModel():SequenceDuration(), function()
if IsValid( self ) && IsValid( self.Owner ) then
self:SetSpecial( true )
self.CanIron = true
self:SendWeaponAnim( self.SpecialActive )
self:SetNextPrimaryFire( CurTime() + 0.2 )
self:SetNextSecondaryFire( CurTime() + 0.2 )
end
end )
else
self:SendWeaponAnim( self.SpecialDeactivate )
timer.Simple( self.Owner:GetViewModel():SequenceDuration(), function()
if IsValid( self ) && IsValid( self.Owner ) then
self:SetSpecial( false )
self.CanIron = true
self:SendWeaponAnim( self.SpecialDisabled )
self:SetNextPrimaryFire( CurTime() + 0.2 )
self:SetNextSecondaryFire( CurTime() + 0.2 )
end
end )
end
elseif string.lower( self.SpecialType ) == "automatic" then
...[/code]
No matter what when I call self:GetSpecial() it's returning false!
HOWEVER, self:GetIronsights() seems to work perfectly fine!
(I'm ashamed of my ironsight setting function, so I won't post it. I need to rewrite it for sprint and crouch-sneaking ironsights to work properly)
[B]EDIT:[/B]
If you can make sense of it, this is what the console prints:
[quote=Garry's Mod - Developer Console]Setting to falsefalse
false
false
Light Military
Model 01 M4A1-S spawned with special type *silencer* disabled
Light Military
Model 01 M4A1-S spawned with 31 rounds loaded
false
Giving Dr. Scandalous™ a c01e1_m4a1
false
false
false
Light Military
Model 0 M4A1-S spawned with special type *silencer* disabled
Light Military
Model 01 M4A1-S spawned with 19 rounds loaded
false
false
false
false
Dr. Scandalous™ disabled special type *silencer* for Light Military
Model 01 M4A1-S
Setting to true
false
false
false
false[/quote]
Either remove the self.CanIron check from SetSpecial (it seems to me that this is just unintended remains from copy-pasting SetIronsights), or set it to true BEFORE you call SetSpecial rather than after.
[QUOTE=Bo98;45798469]Either remove the self.CanIron check from SetSpecial (it seems to me that this is just unintended remains from copy-pasting SetIronsights), or set it to true BEFORE you call SetSpecial rather than after.[/QUOTE]
[del]I really don't get the relevant relation between ironsights and 'special' (this is part of a giant all-purpose base weapon script, fyi)[/del]
I see what you mean! I can't believe I missed that!
Fixed the problem, and accomplished my bug fix, THANKS!!! [t]http://www.facepunch.com/fp/ratings/heart.png[/t]
What is the difference between ClientsideModel, an effect, or a ents.CreateClientProp?
Do any have any benefits over the other as far as performance and such?
[QUOTE=Revenge282;45799285]What is the difference between ClientsideModel, an effect, or a ents.CreateClientProp?
Do any have any benefits over the other as far as performance and such?[/QUOTE]ents.CreateClientProp creates a clientside model with physics, whilst on the other hand, ClientsideModel creates a clientside model without physics and just the model. As for which one to use, it depends on whether you need it to have physics or not, though ClientsideModel is generally the way to go.
This is going to sound stupid (and probably is stupid), but I can't seem to get timer.Simple to work correctly. It is documented as timer.Simple(delay, func), where delay is a delay in seconds, and func is the function to call after 'delay' seconds. I can only seem to get func to be called when delay is 0, as can be seen here;
[CODE]lua_run timer.Simple(0, function() print("HI") end) -- This works fine
lua_run timer.Simple(1, function() print("HI") end) -- No output[/CODE]
What am I doing wrong?
[QUOTE=jackwilsdon;45800249]This is going to sound stupid (and probably is stupid), but I can't seem to get timer.Simple to work correctly. It is documented as timer.Simple(delay, func), where delay is a delay in seconds, and func is the function to call after 'delay' seconds. I can only seem to get func to be called when delay is 0, as can be seen here;
[CODE]lua_run timer.Simple(0, function() print("HI") end) -- This works fine
lua_run timer.Simple(1, function() print("HI") end) -- No output[/CODE]
What am I doing wrong?[/QUOTE]
Well... perhaps because of where you're calling the code it doesn't wait the 1 second?
Otherwise, the console should print HI 1 second after you enter that?
Anyway, [U]I have my own question as well.
[/U]I don't know how to make scripted NPC's, even with nextbot... I tried, but I want to learn how and this is just a fore-question; is it possible to use a hard coded NPC as a base, or mimic its behavior with just a few lines of code? I want to take the combine soldier's AI and apply it to my own, but script in a few exceptions, such as maybe making it use suit chargers, simulating suit armor, making it react to flash bangs, etc, etc, etc... So the general question would be, is there a way to make a SNPC pull behaviors from the hard-coded AI system?
[QUOTE=jackwilsdon;45800249]This is going to sound stupid (and probably is stupid), but I can't seem to get timer.Simple to work correctly. It is documented as timer.Simple(delay, func), where delay is a delay in seconds, and func is the function to call after 'delay' seconds. I can only seem to get func to be called when delay is 0, as can be seen here;
[CODE]lua_run timer.Simple(0, function() print("HI") end) -- This works fine
lua_run timer.Simple(1, function() print("HI") end) -- No output[/CODE]
What am I doing wrong?[/QUOTE]
If it's a dedicated server, join the server and it should run.
[QUOTE=Exho;45776436]Send me the code you used please
Not even do those numbers work for me
[IMG]http://i.gyazo.com/3674a60b19e6ecce91e273ae17e44126.png[/IMG]
[code]
function PANEL:Avatar(ply)
self.Avatar = vgui.Create( "AvatarImage", self )
self.Avatar:SetPos( 7, 7 )
self.Avatar:SetSize(128, 128)
self.Avatar:SetPlayer(ply, 128)
end
[/code][/QUOTE]
You can do what I did in my death badge, make the avatar 184x184 and then cut out the checkered part by parenting a 128x128 dummy panel to the AvatarImage.
[QUOTE=Loures;45802976]You can do what I did in my death badge, make the avatar 184x184 and then cut out the checkered part by parenting a 128x128 dummy panel to the AvatarImage.[/QUOTE]
Well that is a rather hacky way to do that , If i were you i would use the recommended sizes or powers by 2
[QUOTE=sm69baller;45803074]Well that is a rather hacky way to do that , If i were you i would use the recommended sizes or powers by 2[/QUOTE]
That's not the issue, it will still cause the purple-black checkered texture to appear, you need to clip it.
So I'm trying to spawn a boat model that floats using the following code:
[code]
function spawnprop( ply, props )
local ent = ents.Create("prop_physics")
ent:SetModel( props )
ent:SetPos( ply:GetPos() )
ent:SetOwner( ply )
ent:PhysicsInit( SOLID_VPHYSICS )
ent:SetSolid( SOLID_VPHYSICS )
ent:SetMoveType( MOVETYPE_VPHYSICS )
local physics = ent:GetPhysicsObject()
ent:Spawn()
if ( physics:IsValid() ) then
physics:SetMass( 100 )
physics:SetBuoyancyRatio( 0.7 )
physics:Wake()
end
end
spawnprop( ply, "models/props_wasteland/boat_fishing01a.mdl" )
[/code]
However I just get this:
[vid]http://fat.gfycat.com/LinedCooperativeAssassinbug.webm[/vid]
[QUOTE=Adzter;45803319]So I'm trying to spawn a boat model that floats using the following code:
[code]
function spawnprop( ply, props )
local ent = ents.Create("prop_physics")
ent:SetModel( props )
ent:SetPos( ply:GetPos() )
ent:SetOwner( ply )
ent:PhysicsInit( SOLID_VPHYSICS )
ent:SetSolid( SOLID_VPHYSICS )
ent:SetMoveType( MOVETYPE_VPHYSICS )
local physics = ent:GetPhysicsObject()
ent:Spawn()
if ( physics:IsValid() ) then
physics:SetMass( 100 )
physics:SetBuoyancyRatio( 0.7 )
physics:Wake()
end
end
spawnprop( ply, "models/props_wasteland/boat_fishing01a.mdl" )
[/code]
[/QUOTE]
Have you tried a lower buoyancy ratio? On the wiki they say "realistic buoyancy" is 0.025
Yeah setting it to that has the same effect.
try putting some [b] print [/b] function into your [b]if[/b] statement and check this code runs...
How would I get a sound to play once when a value is "set" but have it not play when the value is reset or gets higher
[QUOTE=Dexter127;45803491]try putting some [b] print [/b] function into your [b]if[/b] statement and check this code runs...[/QUOTE]
Doesn't look like it's being ran, am I calling something in the wrong order?
EDIT: Yeah I needed to call ent:GetPhysicsObject after it had spawned.
[code]
ent:Spawn()
local physics = ent:GetPhysicsObject()
if ( physics:IsValid() ) then
print("Does this run?")
physics:SetMass( 100 )
physics:SetBuoyancyRatio( 0.025 )
physics:Wake()
end
[/code]
Works fine, thanks for the help guys.
EDIT2: Only problem is that it doesn't look like the model collides with the player, I've set the physics type, move type and used setsolid. It collides with other props just not the player;
[code]
ent:PhysicsInit( SOLID_VPHYSICS )
ent:SetSolid( SOLID_VPHYSICS )
ent:SetMoveType( MOVETYPE_VPHYSICS )
ent:Spawn()
[/code]
Remove the ent:SetOwner( ply ) part
Sorry, you need to Log In to post a reply to this thread.