[QUOTE=keeperman;49237030]My timer doesn't get removed after it's done so nothing happens
BTW how do I remove the number after a number slide?
•••••••••••••••••••••V This bit
|----------------------| 58[/QUOTE]
The Garry's Mod GitHub is really useful for editing the parts of a derma element.
[URL="https://github.com/garrynewman/garrysmod/blob/3e138636eb1b0ad6ed785dedf350020755cff5f1/garrysmod/lua/vgui/dnumberwang.lua"]This is the page for the DNumberWang[/URL], take a look through the code for any DLabels that are changed when the "wang" slides. You should be able to :SetVisible(false) on them to remove them.
[editline]3rd December 2015[/editline]
[QUOTE=Leyserr;49237628]I'm trying to get the amount of staff online but I can't seem to do it because staffOn always returns 0, any help would be appreciated.
Here is my current code:
[lua]
local ulxRanks = {"moderator", "vipmoderator", "admin", "headadmin", "superadmin"}
function getStaff()
for k,v in pairs(player.GetAll()) do
if table.HasValue(ulxRanks,v.GetUserGroup()) then
staffOn = staffOn + 1
end
end
end[/lua][/QUOTE]
v:GetUserGroup, not v.GetUserGroup
staffOn is nil and must be defined, just put local staffOn = 0 at the top of your code.
you also need to call getStaff() if you aren't already
Thanks man.
But now staffOn is indefinitely incrementing, is there a way to stop this?
[QUOTE=Leyserr;49237628][lua]
local ulxRanks = {"moderator", "vipmoderator", "admin", "headadmin", "superadmin"}
function getStaff()
for k,v in pairs(player.GetAll()) do
if table.HasValue(ulxRanks,v.GetUserGroup()) then
staffOn = staffOn + 1
end
end
end[/lua][/QUOTE]
This is literally one of the grossest and slowest ways you could do that. Here's an equally gross but much faster way:
[lua]
local staff_ranks = {
moderator = true,
vipmoderator = true,
admin = true,
headadmin = true,
superadmin = true,
}
function player.GetStaff()
local tab = player.GetAll()
local c = 1
for i = 1, #tab do
if staff_ranks[tab[i]:GetUserGroup()] then
tab[c] = tab[i]
c = c + 1
end
end
for i = c, #tab do
tab[i] = nil
end
return tab
end
[/lua]
How am I supposed to add " to a table?
Like table.insert( thing, "["b"]" )
bad, you're doing all these micro-optimizations but you're still doing two loops?
[lua]
local staffRanks = {
["moderator"] = true,
["vipmoderator"] = true,
["admin"] = true,
["headadmin"] = true,
["superadmin"] = true
}
local getStaff = function()
local ret = {}
for k, v in pairs(player.GetAll()) do
if(staffRanks[v:GetUserGroup()]) then
ret[#ret + 1] = v
end
end
return ret
end
[/lua]
arguably, this could be made better by not making a table every call and maybe using a for i loop
plus op wanted a way to get the number of staff on, he may not even need the players
[editline]3rd December 2015[/editline]
[QUOTE=keeperman;49238228]How am I supposed to add " to a table?
Like table.insert( thing, "["b"]" )[/QUOTE]
either escape the inner quotes ("[\"b\"]") or use single quotes ('["b"]')
[QUOTE=PortalGod;49238258]bad, you're doing all these micro-optimizations but you're still doing two loops?
[/QUOTE]
It's actually faster to do a for loop and not create a new table. Though in the end the biggest performance hit in all those functions is player.GetAll
[code]
Stoned 0.00099999998928979
PortalGod 0.027000000001863
[/code]
Using this benchmark: [url]https://gist.github.com/aStonedPenguin/10e5765a2cc393628fdf[/url]
[QUOTE=Leyserr;49238044]Thanks man.
But now staffOn is indefinitely incrementing, is there a way to stop this?[/QUOTE]
Ah yes. Keep local staffOn but remove the = 0, then just put: staffOn = 0 before the for loop. (That's if you're still using your code of course)
thanks for the unexplained ratings
[QUOTE=StonedPenguin;49239549]It's actually faster to do a for loop and not create a new table. Though in the end the biggest performance hit in all those functions is player.GetAll
[code]
Stoned 0.00099999998928979
PortalGod 0.027000000001863
[/code]
Using this benchmark: [url]https://gist.github.com/aStonedPenguin/10e5765a2cc393628fdf[/url][/QUOTE]
I don't know why this was disagreed with; if you don't believe it, test it yourself. Lua handles plain iterator loops very down to the metal to the point where the speed is negligible by comparison. Stoned's code is faster in this case.
Would os.date("%a") return different abbreviated names depending on os language? Like, if someone was French, it'd return a different string to English
My script stops after the timer and won't continue on
[QUOTE=keeperman;49244434]My script stops after the timer and won't continue on[/QUOTE]
Do you know we can do nothing with that information, do you?
[QUOTE=geferon;49245013]Do you know we can do nothing with that information, do you?[/QUOTE]
[CODE] chat.AddText( "Test" )
OKButton:SetDisabled( true )
timer.Create( "Countdown", 1, NumSlider:GetValue(), function() NumSlider:SetValue( math.Round( NumSlider:GetValue() ) - 1 ) chat.AddText( "" .. NumSlider:GetValue() ) end)
chat.AddText( "Test 2" )
if not timer.Exists( "Countdown" ) then
chat.AddText( "Timer is done" )
OKButton:SetDisabled( false )
end [/CODE]
[CODE]
resource.AddFile("materials/models/rex/tex_0017_0 (2).vmt")
[/CODE]
Anybody knows why this file can't be downloaded? Is it because of the space?
Is there any hook to enable rendering of players which are spectated via OBS_MODE_IN_EYE?
I'm working on a thirdperson thing for my gamemode, and GM:ShouldDrawLocalPlayer() doesn't seem to work on other player entities.
Hey there, anyone remember that old astar pathfinding module? I want to create some sort of NPC movement system with it.
(code for it is here: [url]http://pastebin.com/UEYSM8GH[/url])
However, due to it's complexity, I don't really understand what I would need to do to find suitable vectors with it. Any tips?
[QUOTE=P4sca1;49248415][CODE]
resource.AddFile("materials/models/rex/tex_0017_0 (2).vmt")
[/CODE]
Anybody knows why this file can't be downloaded? Is it because of the space?[/QUOTE]
Maybe the name, otherwise, it would be your sv_downloadurl.
[editline]5th December 2015[/editline]
[QUOTE=ThreeDog;49248445]Is there any hook to enable rendering of players which are spectated via OBS_MODE_IN_EYE?
I'm working on a thirdperson thing for my gamemode, and GM:ShouldDrawLocalPlayer() doesn't seem to work on other player entities.[/QUOTE]
Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/CreateRagdoll]Player:CreateRagdoll[/url] and parent it to the player.
[editline]5th December 2015[/editline]
Does anyone know a way to get if the current viewmodel activity has finished playing? I know Source has ViewModel.IsSequenceFinished, but it isn't available in GMod.
does anybody know what [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/IsLineOfSightClear]Entity:IsLineOfSightClear[/url] checks for exactly? like, does it check if entity A's origin can see any part of entity B? if any of entity A can see any part of entity B? or just if entity's A origin can see B's origin?
i'm also wondering this about [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/Visible]Entity:Visible[/url]
[QUOTE=mitterdoo;49250116]does anybody know what [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/IsLineOfSightClear]Entity:IsLineOfSightClear[/url] checks for exactly? like, does it check if entity A's origin can see any part of entity B? if any of entity A can see any part of entity B? or just if entity's A origin can see B's origin?
i'm also wondering this about [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/Visible]Entity:Visible[/url][/QUOTE]
[url]https://facepunch.com/showthread.php?t=1411111&p=46704151&viewfull=1#post46704151[/url]
Is thee a way to override npc_grenade_bugbait's Impact effect without redoing the whole entity?
Does anybody know how to disable the text when you look at a player? (Showing the name and the health)
[QUOTE=P4sca1;49251167]Does anybody know how to disable the text when you look at a player? (Showing the name and the health)[/QUOTE]
Simply override HUDPaint, Garry's base code calls a function that handles all of that
[QUOTE=P4sca1;49251167]Does anybody know how to disable the text when you look at a player? (Showing the name and the health)[/QUOTE]
[CODE]function GM:HUDDrawTargetID()
local tr = util.GetPlayerTrace(LocalPlayer())
local trace = util.TraceLine(tr)
if (!trace.Hit) then return end
if (!trace.HitNonWorld) then return end
if (!trace.Entity:IsPlayer()) then return end
-- your code here. Either you can remove all this shit inside and just have no overlay, or you can code it for certain entities. This is for players.
end[/CODE]
[CODE]
hook.Add("HUDDrawTargetID", "NoTargetID", function() return end)
[/CODE]
I tried this, but it is not working.
[CODE]
function GM:HUDDrawTargetID()
end
[/CODE]
GM is a nil value.
This function does not seem to work properly. When you buy the knife it prints ''nono''. Does anyone know why?
[lua]
function boughtweap(ply,equipment,is_item)
if equipment == weapon_ttt_knife then
ply:SetNWInt("SKR_knifebought",1)
print("Yus")
else
print("Nono")
end
end
hook.Add("TTTOrderedEquipment","boughtweap",boughtweap)
[/lua]
[QUOTE=P4sca1;49252192][CODE]
hook.Add("HUDDrawTargetID", "NoTargetID", function() return end)
[/CODE]
I tried this, but it is not working.
[CODE]
function GM:HUDDrawTargetID()
end
[/CODE]
GM is a nil value.[/QUOTE]
Try GAMEMODE instead. If not, you need to put the code in the gamemode folder.
[editline]6th December 2015[/editline]
[QUOTE=Skere_;49254879]This function does not seem to work properly. When you buy the knife it prints ''nono''. Does anyone know why?
[lua]
function boughtweap(ply,equipment,is_item)
if equipment == weapon_ttt_knife then
ply:SetNWInt("SKR_knifebought",1)
print("Yus")
else
print("Nono")
end
end
hook.Add("TTTOrderedEquipment","boughtweap",boughtweap)
[/lua][/QUOTE]
weapon_ttt_knife is not a variable. It is the class name of a weapon. Use "weapon_ttt_knife".
[QUOTE=BillyOnWiiU;49254932]Try GAMEMODE instead. If not, you need to put the code in the gamemode folder.
[editline]6th December 2015[/editline]
weapon_ttt_knife is not a variable. It is the class name of a weapon. Use "weapon_ttt_knife".[/QUOTE]
Oh my god I feel like an idiot for that
Thanks!
[QUOTE=NiandraLades;49244072]Would os.date("%a") return different abbreviated names depending on os language? Like, if someone was French, it'd return a different string to English[/QUOTE]
A little late to answer but no its in english
Is there anyway I can send a networked message to a non-player entity?
I'm trying to get a specific number to be shown on the Client when the User presses E.
Edit: Solved.
[IMG]http://i40.tinypic.com/2dwf9g0.jpg[/IMG]
I saw this image for advanced player customization and I am really interested in creating this. My question then becomes, what is the easiest and most efficient way to do this? From what I figure, I would need to make a new player model for each and every combination, which is why I assume nothing like this really exists. Is there any easier way?
[QUOTE=john55223;49256061]
I saw this image for advanced player customization and I am really interested in creating this. My question then becomes, what is the easiest and most efficient way to do this? From what I figure, I would need to make a new player model for each and every combination, which is why I assume nothing like this really exists. Is there any easier way?[/QUOTE]
[URL="https://steamcommunity.com/sharedfiles/filedetails/?id=280384240"]Luckily for you I updated these models and turned them into playermodels as well.[/URL]
and don't talk shit about the crappy preview images, i may be able to compile models but i sure as hell can't pose them.
Sorry, you need to Log In to post a reply to this thread.