[QUOTE=Invule;46105949]Hi, I have a small issue with my script that i cant figure out, and i also have a question:
I have a DTextEntry in my frame, then when i press my dbutton it sends the DTextEntry text to the server, and heres my issue, how would i go on about sending the text back to all clients from the server?[/QUOTE]
net.Broadcast?
[QUOTE=AirBlack;46106138]net.Broadcast?[/QUOTE]
Yes, someone is already explaining it to me through steam, he said the exact same thing, thanks anyways. :)
omfg this is probably super simple and embarrassing but I'm using SetPlayerColor and can't seem to get rid of it/make players back to their normal colour-less state
What's the Vector/RGB number for this? I've tried the obvious, but just end up white or black
Try passing a nil value, dunno.
[QUOTE=NiandraLades;46106506]omfg this is probably super simple and embarrassing but I'm using SetPlayerColor and can't seem to get rid of it/make players back to their normal colour-less state
What's the Vector/RGB number for this? I've tried the obvious, but just end up white or black[/QUOTE]
Try with 0 opacity?
[QUOTE=zeaga;46102679]Line 4 is spewing [U]attempt to index local 'ply' (a nil value)[/U]?
[LUA]if SERVER then
hook.Add( "PlayerSpawn", "ShittyHook", function( ply )
local stuff = file.Read( "zeaga/somedata.txt", "DATA" )
if not string.match( stuff, ply:SteamID( ) ) then -- Errors
-- do some shit
end
end )
end[/LUA]
That's the gist of the part of the code that's causing the problem, anyway. It's actually supposed to be hooked to PlayerInitialSpawn but I have it set to PlayerSpawn for debugging purposes.[/QUOTE]
Anyone? I'm completely stumped. I must have stared at the code for 20 minutes straight without any ideas as to why this is happening.
[QUOTE=zeaga;46107254]Anyone? I'm completely stumped. I must have stared at the code for 20 minutes straight without any ideas as to why this is happening.[/QUOTE]
You are either not sending us the full code or you are calling hook.Call() without passing the player as argument somwhere.
Hi there,
I'm working on VCmod and I would want my sprites to show for every player, which isn't the case atm.
Example: Player1 spawns a car and enables left blinker. Player1 will see his blinker but Player2 will not see anything.
I would like them both to see the blinker. Any way of doing that?
[QUOTE=zeaga;46107254]Anyone? I'm completely stumped. I must have stared at the code for 20 minutes straight without any ideas as to why this is happening.[/QUOTE]
I believe you have your if statement setup incorrectly.
string.match() returns anything it matches, so if the "stuff" variable matches ply:SteamID() it returns the value of ply:SteamID() which is a string can't be inverted with the ! (not) operator. For the context of the code I think you should be checking if anything is returned from string.match() as it returns nil if there isn't a match.
[code]
if SERVER then
hook.Add( "PlayerSpawn", "ShittyHook", function( ply )
local stuff = file.Read( "zeaga/somedata.txt", "DATA" )
if string.match( stuff, ply:SteamID( ) ) then
-- code
end
end )
end
[/code]
[QUOTE=VonSpot;46107571]I believe you have your if statement setup incorrectly.
string.match() returns anything it matches, so if the "stuff" variable matches ply:SteamID() it returns the value of ply:SteamID() which is a string can't be inverted with the ! (not) operator. For the context of the code I think you should be checking if anything is returned from string.match() as it returns nil if there isn't a match.
[code]
if SERVER then
hook.Add( "PlayerSpawn", "ShittyHook", function( ply )
local stuff = file.Read( "zeaga/somedata.txt", "DATA" )
if string.match( stuff, ply:SteamID( ) ) then
-- code
end
end )
end
[/code][/QUOTE]
In Lua any value dumped in an if without a comparator will evaluate to true unless it is nil or false, so yes, a "not" should work just fine. It seems that the hook is being called with a nil value. Perhaps check that theory by printing ply beforehand?
[QUOTE=boshadow;46107495]Hi there,
I'm working on VCmod and I would want my sprites to show for every player, which isn't the case atm.
Example: Player1 spawns a car and enables left blinker. Player1 will see his blinker but Player2 will not see anything.
I would like them both to see the blinker. Any way of doing that?[/QUOTE]
You need to network that.
Player starts/stops indicating:
Client->Server using net messages
Server->Clients using another net message, DTBool, or SetNWBool2(next gmod update)
[QUOTE=syl0r;46107403]You are either not sending us the full code or you are calling hook.Call() without passing the player as argument somwhere.[/QUOTE]
That's the entire serverside code, aside from the bit that checks for and creates the 'zeaga' directory and 'somedata.txt' file outside the hook, and the hook itself is the default PlayerSpawn hook running on vanilla Sandbox.
[QUOTE=Internet1001;46107630]In Lua any value dumped in an if without a comparator will evaluate to true unless it is nil or false, so yes, a "not" should work just fine. It seems that the hook is being called with a nil value. Perhaps check that theory by printing ply beforehand?[/QUOTE]
I'll try that, thanks.
[editline]Edited:[/editline]
Odd. Originally ( and somehow I forgot this in my original post like an idiot :/ ) the hook called a function that had already been declared. I changed it to a function inside the hook and it works just fine now.
Still not sure why this is, though.
Edited again: aaaand I added the hook wrong like a dumbass. I had originally put [U]hook.Add( "PlayerSpawn", "Identifier", Identifier( ply ) )[/U]
Sorry for wasting everyone's time!
I have another question, though:
How can I fix comboboxes breaking when their parent panel is a modal? You can open their dropdown menus, but you can't click any of the choices.
[QUOTE=NiandraLades;46106506]omfg this is probably super simple and embarrassing but I'm using SetPlayerColor and can't seem to get rid of it/make players back to their normal colour-less state
What's the Vector/RGB number for this? I've tried the obvious, but just end up white or black[/QUOTE]
Try this? If it doesn't work, then it's cuz Garry and stuff.
[code]
function ChangeColor( col )
ply.normColor = ply.normColor or ply:GetPlayerColor( )
ply:SetPlayerColor( col )
end
function SetNormalColor( ply )
ply:SetPlayerColor( ply.normColor )
end
[/code]
Also, @Internet1001, there is no opacity in SetPlayerColor, it's a Vector with just r,g,b, I think.
[editline]29th September 2014[/editline]
[QUOTE=zeaga;46107681]
I have another question, though:
How can I fix comboboxes breaking when their parent panel is a modal? You can open their dropdown menus, but you can't click any of the choices.[/QUOTE]
Post your code, silly boy.
[QUOTE=AnonTakesOver;46108007]Post your code, silly boy.[/QUOTE]
Thought it was straight forward enough, sorry.
[LUA]
qPanel = vgui.Create( "DFrame" )
qPanel:SetSize( 336, 100 )
qPanel:Center( )
qPanel:SetTitle( "da title" )
qPanel:SetVisible( true )
qPanel:SetDraggable( false )
qPanel:ShowCloseButton( false )
qPanel:DoModal( true )
qPanel:MakePopup( )
qCombo = vgui.Create( "DComboBox", qPanel )
qCombo:SetPos( 20, 36 )
qCombo:SetSize( 70, 20 )
qCombo:SetValue( "<blank>" )
qCombo:AddChoice( "Choice 1" )
qCombo:AddChoice( "Choice B" )
qCombo:AddChoice( "Choice Green" )
function qCombo:OnSelect( i, v, d )
qAnswer = i
end
[/LUA]
There's a lot more to it but, as per usual, that's the gist of what's causing me problems.
[QUOTE=NiandraLades;46106506]omfg this is probably super simple and embarrassing but I'm using SetPlayerColor and can't seem to get rid of it/make players back to their normal colour-less state
What's the Vector/RGB number for this? I've tried the obvious, but just end up white or black[/QUOTE]
Vector( 1, 1, 1 )
Vector( 62.0/255.0, 88.0/255.0, 106.0/255.0 )
([url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/matproxy/player_color.lua[/url] line 33)
is there a way to set the max length of the text in a DTextEntry? I've tried doing
[lua]textentry.OnChange = function(self)
self:SetText(self:GetText():sub(1, length))
end
[/lua]
but that resets the cursor to the start every time it's called
[QUOTE=PortalGod;46108829]is there a way to set the max length of the text in a DTextEntry? I've tried doing
[lua]textentry.OnChange = function(self)
self:SetText(self:GetText():sub(1, length))
end
[/lua]
but that resets the cursor to the start every time it's called[/QUOTE]
Try textentry.OnValueChange
or overwrite [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dtextentry.lua#L344"]this[/URL]
To something like
[code]
textentry.MaxLength = 100
textentry.AllowInput = function( self, strValue )
if ( self:CheckNumeric( strValue ) ) then return true end
if ( self.MaxLength ) then return self.MaxLength > strValue:len() end
end
[/code]
Untested, just going of the GitHub page.
I am assuming strValue returns the text in the textentry
[QUOTE=AnonTakesOver;46108876]Try textentry.OnValueChange
or overwrite [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dtextentry.lua#L344"]this[/URL]
To something like
[code]
textentry.MaxLength = 100
textentry.AllowInput = function( strValue )
if ( self:CheckNumeric( strValue ) ) then return true end
if ( self.MaxLength ) then return self.MaxLength > strValue:len() end
end
[/code]
Untested, just going of the GitHub page.
I am assuming strValue returns the text in the textentry[/QUOTE]
strValue is whatever's attempting to be added, but I got it to work with this
[lua]
textentry.AllowInput = function(self, str)
return #self:GetText() > length
end
[/lua]
for some reason, returning false lets it through, and returning true stops it
thanks though!
[QUOTE=PortalGod;46108917]strValue is whatever's attempting to be added, but I got it to work with this
[lua]
textentry.AllowInput = function(self, str)
return #self:GetText() > length
end
[/lua]
for some reason, returning false lets it through, and returning true stops it
thanks though![/QUOTE]
We all learnt something today!
Yeah, strValue being the attempted text does make more sense now that I read the code.
[QUOTE=MDave;46108434]Vector( 62.0/255.0, 88.0/255.0, 106.0/255.0 )
([url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/matproxy/player_color.lua[/url] line 33)[/QUOTE]
wops. i just looked at the wiki. mb
[del]Three[/del] One question.
[del]What was that function to check if an entity is in water? (In this case a player but later for custom entity)[/del]
[del]What or How do hammer units translate in game? For example I need to check if an entity is within 255 hammer units of another entity.[/del]
[B]EDIT[/B]
Figured it out myself, kinda. But I have an issue where I'm getting output no matter my distance from the entity.
[code]
local function test()
for k, v in pairs( ents.GetAll(func_fish_pool) ) do
if(v:GetPos():Distance(ply:GetPos()) < 255) then --If the player is within 255 units of v
print("It works!")
end
end
end
test()
[/code]
What is "models/Junkola.mdl" and why won't it work properly according to the [URL="https://developer.valvesoftware.com/wiki/Func_fish_pool"]developer wiki[/URL]?
[QUOTE=BlackMadd;46109532]Three questions.
What was that function to check if an entity is in water? (In this case a player but later for custom entity)
What or How do hammer units translate in game? For example I need to check if an entity is within 255 hammer units of another entity.
What is "models/Junkola.mdl" and why won't it work properly according to the [URL="https://developer.valvesoftware.com/wiki/Func_fish_pool"]developer wiki[/URL]?[/QUOTE]
1. [url]http://wiki.garrysmod.com/page/Entity/WaterLevel[/url]
2. google.
3.
Note: The default model, models/Junkola.mdl, won't work properly. Use one of the following models instead.
Because its broken, simple as that.
[QUOTE=zerothefallen;46109593]Because its broken, simple as that.[/QUOTE]
But why is it broken ;3; I'm to damn curious as to why it hasn't been fixed, and if I can fix it myself.
Simple question, since it doesn't seem to be answered on either wiki, Maurits or GMOD Wiki. I have a fairly good idea, but I don't know of conditions, where to use what, etc.
I wanted to spawn an NPC where it would ignore enemies.
How do I use, and what are the exact effects of, these functions?
NPC:UseActBusyBehavior()
NPC:UseAssaultBehavior()
NPC:UseFollowBehavior()
NPC:UseFuncTankBehavior()
NPC:UseLeadBehavior()
NPC:UseNoBehavior()
Also, these would work for game NPC's such as npc_combine_s, npc_headcrab, npc_antlion, etc. right?
I know this question likely sounds [IMG]http://www.facepunch.com/fp/ratings/box.png[/IMG] but I'm simply curious as to how I would expect each function to make an NPC in open space act, and if it would work on built in NPC's.
[editline]Automerge? Yes? No?[/editline]
Like, I don't know the difference between act busy and no behavior? What would func tank behavior do if the NPC is not on a turret? What is follow behavior without a target to follow? Also of course, do these functions work on default NPC's like headcrabs, soldiers, etc, etc, etc.?
OR simple enough, is there an easy(er) way to make NPC's ignore their enemies without disabling AI for all other NPC's?
[QUOTE=Willox;46106094]You'll probably get limited by a few things (on Windows at least) at 260 characters total path length. Each file/dir name shouldn't be greater than 255 characters either.
why?[/QUOTE]
It seems that around somewhere between 20 - 30 characters or so it refuses to be read by Lua, but I couldn't be arsed to map change that many times just to test this out
worlds most noob question ever
why won't
[code]string.Replace(ent.Model,".mdl",".png")[/code]
work? ent.Model [i]should[/i] be returning a model path as a string ("models/props_lab/reciever01b.mdl", etc) - i know it's probably a horrible way of doing this, but why won't that work? only error i get is :
[code][ERROR] lua/includes/extensions/string.lua:190: attempt to index local 'str' (a nil value)[/code] i mean im not a total tard, i guess it isn't getting a string or something along those lines but i dont really get why
i don't think i should try fixing gamemodes that were already shitty in gm12 while i still suck at lua
ent.Model is a nil value
Check that it's being set correctly
[QUOTE=Internet1001;46114592]ent.Model is a nil value
Check that it's being set correct[/QUOTE]
it's set in another file, in another folder with
[code]ENT.Model = "models/props_lab/reciever01b.mdl"[/code]
i'm not 100% on gamemode structure but im fairly sure it works as stuff like the names are all coming through fine ie
[code]ENT.PrintName = "Dispenser"[/code]
+
[code]nicename = ent.PrintName or ent.ClassName,[/code]
but the model path just don't seem to be coming through I guess
Show us where ent is defined
Sorry, you need to Log In to post a reply to this thread.