Not sure why this wont work, but basically im getting this error:
[lua]
bad key to string index (number expected, got string)
[/lua]
When I try to do:
[lua]
function OnPlayerConnected( ply )
MsgC( Color( 205, 50, 0 ), ply, ply:SteamID(), " connected" )
end
hook.Add( "PlayerConnect", "PlayerConnectLog", OnPlayerConnected )
[/lua]
Whenever i remove the ply:SteamID() it works perfectly, lol, i dont understand what im doing wrong, probs being dumb :(
[QUOTE=Invule;46887851]Not sure why this wont work, but basically im getting this error:
bad key to string index (number expected, got string)
When I try to do:
function OnPlayerConnected( ply ) MsgC( Color( 205, 50, 0 ), ply, ply:SteamID(), " connected" )endhook.Add( "PlayerConnect", "PlayerConnectLog", OnPlayerConnected )
Whenever i remove the ply:SteamID() it works perfectly, lol, i dont understand what im doing wrong, probs being dumb :([/QUOTE]
[URL]http://wiki.garrysmod.com/page/GM/PlayerConnect[/URL] that hook passes two arguments both strings and not the player. You can't get the steamid of a string. :/
Sometimes, player.GetAll() returns nil, messing up my timer. Anyone else getting that problem?
I'm new to lua, and this problem is pissing me off so much because it's probably something simple and easy to fix, yet I can't figure out what I'm doing wrong. I keep getting the '=' expected near (shit it doesn't belong next to like "end" or "else"). Example:
[CODE]function pre_round()
sstate = 2
timer.Create( "pre_round", 5, 1, round_start )
local function round_start()
round
end
end[/CODE]
Throws an error saying it's expecting a '=' near the first end. What the fuck is this error trying but failing to explain to me?
You're creating a function after you're referencing it in a timer. Code is very literal.. Typically code execution runs line by line, when a function is encountered that function is ran line by line before coming back to the original function / code which was executing.
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/includes/file_only_works_on_autorefresh_possible_reasons.lua.html[/url]
You can change the code to have the function defined before the timer is called, or you can integrate the function into the timer ( because creating a function returns a reference ).
Additionally, you're not doing anything with "round" which is causing the error because it either expects it to be a function, ()s required, a variable, = x required, etc... It doesn't know what to make of it.
Examples of both:
[code]// We can create this function inside of pre_round but it is a local function so depending on what the function
// purpose is and how it is to be created helps us determine if it is necessary to create it inside the function
// or in the file...
local function round_start()
// round -- Invalid call, round by itself won't do anything... Are you trying to call a function? Add ()s, Are you changing the value of a variable? Add = x; ...
end
function pre_round()
sstate = 2
timer.Create( "pre_round", 5, 1, round_start )
end[/code]
[code]function pre_round()
sstate = 2
timer.Create( "pre_round", 5, 1, function round_start()
// round -- Invalid call, round by itself won't do anything... Are you trying to call a function? Add ()s, Are you changing the value of a variable? Add = x; ...
end )
end[/code]
Even though this isn't a problem and is a question I think I'd be better here then a whole new thread..
What's the reason quite a few people say try and avoid using Player:SendLua()
[QUOTE=Acecool;46889419]You're creating a function after you're referencing it in a timer. Code is very literal.. Typically code execution runs line by line, when a function is encountered that function is ran line by line before coming back to the original function / code which was executing.
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/includes/file_only_works_on_autorefresh_possible_reasons.lua.html[/url]
You can change the code to have the function defined before the timer is called, or you can integrate the function into the timer ( because creating a function returns a reference ).
Additionally, you're not doing anything with "round" which is causing the error because it either expects it to be a function, ()s required, a variable, = x required, etc... It doesn't know what to make of it.
Examples of both:
[code]// We can create this function inside of pre_round but it is a local function so depending on what the function
// purpose is and how it is to be created helps us determine if it is necessary to create it inside the function
// or in the file...
local function round_start()
// round -- Invalid call, round by itself won't do anything... Are you trying to call a function? Add ()s, Are you changing the value of a variable? Add = x; ...
end
function pre_round()
sstate = 2
timer.Create( "pre_round", 5, 1, round_start )
end[/code]
[code]function pre_round()
sstate = 2
timer.Create( "pre_round", 5, 1, function round_start()
// round -- Invalid call, round by itself won't do anything... Are you trying to call a function? Add ()s, Are you changing the value of a variable? Add = x; ...
end )
end[/code][/QUOTE]
"Round" is supposed to be calling a function. I was using that local function to set a few variables and call that function, and I had removed them to see if they might have been the problem. I never realized calling functions required the () even if I'm not adding an argument. Adding () solved everything. Thanks for explaining why it throws that error.
[QUOTE=keensta;46889453]Even though this isn't a problem and is a question I think I'd be better here then a whole new thread..
What's the reason quite a few people say try and avoid using Player:SendLua()[/QUOTE]
Its generally bad practice you should instead AddCSLua your files or use the net libary. From memory I think it uses user messages and they are deprecated
[QUOTE=ZombieWizzard;46889480]Its generally bad practice you should instead AddCSLua your files or use the net libary. From memory I think it uses user messages and they are deprecated[/QUOTE]
It's better to send scripts tp clients through Lua cache before they connect since the cache is compressed.
SendLua also can create server exploits if used incorrectly. For example:
[CODE]
for k,v in pairs(player.GetAll()) do
v:SendLua("MsgN('Your name is: "..v:Name().." ')")
end
[/CODE]
If a player has a script in their name, the script will be executed on the client. There was a bug that had been found in a CoderHire addon where a player could execute code on every client connected on the server that way.
Is there any way to spawn brush entities in Lua? Even something as simple as making a box between two vectors? I've done all the searching I can but haven't found anything.
[QUOTE=TwoYearLurker;46891575]Is there any way to spawn brush entities in Lua? Even something as simple as making a box between two vectors? I've done all the searching I can but haven't found anything.[/QUOTE]
what brush entities are you trying to spawn? you can spawn scripted entities the normal way, and you can spawn triggers, but I don't know about anything else
I've been able to spawn func_brush via Lua but it involved re-spawning a func_tracktrain that existed in the map as func_brush. Try it!
No, see, what I'd like to be able to do is spawn any brush entity (it could be a func_physbox, it could just be a scripted entity made for testing that ignites things inside it) at any arbitrary location by defining the corners with a STool or something. Is there any way to spawn a brush entity that [I]doesn't[/I] involve copying another brush that already exists on the map?
[lua]
entity:SetKeyValue("mins", "-16 -16 -16")
entity:SetKeyValue("maxs", "16 16 16")
[/lua]
I think that was how it used to work, but like I said, I've only ever had it work for triggers
[QUOTE=TwoYearLurker;46891780]No, see, what I'd like to be able to do is spawn any brush entity (it could be a func_physbox, it could just be a scripted entity made for testing that ignites things inside it) at any arbitrary location by defining the corners with a STool or something. Is there any way to spawn a brush entity that [I]doesn't[/I] involve copying another brush that already exists on the map?[/QUOTE]
why does it have to be a brush?
I'm looking to use video chat in a gamemode.
I'm thinking either finding a C++ module like [URL="https://developers.google.com/talk/libjingle/index"]libjingle[/URL], or using an HTTP panel to display a web-based video chat client like [URL="http://tinychat.com/"]tinychat[/URL].
The gamemode is going to be an in-game adaptation of [URL="http://www.indieboardsandcards.com/resistance.php"]The Resistance[/URL]. Because table talk is so important in the board game, I can't settle for voice chat.
Two questions: Does the HTML panel in gmod support flash player? Would it be easier to implement and distribute a C++ module with the gamemode?
Hey are there any guides on making derma skins? I'm working on a custom gamemode and god default derma is ugly.
How would one use PostProccess effects for Overlays? Im trying to get the RED ruber effect on screen..
[B]Edit:[/B]
[QUOTE=Pazda;46895804]Hey are there any guides on making derma skins? I'm working on a custom gamemode and god default derma is ugly.[/QUOTE]
Use the Paint() function
[QUOTE=CASAVANT;46896467]I'm not sure what's wrong here. I get an error and the jobs wont show up...[/QUOTE]
Variables can't contain spaces.
Good:
[code]TEAM_US_1[/code]
Bad:
[code]TEAM_US 1[/code]
[editline].[/editline]
Sorry if this is a bad place to put this, but does anyone know of some good admin addons besides Ulysses that are up-to-date? I've been looking for some but everything I find is outdated. I want to play around with other admin addons.
[QUOTE=zeaga;46896494]Variables can't contain spaces.
Good:
[code]TEAM_US_1[/code]
Bad:
[code]TEAM_US 1[/code]
[editline].[/editline]
Sorry if this is a bad place to put this, but does anyone know of some good admin addons besides Ulysses that are up-to-date? I've been looking for some but everything I find is outdated. I want to play around with other admin addons.[/QUOTE]
Ah ok. Thanks!
[editline]10th January 2015[/editline]
My friends dont know what they are doing... Im getting a slightly different error now...
Error: [CODE][ERROR] addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:16: '=' expected near '-'
1. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:0
[/CODE]
[CODE]/*---------------------------------------------------------------------------
DarkRP custom jobs
---------------------------------------------------------------------------
This file contains your custom jobs.
This file should also contain jobs from DarkRP that you edited.
Note: If you want to edit a default DarkRP job, first disable it in darkrp_config/disabled_defaults.lua
Once you've done that, copy and paste the job to this file and edit it.
The default jobs can be found here:
https://github.com/FPtje/DarkRP/blob/master/gamemode/config/jobrelated.lua
For examples and explanation please visit this wiki page:
http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields
Add jobs under the following line:
---------------------------------------------------------------------------*/
Spetsnaz-Private ss_1
//Created using DeaDeye's Classmaker
TEAM_SS_1 = AddExtraTeam("Spetsnaz-Private", Color(255, 0, 0, 255), "models/player/mw2guy/rus/soldier_e.mdl", [[You gotta start somewhere...F*$&ing grunts....]], {"fas2_ots33","fas2_dv2"}, "ss_1", 100, 40, 0, false, true, {Citizen})
Spetsnaz-Medic ss_2
//Created using DeaDeye's Classmaker
TEAM_SS_2 = AddExtraTeam("Spetsnaz-Medic", Color(255, 0, 0, 255), "models/player/cod players/opfor5.mdl", [[Keep your comrades in the battle!]], {"fas2_ak47","fas2_ots33","fas2_ifak","fas2_dv2"}, "ss_2", 16, 50, 0, false, true, {Spetsnaz-Private})
Spetsnaz-Breacher ss_3
//Created using DeaDeye's Classmaker
TEAM_SS_3 = AddExtraTeam("Spetsnaz-Breacher", Color(255, 0, 0, 255), "models/player/mw2guy/riot/riot_ru.mdl", [[Knock the enemies walls down with your communistfist!]], {"weapon_real_spas","fas2_dv2"}, "ss_3", 8, 50, 0, false, true, {Spetsnaz-Private})
Spetsnaz-Recon ss_4
//Created using DeaDeye's Classmaker
TEAM_SS_4 = AddExtraTeam("Spetsnaz-Recon", Color(255, 0, 0, 255), "models/player/mw2guy/diver/diver_02.mdl", [[Stay low, Stay hidden...]], {"fas2_sr25","fas2_machete","fas2_p226"}, "ss_4", 8, 50, 0, false, true, {Spetsnaz-Private})
Spetsnaz-CQC ss_5
//Created using DeaDeye's Classmaker
TEAM_SS_5 = AddExtraTeam("Spetsnaz-CQC", Color(255, 0, 0, 255), "models/player/mw2guy/rus/soldier_a.mdl", [[Close Quarter Combat]], {"fas2_m3s90","fas2_pp19","fas2_dv2","fas2_m67"}, "ss_5", 16, 50, 0, false, true, {Spetsnaz-Private})
Spetsnaz-Assault ss_6
//Created using DeaDeye's Classmaker
TEAM_SS_6 = AddExtraTeam("Spetsnaz-Assault", Color(255, 0, 0, 255), "models/player/btb5.mdl", [[Shoot fear into the enemy with communist bullets!]], {"fas2_galil","fas2_p226","fas2_m67","fas2_dv2","fas2_ammobox"}, "ss_6", 16, 50, 0, false, true, {Spetsnaz-Private})
Spetsnaz-Heavy ss_7
//Created using DeaDeye's Classmaker
TEAM_SS_11 = AddExtraTeam("Spetsnaz-Heavy", Color(255, 0, 0, 255), "models/player/cell04.mdl", [[We need more firepower!!!! That\'s why you\'rehere...]], {"weapon_bianchi","fas2_m79","fas2_ammobox","fas2_deagle","fas2_m67"}, "ss_11", 4, 50, 0, true, true, {Spetsnaz-private})
Spetsnaz-Sergeant ss_8
//Created using DeaDeye's Classmaker
TEAM_SS_8 = AddExtraTeam("Spetsnaz-Sergeant", Color(255, 0, 0, 255), "models/player/cod players/opfor2.mdl", [[Lead your squad through battle with communist mindcontrol!]], {"fas2_mp5sd6","fas2_m1911","fas2_m79","fas2_dv2"}, "ss_8", 8, 70, 0, false, true, {Spetsnaz-Medic,Spetsnaz-Breacher,Spetsnaz-Recon,Spetsnaz-CQC,Spetsnaz-Assault})
Spetsnaz-Captain ss_9
//Created using DeaDeye's Classmaker
TEAM_SS_9 = AddExtraTeam("Spetsnaz-Captain", Color(255, 0, 0, 255), "models/player/cod players/opfor3.mdl", [[Your on your way to the top ranks comrade!]], {"fas2_m14","fas2_deagle","fas2_m67","fas2_machete"}, "ss_9", 4, 90, 0, false, true, {Spetsnaz-Sergeant})
Spetsnaz-Major ss_10
//Created using DeaDeye's Classmaker
TEAM_SS_10 = AddExtraTeam("Spetsnaz-Major", Color(255, 0, 0, 255), "models/player/btb6.mdl", [[Strike fear into your enemy with your prestigiouscommunist fist!]], {"fas2_sr25","fas2_galil","fas2_deagle","fas2_machete","fas2_ifak","fas2_ammobox","fas2_m67"}, "ss_10", 2, 120, 0, true, true, {Spetsnaz-Captain})
Spetsnaz-Marshal ss_11
//Created using DeaDeye's Classmaker
TEAM_SS_11 = AddExtraTeam("Spetsnaz-Marshal", Color(255, 0, 0, 255), "models/player/pmc_5/pmc__01.mdl", [[Command your entire army and lead them to victory!]], {"fas2_sr25","fas2_galil","fas2_m3s90","fas2_ragingbull","fas2_machete","fas2_m79","fas2_m67","fas2_ifak","fas2_ammobox"}, "ss_11", 1, 180, 0, true, true, {Spetsnaz-Major})
//Created using DeaDeye's Classmaker
TEAM_US_1 = AddExtraTeam("US_Recruit", Color(0, 153, 0, 255), "models/player/rusty/natguard/male_09.mdl", [[US rank 1]], {"fas2_p226","fas2_dv2"}, "us 1", 20, 40, 0, false, true, {Citizen})
//Created using DeaDeye's Classmaker
TEAM_US_2 = AddExtraTeam("US_Private", Color(0, 153, 0, 255), "models/player/btb2npc.mdl", [[US private]], {"fas2_p226","fas2_m4a1","fas2_dv2"}, "us 2", 20, 45, 0, false, true, {US_Recruit})
//Created using DeaDeye's Classmaker
TEAM_US_3 = AddExtraTeam("Private_1st_Class", Color(0, 153, 0, 255), "models/player/btb2npc.mdl", [[US Private 1st class]], {"fas2_p226","fas2_m4a1","fas2_dv2"}, "us 3", 20, 50, 0, false, true, {US_Private})
//Created using DeaDeye's Classmaker
TEAM_US_4 = AddExtraTeam("US_Specialist", Color(0, 153, 0, 255), "models/player/codmw2/codmw2.mdl", [[US Specialist has a bit of a kick!]], {"fas2_p226","fas2_m67","fas2_dv2","weapon_real_spas"}, "us 4", 20, 55, 0, false, true, {US_Private_1st_Class})
//Created using DeaDeye's Classmaker
TEAM_US_5 = AddExtraTeam("US_Corporal", Color(0, 153, 0, 255), "models/player/codmw2/codmw2h.mdl", [[US corporal, Working your way up the ranks is
niiiiice.]], {"fas2_p226","fas2_m4a1","fas2_m67","fas2_dv2"}, "us 5", 20, 60, 0, false, true, {US Specialist})
//Created using DeaDeye's Classmaker
TEAM_US_6 = AddExtraTeam("US_Sergeant", Color(0, 153, 0, 255), "models/player/codmw2/t_codm.mdl", [[Go gettem SARG!!!]], {"fas2_m4a1","fas2_p226","fas2_m67","fas2_dv2"}, "us 6", 20, 65, 0, false, true, {US_Corpral})
//Created using DeaDeye's Classmaker
TEAM_US_7 = AddExtraTeam("US_Medic", Color(0, 153, 0, 255), "models/player/btb4npc.mdl", [[MEEEEEDIC MAN DOWN!! WEE NEED YOU!]], {"fas2_p226","fas2_m4a1","fas2_dv2","fas2_ifak","fas2_m67"}, "us 7", 20, 70, 0, false, false, {US_Sergeant})
//Created using DeaDeye's Classmaker
TEAM_US_8 = AddExtraTeam("US_Staff_Sergeant", Color(0, 153, 0, 255), "models/player/mw2guy/bz/tfbzca01.mdl", [[Next rank of sergeant]], {"fas2_m1911","fas2_m4a1","fas2_m67","fas2_dv2"}, "us 8", 20, 70, 0, false, true, {US_Medic})
//Created using DeaDeye's Classmaker
TEAM_US_9 = AddExtraTeam("US_Sergeant_Major", Color(0, 153, 0, 255), "models/player/mw2guy/bz/tfbz02.mdl", [[Sergeant Major]], {"fas2_m1911","fas2_m4a1","fas2_m67","fas2_dv2","fas2_ammobox"}, "us 9", 20, 75, 0, false, true, {US_Staff_Sergeant})
//Created using DeaDeye's Classmaker
TEAM_US_10 = AddExtraTeam("US_First_Lieutnant", Color(0, 153, 0, 255), "models/player/btb1.mdl", [[1st LT]], {"fas2_m1911","fas2_m4a1","fas2_m67","fas2_dv2"}, "us 10", 20, 80, 0, false, true, {US_Sergeant_Major})
//Created using DeaDeye's Classmaker
TEAM_US_11 = AddExtraTeam("US_Captain", Color(0, 153, 0, 255), "models/player/mw2guy/bz/bzgb01.mdl", [[Capi ton of the US ]], {"fas2_m4a1","fas2_deagle","fas2_m67","fas2_ammobox","fas2_dv2"}, "us 11", 15, 85, 0, false, true, {US_First_Lieutn
Messing around with a weapon for TTT and I've run into a problem. I'm drawing a material onto a monitor that the player holds in their viewmodel. The texture is updated with a rendertarget and everything is happy. Until, I assume, when things like visleafs get involved as shown here:
[vid]http://puu.sh/ekk5J.mp4[/vid]
This is my map where I'm very lazy and havn't put any skip/hint textures or other forms of visleaf creations. The automatic visleafs do hide the player models at some points as you can see when I use mat_wireframe, but not to the rendertarget.
On this map though the player stops being drawn for the rendertarget as well:
[vid]http://puu.sh/ekk6x.mp4[/vid]
Is there a way to prevent this from happening?
If not is there a way to detect that this is happening?(That way I can just put a 'Signal Lost' message rather than a glitchy looking view)
Any other suggestions?
Related question:
Is there any way to force spectators in TTT to see the viewmodel rather than what I assume is the world model? I based the viewmodel on dual elites and manipulated the bones to hold the monitor. When a person spectates they still see the elites.
Hey, so
[code]
local backgroundpanel = vgui.Create("DPanel", frame)
backgroundpanel:SetPos(200, 20)
backgroundpanel:SetSize(580, 560)
[/code]
Works fine, but this is invisible:
[code]
local backgroundpanel = vgui.Create("DScrollPanel", frame)
backgroundpanel:SetPos(200, 20)
backgroundpanel:SetSize(580, 560)
[/code]
Am I using it wrong?
[QUOTE=NiandraLades;46898102]Hey, so
[code]
local backgroundpanel = vgui.Create("DPanel", frame)
backgroundpanel:SetPos(200, 20)
backgroundpanel:SetSize(580, 560)
[/code]
Works fine, but this is invisible:
[code]
local backgroundpanel = vgui.Create("DScrollPanel", frame)
backgroundpanel:SetPos(200, 20)
backgroundpanel:SetSize(580, 560)
[/code]
Am I using it wrong?[/QUOTE]
It looks like your variable is the same as the scroll panel one. I don't know if that's how it supposed to be but if not, that's the problem.
Oh, yeah, that's intentional as it's the same thing - I just want a scrollbar on it instead of just a panel
Have a feeling I'm using it wrong and I know why
[editline]10th January 2015[/editline]
yeah, I was being dumb, sorry!!
[QUOTE=NiandraLades;46898210]Oh, yeah, that's intentional as it's the same thing - I just want a scrollbar on it instead of just a panel
Have a feeling I'm using it wrong and I know why[/QUOTE]
It is invisible because you must parent other panels onto it for it to work.
Here's example from my Lua main menu ( the map icon list )[code]
local Scroll = vgui.Create( "DScrollPanel", self )
Scroll:Dock( FILL )
Scroll:DockMargin( 0, 15, 0, 15 )
function Scroll:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, BackgroundColor )
end
local CategoryMaps = vgui.Create( "DIconLayout", Scroll )
CategoryMaps:SetSpaceX( 5 )
CategoryMaps:SetSpaceY( 5 )
CategoryMaps:Dock( TOP )
CategoryMaps:DockMargin( 5, 5, 5, 5 )[/code]
Is there some easy way of detecting whether or not a sent is touching the ground?
I have tried using both OnGround() and IsOnGround() but they only seem to work for players.
[QUOTE=Cyrill Jones;46898776]Is there some easy way of detecting whether or not a sent is touching the ground?
I have tried using both OnGround() and IsOnGround() but they only seem to work for players.[/QUOTE]
A trace downwards + Entity.OBBMins
[QUOTE=Dgc2002;46897459]Messing around with a weapon for TTT and I've run into a problem. I'm drawing a material onto a monitor that the player holds in their viewmodel. The texture is updated with a rendertarget and everything is happy. Until, I assume, when things like visleafs get involved as shown here:
-snip-
This is my map where I'm very lazy and havn't put any skip/hint textures or other forms of visleaf creations. The automatic visleafs do hide the player models at some points as you can see when I use mat_wireframe, but not to the rendertarget.
On this map though the player stops being drawn for the rendertarget as well:
-snip-
Is there a way to prevent this from happening?
If not is there a way to detect that this is happening?(That way I can just put a 'Signal Lost' message rather than a glitchy looking view)
Any other suggestions?
Related question:
Is there any way to force spectators in TTT to see the viewmodel rather than what I assume is the world model? I based the viewmodel on dual elites and manipulated the bones to hold the monitor. When a person spectates they still see the elites.[/QUOTE]
The portal gun gave me such a huge issue with visleafs. As it is, Lua isn't bound to mess with them much.
Our only way of touching them is PVS functions.
[url]http://wiki.garrysmod.com/page/Global/AddOriginToPVS[/url]
[url]http://wiki.garrysmod.com/page/net/SendPVS[/url]
[url]http://wiki.garrysmod.com/page/CRecipientFilter/AddPVS[/url]
If AddOriginToPVS doesn't work, your best bet of showing a SIGNAL LOST screen is using net.SendPVS to send a message to all clients which are IN the PVS and then broadcasting a message to all players. If the player received the second message and not the first message, they aren't able to see the visleaf.
Sorry, you need to Log In to post a reply to this thread.