I am reposting since my question was somehow skipped.
Okay, so today I've got back to working on my gamemode and when I ran it I noticed that error that wasn't there before the update appeared: -- I CAN'T really put the error here because I removed the function and cleared console, however theres 1 thing that you'll need to help me out:
I can't do:
PrintTable(player.GetByID(1).XPM)
PrintTable(ply.XPM)
Outputs nothing, like the tables were empty, however doing:
PrintTable(FetchData) works flawlessly
Heres the code and as I remember it worked before the update.
[lua]function DB.PlayerCheck(ply)
ply.XPM = {} -- Temp. table
ply.XPM.xp = 0
ply.XPM.fame = 0
ply.XPM.infame = 0
FetchData = sql.Query("SELECT * FROM xpm_players WHERE id = '"..ply:SteamID().."'") -- Get data from the database
if FetchData then -- asign it where it belongs
ply.XPM.xp = FetchData.xp
ply.XPM.fame = FetchData.fame
ply.XPM.infame = FetchData.infame
end
end
hook.Add("PlayerInitialSpawn", "PlayerCheck", DB.PlayerCheck)[/lua]
Also sorry if I made any mistake while writting this post, it's really late
I'm confused as to what you're asking, especially since you can't provide the error anymore
[QUOTE=Banana Lord.;39053796]I'm confused as to what you're asking, especially since you can't provide the error anymore[/QUOTE]
Error was releated to ply.XPM.fame not existing.
And the problem is that ply.XPM is empty even thought I asign stuff from FetchData to it
Anyone know why Ignite only works once on a prop? I didn't think gmod only ignited once in gmod 12 so did they change something?
[QUOTE=tissue902;39056815]Anyone know why Ignite only works once on a prop? I didn't think gmod only ignited once in gmod 12 so did they change something?[/QUOTE]
You have to call Extinguish first
I need someone to check this death sequence code, I get no errors from it but I know something is off... I just cant put my finger on it..
[CODE]function ENT:Die()
local rag = self:CreatePikRagdoll(false);
if (self:IsOnFire()) then
rag:Ignite(math.Rand(8, 10), 0);
end
local clr = self.PikClr;
if (clr == "red") then
rag.cr = 255;
rag.cg = 10;
rag.cb = 10;
elseif (clr == "yellow") then
rag.cr = 255;
rag.cg = 255;
rag.cb = 10;
elseif (clr == "blue") then
rag.cr = 10;
rag.cg = 10;
rag.cb = 255;
elseif (clr == "purple") then
rag.cr = 200;
rag.cg = 10;
rag.cb = 200;
elseif (clr == "white") then
rag.cr = 250;
rag.cg = 250;
rag.cb = 250;
end
self.DrownSound:Stop();
self:EmitSound("pikmin/pikmin_die.wav", 100, math.random(95, 110));
self:Remove();
timer.Simple(math.Rand(1.6, 2.5), //Give it some random-ness, so they don't die in order so much
function(rag)
if (IsValid(rag)) then
local pos = rag:GetPos();
local r = rag.cr;
local g = rag.cg;
local b = rag.cb;
local effectdata = EffectData();
effectdata:SetOrigin(rag:GetPos());
effectdata:SetStart(Vector(r, g, b));
util.Effect("pikmin_pop", effectdata);
local effectdata = EffectData();
effectdata:SetOrigin((rag:GetPos() + Vector(0, 0, 15)));
effectdata:SetStart(Vector((r * .5), (g * .5), (b * .5)));
util.Effect("pikmin_deathsoul", effectdata);
rag:EmitSound(Sound("pikmin/pikmin_pop.wav"), 100, math.random(95, 110));
rag:Remove();
end
end, rag);
end
[/CODE]
[QUOTE=triset;39057059]I need someone to check this death sequence code, I get no errors from it but I know something is off... I just cant put my finger on it..
[CODE]function ENT:Die()
local rag = self:CreatePikRagdoll(false);
if (self:IsOnFire()) then
rag:Ignite(math.Rand(8, 10), 0);
end
local clr = self.PikClr;
if (clr == "red") then
rag.cr = 255;
rag.cg = 10;
rag.cb = 10;
elseif (clr == "yellow") then
rag.cr = 255;
rag.cg = 255;
rag.cb = 10;
elseif (clr == "blue") then
rag.cr = 10;
rag.cg = 10;
rag.cb = 255;
elseif (clr == "purple") then
rag.cr = 200;
rag.cg = 10;
rag.cb = 200;
elseif (clr == "white") then
rag.cr = 250;
rag.cg = 250;
rag.cb = 250;
end
self.DrownSound:Stop();
self:EmitSound("pikmin/pikmin_die.wav", 100, math.random(95, 110));
self:Remove();
timer.Simple(math.Rand(1.6, 2.5), //Give it some random-ness, so they don't die in order so much
function(rag)
if (IsValid(rag)) then
local pos = rag:GetPos();
local r = rag.cr;
local g = rag.cg;
local b = rag.cb;
local effectdata = EffectData();
effectdata:SetOrigin(rag:GetPos());
effectdata:SetStart(Vector(r, g, b));
util.Effect("pikmin_pop", effectdata);
local effectdata = EffectData();
effectdata:SetOrigin((rag:GetPos() + Vector(0, 0, 15)));
effectdata:SetStart(Vector((r * .5), (g * .5), (b * .5)));
util.Effect("pikmin_deathsoul", effectdata);
rag:EmitSound(Sound("pikmin/pikmin_pop.wav"), 100, math.random(95, 110));
rag:Remove();
end
end, rag);
end
[/CODE][/QUOTE]
[code]
timer.Simple(math.Rand(1.6, 2.5), //Give it some random-ness, so they don't die in order so much
function(rag)
...
end, rag);
[/code]
timers don't use arguments like that anymore, remove both rags and the comma after the end
[QUOTE=Drakehawke;39056974]You have to call Extinguish first[/QUOTE]
Is that new to gmod13? I would have assumed that after the duration runs out it would auto extinguish. Well anyways setting a timer up worked. Thanks man.
[QUOTE=tissue902;39057441]Is that new to gmod13? I would have assumed that after the duration runs out it would auto extinguish. Well anyways setting a timer up worked. Thanks man.[/QUOTE]
Not sure, it's probably a bug
[QUOTE=Drakehawke;39053694]I *think* it's like this, although it seems silly to use a string like this and not just a table
[code]
"default"
{
"density" "2000"
"elasticity" "0.25"
"friction" "0.8"
"dampening" "0.0"
"stepleft" "Default.StepLeft"
"stepright" "Default.StepRight"
"bulletimpact" "Default.BulletImpact"
"scraperough" "Default.ScrapeRough"
"scrapesmooth" "Default.ScrapeSmooth"
"impacthard" "Default.ImpactHard"
"impactsoft" "Default.ImpactSoft"
"audioreflectivity" "0.66"
"audiohardnessfactor" "1.0"
"audioroughnessfactor" "1.0"
"scrapeRoughThreshold" "0.5"
"impactHardThreshold" "0.5"
"gamematerial" "C"
"jumpfactor" "1.0"
"maxspeedfactor" "1.0"
"climbable" "0"
}[/code][/QUOTE]
Hm, I tried something like this, but it didn't seem to work at the time. I'll probably tinker with it some more.
[QUOTE=J.R.;38782639]Everybody keeps getting spewed with this error:
[code]
[ERROR] lua/matproxy/player_weapon_color.lua:19: attempt to call method 'GetWeaponColor' (a nil value)
1. bind - lua/matproxy/player_weapon_color.lua:19
2. unknown - lua/includes/modules/matproxy.lua:56
[/code][/QUOTE]
bump, this started happening to me too.
Anyone know of a good derma tutorial. One that shows you how to actually make something like a spawn menu and such. Ive got one created but I'm using DListpanels which are being phased out so Id like to learn how to make legit menus.
Im also trying to get it from looking at sandbox's menu system but its very large and complex. Hard to figure out what everythings doing exactly.
I learned the basics with [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe102.html"]this[/URL]
Need help with this...
I use DarkRP and I'm using ULX chat tags here's the code for the tags.
if SERVER then
hook.Add( "PlayerSay", "Tags", function(ply, text, team)
local rank
if ply:IsSuperAdmin() then
rank = "Superadmin"
elseif ply:IsAdmin() then
rank1 = "Admin"
else
rank2 = "User"
end
umsg.Start("_Tagsay")
umsg.String(text)
umsg.String(rank)
umsg.Entity(ply)
umsg.End()
return false
end)
end
if CLIENT then
usermessage.Hook("_Tagsay", function (um)
local text = um:ReadString()
local rank = um:ReadString() or "User"
local ply = um:ReadEntity()
if !rank or !text or !ply then return end
ChatAdd(rank,text, ply)
end)
function ChatAdd(rank, text, ply)
chat.AddText("",Color(255,125,0),"[",Color(255,0,255),rank1,Color(255,0,255),rank,Color(255,125,0),"]",Color(0,125,25),ply:Nick()..": ",Color(255,255,255),text)
end
end
All the commands from DarkRP are broken when I use it as /ooc /buymoneyprinter ect.
Can someone re-write it for DarkRP?
Also dont tell me to remove return false, it didn't work.
is there a way to do Var = Var .. "something else" shortened? Like in php its $var .= "something". Just makes things alot simpler.
Sorry if this is the wrong thread, but where should I go to learn the basics of Lua?
I have small knowledge of Javascript and Python but I know those aren't going to help.
[QUOTE=Bathtub;39059654]Sorry if this is the wrong thread, but where should I go to learn the basics of Lua?
I have small knowledge of Javascript and Python but I know those aren't going to help.[/QUOTE]
[URL="http://glua.me"]http://glua.me[/URL] - for the old wiki + other useful stuff
New wiki: [URL="http://wiki.garrysmod.com"]http://wiki.garrysmod.com[/URL]
the search function on glua.me is gmod 12 but the luabin is 13
just an fyi
Where did you guys learn lua?
Most people either learn from other people's scripts, or the [url=http://www.lua.org/pil/]PIL[/url].
[code]MsgN(Material("Nature/snowfloor001a"):GetMaterialTexture("$basetexture2"):GetName());[/code]
returns:
[code]attempt to call method 'GetMaterialTexture' (a nil value)[/code]
Does this mean it didn't find the material correctly or what?
How would I make it so with ULX it would auto-promote someone to a certain rank if they are in a steam group? Thanks!
I believe the function has been renamed to GetTexture. Try that instead of GetMaterialTexture.
[QUOTE=thomasfn;39060276]I believe the function has been renamed to GetTexture. Try that instead of GetMaterialTexture.[/QUOTE]
Much appreciated.
Thank you for the responses, I'm gonna start learning LUA some day when im not feeling lazy
[QUOTE=Bathtub;39060657]Thank you for the responses, I'm gonna start learning LUA some day when im not feeling lazy[/QUOTE]
Start now, there's no reason not to. It's a really simple syntax and a very easy to learn scripting language. Only hassle is learning Garry's Mod's implementation of lua, what with it's hooks, classes, enums and what have you, which the wiki does a fine job of highlighting.
Start simple, make an addon with a couple of sweps and entities, and really just focus on gameplay mechanics that are new. Move into derma, GUIs and what not, and eventually you'll be on your way to doing well
[QUOTE=MrTheJoker;39060271]How would I make it so with ULX it would auto-promote someone to a certain rank if they are in a steam group? Thanks![/QUOTE]
[lua]
hook.Add("PlayerAuthed", "checkgroup", function(ply)
local id = ply:SteamID64()
http.Fetch("http://steamcommunity.com/gid/<GroupID>/memberslistxml/?xml=1", function(result, size) --Alternatively, use "http://steamcommunity.com/groups/<GroupName>/memberslistxml/?xml=1"
if size > 0 then
for w in string.gmatch(result, "<steamID64>(%d+)</steamID64>") do
if w == id then
ULib.ucl.addUser( ply:SteamID(), {}, {}, "vip" )
end
end
end
end)
end)
[/lua]
Check out [URL="https://partner.steamgames.com/documentation/community_data"]Steam's API documentation[/URL] for more.
Is there any way to calculate lighting serverside? I'm trying to make it so that a player takes damage whenever exposed to a certain amount of light, and I was going to use render.ComputeLighting, but that's only clientside.
[editline]1st January 2013[/editline]
Worst comes to worst, I could use a position threshold, but I would really rather it use the lighting.
[QUOTE=shadowndacorner;39061427]Is there any way to calculate lighting serverside? I'm trying to make it so that a player takes damage whenever exposed to a certain amount of light, and I was going to use render.ComputeLighting, but that's only clientside.
[editline]1st January 2013[/editline]
Worst comes to worst, I could use a position threshold, but I would really rather it use the lighting.[/QUOTE]
Why not use render.ComputeLighting and send a message to the server using the net library or simply damage the player in the clientside code if possible?
[QUOTE=TehButter;39061518]Why not use render.ComputeLighting and send a message to the server using the net library or simply damage the player in the clientside code if possible?[/QUOTE]
Thought about that, but I don't like doing anything that would actually affect gameplay on the client because of the potential for manipulation. I know it almost definitely wouldn't happen, but someone smart could mess with it.
[editline]1st January 2013[/editline]
Ended up doing it so that it checks if the skybox is directly above the player. Not perfect, but good enough.
Sorry, you need to Log In to post a reply to this thread.