[QUOTE=LilSumac;47421511]Is there any way to tell if the server has crashed or closed improperly server-side? GM:ShutDown seems to only work when the server is terminated safely, and I'm looking for a way to dump/save data without losing it.[/QUOTE]
Serverside, no. Due to the very nature of a "crash", you can't hook into it happening.
Best you can do is periodically save.
If you want to detect if a server has crashed the next time it starts up, though, you can write a file into DATA on GM:Initialize, delete the file on GM:ShutDown, and check if it exists on each start up. If it does, the server crashed.
Clientside, however, you can occasionally ping the server with a small net message or something to see if it responds. If it doesn't, you're either lagging or the server's crashed. If you don't get a response for more than, say, 60 seconds, you can safely assume the server's crashed, and do something.
Is there a particular problem that stems from having too many hooks on a server? If so, how many would it take to cause this problem? I have no basis for this question, just curious.
[QUOTE=AK to Spray;47423542]Is there a particular problem that stems from having too many hooks on a server? If so, how many would it take to cause this problem? I have no basis for this question, just curious.[/QUOTE]
Apart from the fact that each hook function will be called every time the hook fires if none of them return, there's no particular "gotchas" you need to be careful of.
Just don't attach anything stupidly expensive to hooks that get called a lot, and you should be alright.
Uh, okay so moving menus that start off screen work fine if it's with width but starts at the very top of the screen and moves further down if you use height
Has anyone else experienced this?
Slides in off screen fine:
[code]
frame:SetSize(250, 100)
frame:SetPos(-250, 100)
frame:MoveTo(250, 100, 1, 0, 5)
[/code]
Starts on screen and slides even further down:
[code]
frame:SetSize(250, 100)
frame:SetPos(500, -100)
frame:MoveTo(500, 100, 1, 0, 5)
[/code]
[QUOTE=NiandraLades;47423990]Uh, okay so moving menus that start off screen work fine if it's with width but starts at the very top of the screen and moves further down if you use height
Has anyone else experienced this?
Slides in off screen fine:
[code]
frame:SetSize(250, 100)
frame:SetPos(-250, 100)
frame:MoveTo(250, 100, 1, 0, 5)
[/code]
Starts on screen and slides even further down:
[code]
frame:SetSize(250, 100)
frame:SetPos(500, -100)
frame:MoveTo(500, 100, 1, 0, 5)
[/code][/QUOTE]
Is SetPos clamping the value to 0 at minimum, or is MoveTo immediately snapping the panel to Y position 0 as soon as the animation starts?
(Logically, neither should be happening, but more information is always good.)
I'm trying to use GM:PlayerDeath and chat.AddText so that each time a player dies, it will print something to the chatbox. The problem is, PlayerDeath is serverside and chat.Addtext is clientside. Not sure what to do.
[QUOTE=Sheeplie;47424040]I'm trying to use GM:PlayerDeath and chat.AddText so that each time a player dies, it will print something to the chatbox. The problem is, PlayerDeath is serverside and chat.Addtext is clientside. Not sure what to do.[/QUOTE]
Net library.
[QUOTE=Sheeplie;47424040]I'm trying to use GM:PlayerDeath and chat.AddText so that each time a player dies, it will print something to the chatbox. The problem is, PlayerDeath is serverside and chat.Addtext is clientside. Not sure what to do.[/QUOTE]
use gameevents for no networking need.
[code]
gameevent.Listen("entity_killed")
hook.Add("entity_killed", "PlayerDeath", function(dat)
local killer = Entity(dat.entindex_attacker);
local inflictor = Entity(dat.entindex_inflictor);
local victim = Entity(dat.entindex_killed);
if(IsValid(victim) and IsValid(killer) and
victim:IsPlayer() and killer:IsPlayer()) then
chat.AddText(killer:Nick().." killed "..victim:Nick());
end
end);
[/code]
You could either use net library, or the gameevent for that. I'm not really familiar with game events, though. So heres a solution using the net library.
[url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
Server side;
[lua]util.AddNetworkString "Death Notification"
hook.Add ( "PlayerDeath", "Death Notification",
function ( player, inflictor, attacker )
net.Start "Death Notification"
net.WriteEntity ( player )
net.WriteEntity ( attacker )
net.Broadcast ( )
end
)[/lua]
Client side;
[lua]net.Receive ( "Death Notification",
function ( length, server )
local player = net.ReadEntity ( )
local attacker = net.ReadEntity ( )
chat.AddText ( Color ( 100, 255, 100 ), player, " killed ", attacker )
end
)[/lua]
[QUOTE=NiandraLades;47423990]Uh, okay so moving menus that start off screen work fine if it's with width but starts at the very top of the screen and moves further down if you use height
Has anyone else experienced this?
Slides in off screen fine:
[code]
frame:SetSize(250, 100)
frame:SetPos(-250, 100)
frame:MoveTo(250, 100, 1, 0, 5)
[/code]
Starts on screen and slides even further down:
[code]
frame:SetSize(250, 100)
frame:SetPos(500, -100)
frame:MoveTo(500, 100, 1, 0, 5)
[/code][/QUOTE]
Okay, I've found the problem: DFrame is hard-coded to not go above y0 for.. whatever reason.
You see the code here: [url]https://github.com/garrynewman/garrysmod/blob/4eb9bb19dcfac06007691376ecaf2dbc56efa6b2/garrysmod/lua/vgui/dframe.lua#L198[/url]
If you still reaaaally want a DFrame that can do this, you can try overriding its Think function with a duplicate version of the one hosted on github (ideally with functionality you don't need stripped out).
Or just use a DPanel, and add your own close button.
[QUOTE=Phoenixf129;47424355]Or just use a DPanel, and add your own close button.[/QUOTE]
DPanels don't have the functionality to "capture" Keyboard and Mouse control via MakePopup, which is what I presume the DFrame is being used for.
If you know of a method that *exactly* emulates how MakePopup operates, then that'd be good to know.
She could just use an EditablePanel instead, then.
[QUOTE=Jeezy;47421280]Well... there's not much we can figure out without actually seeing the addon, or being given an idea of what it does and how you do it.[/QUOTE]
Its a TTT weapon. [url=http://pastebin.com/520hnzbq]/lua/autorun/advdisguiser.lua[/url] and [url=http://pastebin.com/9C98QWmh]/lua/weapons/weapon_ttt_advdisguiser.lua[/url]
[QUOTE=James xX;47421441]Which addon is it? I'm asking in case the answer could help someone else.[/QUOTE]
It was an advanced disguiser addon that I don't think is around anymore
I never personally encountered this happening but I have seen the server crash. My friend said this who caused the crash:
2:50 PM - Picks: I was a detective who had killed a traitor who had the disguiser but had not used it yet (or it was broken and didn't show the name).
2:51 PM - Picks: I picked it up with the magneto stick and it turned invisable
2:51 PM - Picks: i dropped it and it started to bounce back and forth alot and it crashed
My server has been crash free for 5 days without the addon enabled, but it was a great addon. Would love to see it back on my server :)
[QUOTE=MeepDarknessM;47424066]use gameevents for no networking need.
[code]
gameevent.Listen("entity_killed")
hook.Add("entity_killed", "PlayerDeath", function(dat)
local killer = Entity(dat.entindex_attacker);
local inflictor = Entity(dat.entindex_inflictor);
local victim = Entity(dat.entindex_killed);
if(IsValid(victim) and IsValid(killer) and
victim:IsPlayer() and killer:IsPlayer()) then
chat.AddText(killer:Nick().." killed "..victim:Nick());
end
end);
[/code][/QUOTE]
One thing: Shouldn't the hook.add look like:
hook.Add( "PlayerDeath", "entity_killed", function(dat) ?
Also, I'm not sure how the Entity(dat.entindex_attacker); works. Does the function give you some kind of return table? As far as I knew the arguments for GM:PlayerDeath were where you got the killer, inflictor, and victim from.
No. PlayerDeath is serverside and you're getting around this by hooking the entity_killed event clientside.
[QUOTE=Phoenixf129;47424882]No. PlayerDeath is serverside and you're getting around this by hooking the entity_killed event clientside.[/QUOTE]
I see, so PlayerDeath in this case is just a unique name.
One more thing, what would happen if you didn't specify the data values as entities?
The data values are numbers indicating the entity's "index". The Entity function call takes this and returns the corresponding entity object.
[url]http://wiki.garrysmod.com/page/Global/Entity[/url]
Not really an issue but lately I've been looking into linux hosting and such, how ssh works etc but let's say I want multiple servers on the same machine, I just create multiple srcds folders and give each one a port between 27010-27019, right, but how would I access each console? I need a webhosted server manager?
[QUOTE=rikyy;47425693]Not really an issue but lately I've been looking into linux hosting and such, how ssh works etc but let's say I want multiple servers on the same machine, I just create multiple srcds folders and give each one a port between 27010-27019, right, but how would I access each console? I need a webhosted server manager?[/QUOTE]
screen
-snip found workaround-
function PANEL:OnMousePressed()
if LocalPlayer():InSafezone() && self.item != "none" then
local menu = DermaMenu( self )
menu:AddOption( "Move to Inventory", function()
AskMoveToInv( self.slot )
self:Clean();
end)
menu:Open();
end
end
I was wondering how i would change this function so it doesn't move the hole stack of items but single and 10's of items if you guys could help me thanks!!
[QUOTE=Crafted;47427127]function PANEL:OnMousePressed()
if LocalPlayer():InSafezone() && self.item != "none" then
local menu = DermaMenu( self )
menu:AddOption( "Move to Inventory", function()
AskMoveToInv( self.slot )
self:Clean();
end)
menu:Open();
end
end
I was wondering how i would change this function so it doesn't move the hole stack of items but single and 10's of items if you guys could help me thanks!![/QUOTE]
Make a split option to be able to split the stacks into singles, 10's, custom, etc and then just have them be a new table value, hopefully this will work.
Ignore this pls
[editline]31st March 2015[/editline]
[QUOTE=LUModder;47427200]Make a split option to be able to split the stacks into singles, 10's, custom, etc and then just have them be a new table value, hopefully this will work.[/QUOTE]
How could i make the code for that new to lua coding
[editline]31st March 2015[/editline]
How could i make the code for that new to lua coding[/QUOTE]
How can I pass more than one entity to an effect?
effectdata:SetEntity() seems like it's a one time thing and I want my effect to interact with two entities.
[QUOTE=Sheeplie;47424746]Also, I'm not sure how the Entity(dat.entindex_attacker); works. Does the function give you some kind of return table? As far as I knew the arguments for GM:PlayerDeath were where you got the killer, inflictor, and victim from.[/QUOTE]
[url=http://wiki.garrysmod.com/page/Game_Events]This[/url] shows us the gameevents that work in gmod lua, from here we can see that entity_killed.entindex_* has an entity index which we can use with [url=http://wiki.garrysmod.com/page/Global/Entity]Entity()[/url] to get the actual entity that died.
Since entity_killed doesn't always mean a player was killed (eg a vehicle explodes from shots in another addon or something) we have to specifically check if the entity is a player.
Hi,
i have some problems with a over-head hud for DarkRP:
[CODE]
ddt("Level: "..ply:getDarkRPVar('level') or "", "SHUDName", x + w / 2, y + 34, SHUD.Config.Color.Jobtext, TEXT_ALIGN_CENTER)
[/CODE]
And it's keep showing the same error:
[CODE]
addons/darkrpmodification/lua/darkrp_modules/shud/cl_shud.lua:138: attempt to concatenate a nil value
Trace:
1: Line 32 "Trace" lua/includes/extensions/debug.lua
2: Line 29 "fn" addons/zones/lua/autorun/sh_hookfix.lua
3: Line 179 "nil" addons/ulib/lua/ulib/shared/hook.lua
[/CODE]
i'm a noob with lua coding, can someone explain me my error?
[QUOTE=RocknRolla513;47430316]Hi,
i have some problems with a over-head hud for DarkRP:
[CODE]
ddt("Level: "..ply:getDarkRPVar('level') or "", "SHUDName", x + w / 2, y + 34, SHUD.Config.Color.Jobtext, TEXT_ALIGN_CENTER)
[/CODE]
And it's keep showing the same error:
[CODE]
addons/darkrpmodification/lua/darkrp_modules/shud/cl_shud.lua:138: attempt to concatenate a nil value
Trace:
1: Line 32 "Trace" lua/includes/extensions/debug.lua
2: Line 29 "fn" addons/zones/lua/autorun/sh_hookfix.lua
3: Line 179 "nil" addons/ulib/lua/ulib/shared/hook.lua
[/CODE]
i'm a noob with lua coding, can someone explain me my error?[/QUOTE]
the darkrp level is nil, and you are trying to concat it.. maybe you meant this?
[code]
ddt("Level: "..(ply:getDarkRPVar('level') or "0"), "SHUDName", x + w / 2, y + 34, SHUD.Config.Color.Jobtext, TEXT_ALIGN_CENTER)
[/code]
[QUOTE=MeepDarknessM;47430325]the darkrp level is nil, and you are trying to concat it.. maybe you meant this?
[code]
ddt("Level: "..(ply:getDarkRPVar('level') or "0"), "SHUDName", x + w / 2, y + 34, SHUD.Config.Color.Jobtext, TEXT_ALIGN_CENTER)
[/code][/QUOTE]
You, sir, just saved my life!
Thanks a lot!
Sorry, you need to Log In to post a reply to this thread.