[QUOTE=MattJeanes;47322608]That only works from menu state doesn't it? I'm thinking more dedicated server[/QUOTE]
I don't think there's a way to modify addon mounting from serverside/clientside Lua for security reasons. You could always have different workshop collections and change [I]+host_workshop_collection[/I] for each gamemode?
[QUOTE=thefreeman193;47322643]I don't think there's a way to modify addon mounting from serverside/clientside Lua for security reasons. You could always have different workshop collections and change [I]+host_workshop_collection[/I] for each gamemode?[/QUOTE]
Well yeah that's the other way but it's not really dynamic, can't change on-the-fly. Oh well thanks for your help guys.
[QUOTE=Drakehawke;47322566]I've always found the best way to deal with the spawnmenu is to look at the source code and work it out from there. None of the official documentation really supports major modifications to it.[/QUOTE]
Thanks. I was [I]somewhat[/I] sure this was the right approach and you confirmed it. It was still kind of a shitty process tho :S
What's the SWEP function for the recoil kickback effect you get when you fire a gun?
[QUOTE=Maurdekye;47323368]What's the SWEP function for the recoil kickback effect you get when you fire a gun?[/QUOTE]
[url]http://wiki.garrysmod.com/page/Player/ViewPunch[/url]
What property do you set on a crossbow bolt entity (ents.Create("crossbow_bolt")) to change its damage?
I'm trying to make a basic script to weld ALL entities on a map together, but I'm too bad at loops to know how to add 1 (or go forward one valid prop in a loop) to just weld prop 1 to prop 2, prop 2 to prop 3 and so on. Here's the basic loop at the moment.
[CODE]
concommand.Add("weldall",function()
for k, v in pairs(ents.FindByClass("prop_*")) do
if(v:GetPhysicsObject():IsValid()) then
//constraint.Weld( LastEnt, NewEnt, 0, 0, 0 )
end
end
end)
[/CODE]
You could store the previous prop in a variable;
[code]
concommand.Add("weldall",function()
for k, v in pairs(ents.FindByClass("prop_*")) do
if v:GetPhysicsObject():IsValid() then
if IsValid(lastprop) then
constraint.Weld( lastprop, v, 0, 0, 0 )
end
lastprop = v
end
end
end)
[/code]
[QUOTE=Maurdekye;47323493]What property do you set on a crossbow bolt entity (ents.Create("crossbow_bolt")) to change its damage?[/QUOTE]
I am very interested in this as well.
Thanks!
[QUOTE=Maurdekye;47323493]What property do you set on a crossbow bolt entity (ents.Create("crossbow_bolt")) to change its damage?[/QUOTE]
You can't. You should be able to deal the damage in EntityTakeDamage hook or something though.
[QUOTE=Robotboy655;47323550]You can't. You should be able to deal the damage in EntityTakeDamage hook or something though.[/QUOTE]
Can I even put that in a weapon swep?
[editline]14th March 2015[/editline]
I added this code to my swep;
[code]
function entTakeDamage(hit, info)
if info:GetInflictor().is_superxbow_bolt then
info:SetDamage(100)
end
end
hook.Add("EntityTakeDamage", "EntityTakeDamage_supercrossbow", entTakeDamage)
[/code]
and it seems to do the proper amount of damage.
I assign the meta-tag "is_superxbow_bolt" when I spawn the crossbow bolt entity.
[editline]14th March 2015[/editline]
[s]Another problem i'm having is that the bolts don't collide with props.[/s]
Nevermind, they do.
How should I be writing
[CODE]
for k, v in pairs(ents.FindByClass("prop_*") or ents.FindByClass("item_*")) do
[/CODE]
I want a script to search for entities with the classes 'prop' and 'item'.
[editline]15th March 2015[/editline]
I could just do ents.GetAll with an 'if v:GetClass' statement, but since there's a wildcard, I'm not sure it'd work.
[lua]
for k, v in pairs(ents.GetAll()) do
local classname = v:GetClass()
if not (string.StartWith(classname, "prop_") or string.StartWith(clasname, "item_")) then continue end
-- code --
end
[/lua]
[editline]14th March 2015[/editline]
alternatively (since they're both 5 chars):
[lua]
local valid = {["prop_"] = true, ["item_"] = true}
for k, v in pairs(ents.GetAll()) do
if not valid[string.sub(v:GetClass(), 1, 5)] then return end
-- code --
end
[/lua]
I guess it's an extra table creation vs a few extra function calls
Been stuck at this problem for eight hours.
[LUA]
local function AddToggleButton(n,p,t,bp,bv,bw,x,y)
local n = vgui.Create( "Button" )
n:SetParent( p )
n:SetText( t )
n:SetPos( x, y )
n:SetSize( 85, 25 )
n.DoClick = function()
bp[bv][bw] = !bp[bv][bw];
end
function n:Paint(w,i)
if ( self:IsHovered() ) then
surface.SetDrawColor(0,255,255,200)
surface.DrawRect( 0, 0, w, i )
n:SetTextColor(Color(20,20,20,255))
else
if bp[bv][bw] then
n:SetTextColor(Color(0,255,0,255))
else
n:SetTextColor(Color(255,0,0,255))
end
surface.SetDrawColor(35,35,35,200)
surface.DrawRect( 0, 0, w, i)
surface.SetDrawColor(20,20,20,255)
surface.DrawOutlinedRect(0,0,self:GetSize())
end
end
end
[/LUA]
I am completely lost, and have no idea why this doesnt work now. It worked perfectly before the update that was made the 8th of march. would really appretiate it if someone could help me out <3
Since nobody replied, I will post it one more time to see if anyone else has been having the same problems.
Ive been trying to fix my darkrp server after the update (It broke a lot of my addons) and one error I keep getting is "SWEP:SetWeaponHoldType - ActIndex[ "" ] isn't set! (defaulting to normal)" when more than 1 person is on and all of the weapon's models disappear. Does anyone know what is going on?
That reminds me, why do I have to keep using Ply:SendLua for pretty much everything now?
A simple example-
[CODE]
concommand.Add( "sendlua_annoyance", function( ply )
ply:SendLua( [[notification.AddLegacy( "This won't work without sendlua",1,2)]] )
ply:SendLua( [[chat.AddText(Color(255,0,0,255),"This also won't work without sendlua")]] )
end)
[/CODE]
With that button problem ,if it's something to do with 'ATTEMPT TO INDEX VGUI', then you may just have to spam everything with SendLua like I have to.
[QUOTE=color0a;47325056]Been stuck at this problem for eight hours.
[LUA]
local function AddToggleButton(n,p,t,bp,bv,bw,x,y)
local n = vgui.Create( "Button" )
n:SetParent( p )
n:SetText( t )
n:SetPos( x, y )
n:SetSize( 85, 25 )
n.DoClick = function()
bp[bv][bw] = !bp[bv][bw];
end
function n:Paint(w,i)
if ( self:IsHovered() ) then
surface.SetDrawColor(0,255,255,200)
surface.DrawRect( 0, 0, w, i )
n:SetTextColor(Color(20,20,20,255))
else
if bp[bv][bw] then
n:SetTextColor(Color(0,255,0,255))
else
n:SetTextColor(Color(255,0,0,255))
end
surface.SetDrawColor(35,35,35,200)
surface.DrawRect( 0, 0, w, i)
surface.SetDrawColor(20,20,20,255)
surface.DrawOutlinedRect(0,0,self:GetSize())
end
end
end
[/LUA]
I am completely lost, and have no idea why this doesnt work now. It worked perfectly before the update that was made the 8th of march. would really appretiate it if someone could help me out <3[/QUOTE]
SetTextColor got changed, use SetFGColor
I'm probably not including something in that concommand that I need to
[editline]15th March 2015[/editline]
By the way, can anyone help with why I have to do that, or is it just the only way?
[QUOTE=MPan1;47325206]That reminds me, why do I have to keep using Ply:SendLua for pretty much everything now?
A simple example-
[CODE]
concommand.Add( "sendlua_annoyance", function( ply )
ply:SendLua( [[notification.AddLegacy( "This won't work without sendlua",1,2)]] )
ply:SendLua( [[chat.AddText(Color(255,0,0,255),"This also won't work without sendlua")]] )
end)
[/CODE]
With that button problem ,if it's something to do with 'ATTEMPT TO INDEX VGUI', then you may just have to spam everything with SendLua like I have to.[/QUOTE]
Those are clientside functions, you can't run them serverside.
When you use SendLua, it's sending the code to be executed on the client.
Although you may not want to depend on it, you should use net messages instead.
So here's a small issue, but it's not really related to lua...
I viewed a demo recently to handle a ban report and now my build menu width is a bit messed up, and I can't resize it. Am I missing something?
[img]http://i.imgur.com/CqAD0kU.png[/img]
[QUOTE=meowking1;47325190]Since nobody replied, I will post it one more time to see if anyone else has been having the same problems.
Ive been trying to fix my darkrp server after the update (It broke a lot of my addons) and one error I keep getting is "SWEP:SetWeaponHoldType - ActIndex[ "" ] isn't set! (defaulting to normal)" when more than 1 person is on and all of the weapon's models disappear. Does anyone know what is going on?[/QUOTE]
Those two are unrelated. The SetWeaponHoldType is resulting from an old addon which uses that function instead of SetHoldType; the error doesn't do anything. The weapon models disappearing is a known issue and will be fixed in the hotfix.
Is it possible to check whether any entities in ents:GetAll are touching the ground, even if they are props? Apparently there's a script to do this, but I can't guess what it could be, considering hull traces only trace a certain amount of units down. IsOnGround doesn't work for props. Anyone know a script or can think of one?
[QUOTE=WitheredPyre;47325485]So here's a small issue, but it's not really related to lua...
I viewed a demo recently to handle a ban report and now my build menu width is a bit messed up, and I can't resize it. Am I missing something?
[img]http://i.imgur.com/CqAD0kU.png[/img][/QUOTE]
There's a setting in wiremod that does this.
I use a custom font in one of my scripts. It works fine for me but for most of the people using it the font downloads but doesn't work.
The font is located in resources/fonts/fairview-smallcaps.otf and here is the code i use to generate the font:
[LUA]--[[---------------------------------------------------------
Name: Fonts
-----------------------------------------------------------]]
local function CreateHUDFonts( i, font, name, weight )
--> Size
local CurrentFontSize = 12 + i * 2
--> Create
surface.CreateFont( name .. CurrentFontSize, {
font = font,
size = CurrentFontSize,
weight = weight,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
})
end
--[[---------------------------------------------------------
Name: Font Loop
-----------------------------------------------------------]]
for i=1,20 do
--> Crete Fonts
CreateHUDFonts( i, "Fairview-SmallCaps", "TCB_Premium_Fairview_", 100 )
end[/LUA]
And yes it added to the download list:
[LUA]--[[---------------------------------------------------------
Name: Download Fonts
-----------------------------------------------------------]]
resource.AddSingleFile( "resource/fonts/fairview-smallcaps.otf" )[/LUA]
Does any of you know what could cause this issue?
[QUOTE=PortalGod;47325210]SetTextColor got changed, use SetFGColor[/QUOTE]
I fruaqing love you m9ty <3.
Hey guys and girls,
I'm a beginning developer and i'd like to know some things.
1. Can somebody list me of what a beginning developer should do in tasks like
- make the donator slightly regenerate health over time
- create entities
- and other things
so i will know what i shoudn't approach jsut yet due to lack of knowledge/experience.
2. I've came across some things that i'd like to be explained since i can't figure them out on my own.
- for k,v in pairs () <--- it says it Iterates through a table like the example of the wiki
printing all players in the console.
But the things I don't know is, what can you use it for, and why is only v Defined and not k?
[code]
for k, v in pairs( player.GetAll() ) do
print( v:Nick() )
end
[/code]
3. Tables, I know you can create tables using { }
like weapons = {"med_kit", "m9k_damascus", "m9k_deagle"}, for a job.
but like for k,v in pairs is there anything else i can do with tables?
I'd hope i'm not too big of a hassle for you to answer
Hey guys. I'm trying to get mysqloo working with this gamemode, but I can't find a way to make these queries actually...well...query. I know mysqloo is working because I made a function in init.lua that created the required tables and columns, but the gamemode just won't save/load player data. How would I set up mysqloo to query from multiple functions?? I'm new to SQL stuff so I'm trying my hardest.
mysqloo code to connect:
[CODE]include("options.lua")
include("obj_player_extend.lua")
include("admin_shd.lua")
include("admin_sv.lua")
include("commands.lua")
include("dice.lua")
include("options_sv.lua")
include("purchases_shd.lua")
include("purchases_sv.lua")
require ("mysqloo")
local db = mysqloo.connect(MYSQL_DATABASE_HOST, MYSQL_DATABASE_USERNAME, MYSQL_DATABASE_PASSWORD, MYSQL_DATABASE_NAME, MYSQL_DATABASE_PORT)
db:Connect()
function db:onConnected()
print("[CCGM] Database has been connected")
end
[/CODE]
My working mysqloo code. Could only query within 1 function - 1 at a time.
[CODE]function GM:InitPostEntity()
--mysqloo.CLIENT_MULTI_STATEMENTS = 50 -- [Number] 65536 - Allows multiple statements within one query
--mysqloo.CLIENT_MULTI_RESULTS = 50 -- [Number] 131072 - Allows multiple result sets to be returned by the server
--Wouldn't read from the other file, so it's now here...oh well.
--Let it be known Dr. Chat can't fucking code for shit.
local DATABASE_HOST = "192.168.1.100" // database host (can be an ip)
local DATABASE_PORT = 3306 // port to the database, you probably wont need to change this unless you get told to
local DATABASE_NAME = "zombies" // name of the database
local DATABASE_USERNAME = "root" // username which you use to access it
local DATABASE_PASSWORD = "carter" // password of the username
local db = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
function db:onConnected()
print( "Database has connected!" )
end
db:connect()[/CODE]
What I'm trying to get working. All these functions that have sql queries. How to make connection without connecting to server in each function??
[CODE]function GetSQLPid(self)
local q = db.Query("SELECT player_id FROM zs_players WHERE steam_id='"..self:SteamID().."'")
if not q then return end
local pid
for id,row in pairs(q) do
pid = tonumber(row['player_id'])
end
return pid
end
function CCGM_PlayerDisconnected(user)
local q = db:query("SELECT player_id FROM zs_players WHERE steam_id='"..user:SteamID().."'")
if q then
for id,row in pairs(q) do
local pid = tonumber(row['player_id'])
db.onConnected = function()
local q = db:query("UPDATE zs_players SET last_connect='"..os.date("%Y-%m-%d %H:%M:%S").."' WHERE player_id='"..pid.."'")
q:start()
end
end
end
end
hook.Add("PlayerDisconnected", "CCGM Player Disconnect", CCGM_PlayerDisconnected)
function HasLevelInformation(user)
--return file.Exists("ccgm/zombiesurvival/info/"..string.gsub(user:SteamID(),":","_")..".txt")
local query = db:query("SELECT steam_id FROM zs_players WHERE steam_id='"..user:SteamID().."'")
if query then
for id,row in pairs(query) do
if row['steam_id']==user:SteamID() then
return true
end
end
end
return false
end
[/CODE]
I had the query running from onConnected. Is there another way to do this that I'm missing? Help a noob out please.
[QUOTE=ler0ytjee;47327093]Hey guys and girls,
I'm a beginning developer and i'd like to know some things.
1. Can somebody list me of what a beginning developer should do in tasks like
- make the donator slightly regenerate health over time
- create entities
- and other things
so i will know what i shoudn't approach jsut yet due to lack of knowledge/experience.
2. I've came across some things that i'd like to be explained since i can't figure them out on my own.
- for k,v in pairs () <--- it says it Iterates through a table like the example of the wiki
printing all players in the console.
But the things I don't know is, what can you use it for, and why is only v Defined and not k?
[code]
for k, v in pairs( player.GetAll() ) do
print( v:Nick() )
end
[/code]
3. Tables, I know you can create tables using { }
like weapons = {"med_kit", "m9k_damascus", "m9k_deagle"}, for a job.
but like for k,v in pairs is there anything else i can do with tables?
I'd hope i'm not too big of a hassle for you to answer[/QUOTE]
k is the userid i believe or something along those things (just numbers normally ) the for k goes through those numbers one at a time and returns v (the player entity) then in the next line it finds the nick of those players)
hook.Add("PlayerSpawn", "Playerspawn", function(ply)
timer.Simple( 0, function()
for k,v in pairs(weapons) do
ply:Give(v)
end
this will go through every line in weapons (your table) so k=1 v = "med_kit", k=2 v=m9k_damascus and so on
[editline]15th March 2015[/editline]
acecool gave me this a few months ago
[url]https://www.dropbox.com/s/ej64f3wtz2ocgly/quick_intro_to_tables.lua.txt?dl=0[/url]
Is there a way I can ping a server without
1. Being on it
2. SourceQuery because I do not have a webserver I can host it on
Trying to add it to my menu so I can check if one of the server's I'm always on is up or not.
Sorry, you need to Log In to post a reply to this thread.