[QUOTE=rtm516;52390048]Any idea how i could find the closest entity of a certain type?[/QUOTE]
Loop through all entities of that type and test each's distance until you find the least.
[QUOTE=code_gs;52390236]Loop through all entities of that type and test each's distance until you find the least.[/QUOTE]
Oh ok, thaught there might be a better way of doing it. Thanks anyway.
Player:SetModel() isn't work. Well, its changes model, but only for some time. If I do it for npc - previous model returning so fast, if I do it for player - new model is holds, but movement lagging (like with low fps), and after jump/fire changes back. I'm also tryed to kill player and respawn in one moment, but I got new problem - Player:Kil()l and Player:KillSilently() just doesnt work!
[QUOTE]attempt to call method 'Kill' (a nil value)
[/QUOTE]
So its little strange, how can I fix this poblem?
Can you post the code?
[QUOTE=code_gs;52389104]The original weapon switcher is in C++. You can modify this skeleton here to check if the context menu is open in the PlayerPressBind hook before displaying the menu: [url]https://github.com/Kefta/Weapon-Switcher-Skeleton[/url][/QUOTE]
Additionally for the weapon selection is there any general way to ensure there isn't a menu visible beside explicitly making a check for each unique menu?
[editline]23rd June 2017[/editline]
[QUOTE=dannyf127;52391556]Additionally for the weapon selection is there any general way to ensure there isn't a menu visible beside explicitly making a check for each unique menu?[/QUOTE]
Nevermind just checked if the cursor was enabled.
For some reason the camera won't leave my body, wont look at the target, doesn't effect the angles and whatnot. This only occurs when I put the lerp on but I feel it can be encouraged by other factors like the position possibly having faults? You name it this code won't do it.
[lua]
net.Receive("OnUseInterface", function()
local entity = net.ReadEntity();
hook.Add("CalcView", "CalcInterfaceView", function(player, origin, angles, fov)
if (entity:IsValid()) then
local pos = entity:GetLocalPos() + entity:GetRight() * 9.77 + entity:GetUp() * 48 + entity:GetForward() * -2.2;
local ang = entity:GetLocalAngles();
ang:RotateAroundAxis(ang:Right(), -42);
ang:RotateAroundAxis(ang:Up(), 90);
local view = {
origin = LerpVector(FrameTime() * 4, origin, pos),
angles = LerpAngle(FrameTime() * 4, angles, ang),
};
return view;
end;
end);
timer.Simple(3, function()
hook.Remove("CalcView", "CalcInterfaceView");
end);
end);
[/lua]
[video]https://youtu.be/2a84Tavfa_c[/video]
When I alt tab
If I use SetNWInt on a player, can a different player see it through GetNWInt?
How expensive is GetNWInt?
If I'm gonna be drawing a variable in a HUD, would it be better to store it as a player var and update it every time it changes on the server?
[QUOTE=JasonMan34;52392410]How expensive is GetNWInt?
If I'm gonna be drawing a variable in a HUD, would it be better to store it as a player var and update it every time it changes on the server?[/QUOTE]
It's not. It just acts as a lookup in the nettable -- don't make things unnecessarily more complex.
I have a small problem with logic
I'm running a code inside the think hook to increase a variable until it reach 50 then print a msg
But because of think hook it run continuously and spamming my console with the msg, is there a way to make something run 1 time in think hook? or even a better way to do that
[QUOTE=YoutoYokodera;52392563]I have a small problem with logic
I'm running a code inside the think hook to increase a variable until it reach 50 then print a msg
But because of think hook it run continuously and spamming my console with the msg, is there a way to make something run 1 time in think hook? or even a better way to do that[/QUOTE]
Set a variable and check that it's true.
[CODE]
local something = true
hook.Add( "Think", "blah", function()
if something then
number = number + 1
if number >= 50 then
-- print stuff
something = false
end
end
end )
[/CODE]
What are you doing this for anyway?
[QUOTE=MPan1;52392575]Set a variable and check that it's true.
[CODE]
local something = true
hook.Add( "Think", "blah", function()
if something then
number = number + 1
if number >= 50 then
-- print stuff
something = false
end
end
end )
[/CODE]
What are you doing this for anyway?[/QUOTE]
A flag entity for capturing xd
[editline]23rd June 2017[/editline]
Ok so i solved it, and is there a way to make ply:PrintMessage display longer?
[QUOTE=YoutoYokodera;52392598]A flag entity for capturing xd
[editline]23rd June 2017[/editline]
Ok so i solved it, and is there a way to make ply:PrintMessage display longer?[/QUOTE]
Always include your solution if you solved it yourself. It can help people that might encounter the same problem. [URL="https://xkcd.com/979/"]Don't be DenverCoder9[/URL]
As for the PrintMessage - Don't think so
[QUOTE=code_gs;52392427]It's not. It just acts as a lookup in the nettable -- don't make things unnecessarily more complex.[/QUOTE]
Damm, learning from reading the TTT code is a big mistake :/
[QUOTE=YoutoYokodera;52392598]A flag entity for capturing xd[/QUOTE]
CurTime() is a far, far better alternative to adding 1 to a number. This will run at different speeds on different computers, but CurTime() is always the same speed.
[CODE]
local time
local captured = false
hook.Add( "Think", "CaptureFlag", function()
if !time then time = CurTime() + 3 end -- set the capture time to 3 seconds
if CurTime() > time and !captured then
-- do captured stuff
captured = true
end
end )
[/CODE]
[QUOTE=Mrkostet;52391168]Player:SetModel() isn't work. Well, its changes model, but only for some time. If I do it for npc - previous model returning so fast, if I do it for player - new model is holds, but movement lagging (like with low fps), and after jump/fire changes back. I'm also tryed to kill player and respawn in one moment, but I got new problem - Player:Kil()l and Player:KillSilently() just doesnt work!
So its little strange, how can I fix this poblem?[/QUOTE]
[CODE]if key == IN_USE then
LocalPlayer():Kill()
LocalPlayer():SetModel('models/player/alyx.mdl')
end[/CODE]
(Player(1):Kill() used too)
Also tryed to use KillSilent() but got same result.(I need exactly KillSilent() or change skin without killing by the way.)
[QUOTE=Mrkostet;52392757][CODE]if key == IN_USE then
LocalPlayer():Kill()
LocalPlayer():SetModel('models/player/alyx.mdl')
end[/CODE]
(Player(1):Kill() used too)
Also tryed to use KillSilent() but got same result.(I need exactly KillSilent() or change skin without killing by the way.)[/QUOTE]
SetModel will only work properly on the server, but LocalPlayer() is a client-side function.
Also, Kill is not a function on the client
[QUOTE=MPan1;52392720]CurTime() is a far, far better alternative to adding 1 to a number. This will run at different speeds on different computers, but CurTime() is always the same speed.
[CODE]
local time
local captured = false
hook.Add( "Think", "CaptureFlag", function()
if !time then time = CurTime() + 3 end -- set the capture time to 3 seconds
if CurTime() > time and !captured then
-- do captured stuff
captured = true
end
end )
[/CODE][/QUOTE]
But i have to do it for 2 teams
[QUOTE=YoutoYokodera;52392986]But i have to do it for 2 teams[/QUOTE]
Not an issue.
Are we talking domination-like capture?
Have a capture state variable set to 1 2 or 0 (Team1/Team2/Uncaptured) and run capture logic based on that. (For someone on Team1 - 0 = 3 seconds to capture. 2 = 6 seconds to capture)
[QUOTE=JasonMan34;52393011]Not an issue.
Are we talking domination-like capture?
Have a capture state variable set to 1 2 or 0 (Team1/Team2/Uncaptured) and run capture logic based on that. (For someone on Team1 - 0 = 3 seconds to capture. 2 = 6 seconds to capture)[/QUOTE]
How do i handle the reverse capture then? Like when u cap 50% i must pull it down to 0 first then it starts counting on my team
[QUOTE=YoutoYokodera;52393069]How do i handle the reverse capture then? Like when u cap 50% i must pull it down to 0 first then it starts counting on my team[/QUOTE]
There are many ways to make a king-of-the-hill system, but the how of it is for you to realize...
You could use a number for the capture state that is not 0/1/2 but rather something else.
If Team1 is standing on the point the number increases by 1 per second.
If Team2 is standing on the point the number decreases by 1 per second.
Clamp the number between -5 and 5 to limit the capture time.
Once the number gets to -5 or 5, set the new team that has captured the point
This allows you to do all kinds of stuff with capture time (e.g. for every extra player of a team, increase/decrease 75% faster) and keep a smooth feeling.
In this method, you'll need to either use a timer or a [URL="http://wiki.garrysmod.com/page/Delays_and_Cooldowns"]CurTime delay[/URL] to run the function X times per second, and increase the value by 1/X every time (So the value goes up by 1 every 1 second)
Is there a way to silence NPCs? I'm using some reskinned combine for a gamemode, but I'd like to use different death sounds and callouts that I'd manually call via EmitSound.
edit: Shutting off chatter was just using entity:Fire("GagEnable") after the npc was spawned. They no longer yammer about things. However, death is still the combine scream.
edit: actually not true - i had to stop them being in the same squad to disable chatter. can't stop the combine scream :(
[QUOTE=Sestze;52394064]Is there a way to silence NPCs? I'm using some reskinned combine for a gamemode, but I'd like to use different death sounds and callouts that I'd manually call via EmitSound.
edit: Shutting off chatter was just using entity:Fire("GagEnable") after the npc was spawned. They no longer yammer about things. However, death is still the combine scream.
edit: actually not true - i had to stop them being in the same squad to disable chatter. can't stop the combine scream :([/QUOTE]
Is there a way to delete the entity before it takes lethal damage to avoid it existing long enough to play the death sound maybe?
My question: Does anyone know what the simplest way is to have a score for two teams that can be read from the GUI? I'm so new to this and I always end up with a nil amount.
Trying to display a DImage and this happens for some reason
[lua]local frame = vgui.Create( "DFrame" )
frame:SetSize( ScrW()/2, ScrH()/2 )
frame:Center()
frame:MakePopup()
frame.Paint = function( _, w, h )
draw.RoundedBox(0, 0, 0, w, h, Color(0,0,0))
end
local icon = vgui.Create( "DImage", frame )
icon:SetImage( "materials/roman_numerals/roman_1.png" )
-- icon:SetImageColor(Color(255, 255, 255, 255))
icon:SetSize(56*6, 56*6)
icon:SetPos(200,30)[/lua]
[t]https://image.prntscr.com/image/XVMfhnkmQb_5N_mX2GXpmQ.png[/t]
[B]materials/roman_numerals/roman_1.png[/B]:
[t]https://i.imgur.com/eBAAYE7.png[/t]
Same thing happens when displaying it in original size ([B]icon:SetSize(306, 306)[/B]) and when changing the background color of the DFrame to white
Have you tried using an IMaterial?
[CODE]
local mat = Material( "roman_numerals/roman_1.png", "noclamp smooth" )
image:SetMaterial( mat )
[/CODE]
Maybe one of the parameters will fix it
[QUOTE=MPan1;52394734]Have you tried using an IMaterial?
[CODE]
local mat = Material( "roman_numerals/roman_1.png", "noclamp smooth" )
image:SetMaterial( mat )
[/CODE]
Maybe one of the parameters will fix it[/QUOTE]
Nothing worked :/
[QUOTE=JasonMan34;52394744]Nothing worked :/[/QUOTE]
alphatest?
Do entities' collision bounds change depending on their angles? If not how would I do this? (For example, to stop a client prop from going through the world or hovering 5 feet above it when its angles are changed. Basically, have the prop flush with whatever surface it comes into contact with.)
I've got some problems with cam.3D2D.
At some points of a map or in front of a prop the 3D2D bugs out like that: [url]https://gyazo.com/7b64d4274fd8ad4bb6b5f0642c100126[/url] or isn't visible at all.
Am I doing something wrong or missing something?
[QUOTE=Benn20002;52396382]I've got some problems with cam.3D2D.
At some points of a map or in front of a prop the 3D2D bugs out like that: [url]https://gyazo.com/7b64d4274fd8ad4bb6b5f0642c100126[/url] or isn't visible at all.
Am I doing something wrong or missing something?[/QUOTE]
As you're drawing 3D2D i'd say you're using this hook, right? [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PostDrawTranslucentRenderables]GM:PostDrawTranslucentRenderables[/url]
You should try using this other hook as well [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PostDrawOpaqueRenderables]GM:PostDrawOpaqueRenderables[/url]
Do you mean I should use both hooks or just PostDrawOpaqueRenderables?
I am currently only using PostDrawOpaqueRenderables.
Sorry, you need to Log In to post a reply to this thread.