• What do you need help with? V3
    6,419 replies, posted
[QUOTE=Darkwater124;38515097][vid]https://dl.dropbox.com/u/18131951/Videos/Gmod%202012-11-19%2020-03-58-42.webmsd.webm[/vid] Is there any way to show the text on both sides? (In one 3d2d if possible, otherwise, how do I flip text?)[/QUOTE] [lua]function _R.Vector:IsInFront( vec, normal ) return ( normal:Dot( ( vec - self ):GetNormalized() ) < 0 ) end[/lua] Check if the clients camera is in front of the plane, if it isn't flip the cam 180 degrees.
[QUOTE=JetBoom;38510207]You want to return ACT_GMOD_DEATH, -1 in GM:CalcMainActivity. Either in a hook or the gamemode. Then you want to use ply:SetPlaybackRate(1) in GM:UpdateAnimation That would be simplest way. You'd probably want to play around with cycles and stuff too depending on what you're using it for.[/QUOTE] CLIENT [lua] hook.Add("UpdateAnimation", "hooktryingtomakeplayerdie64", function( ply, velocity, maxseqgroundspeed ) if ply.dying then ply:SetPlaybackRate( 1 ) end end hook.Add("CalcMainActivity", "hooktryingtomakeplayerdie32", function( ply, velocity ) if ply.dying then return ACT_GMOD_DEATH, -1 end end) [/lua] SERVER [lua]hook.Add("CalcMainActivity", "hooktryingtomakeplayerdie", function( ply, velocity ) if ply.dying then return ACT_GMOD_DEATH, -1 end end)[/lua] Yet it keeps playing the current animation. What am I doing wrong? (Yes I am sending ply.dying to client too)
[QUOTE=Dark Slayre;38482331]Is it just me, or does ShouldCollide not even work with ent:EnableCustomCollisions(true)? Whenever I go near that ent it just instantly shoves me out, or if I get far enough into the ent, it pushes the ent back.[/QUOTE] Anyone have a solution to this?
It's not EnableCustomCollisions... It's [B]SetCustomCollisionCheck[/B]
How hard would it be to convert the old Catmull-Rom camera mod to work with new Gmod? Because no one has, which baffles me, because that was a really useful mod. edit: Just a heads up, I know nothing about LUA and very little about scripting/working with code of any sort. I understand how code operates from dicking around with calculator BASIC in highschool but other than that, I lean only my intuition in these matters. This is the error I'm getting when instead of putting it in the now-useless addons folder, I copied the components of the mod folder into the main gmod folder. The tool appeared in a tab like it normally does in the tools menu to the right, but when I take out the tool/toolgun, I get this error repeatedly in the console, several times in yellow and then once in blue. [CODE][ERROR] lua/weapons/gmod_tool/stools/catmullrom_camera.lua:36: attempt to index field 'Layout' (a nil value) 1. Think - lua/weapons/gmod_tool/stools/catmullrom_camera.lua:36 2. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:183 [/CODE] Any help would be greatly, greatly appreciated.
[QUOTE=Drakehawke;38505242][LUA] function PrintEveryChat(args) for k, v in pairs(player.GetAll() do v:ChatPrint( args ) end end[/LUA][/QUOTE] (player.GetAll()[B])[/B] do Nice job forgetting to add the parenthase, thats why it broke my whole DarkRP configuration :D
How would I run something once when the player is fully spawned into the server?
-snip-
Hi. I'm trying to bring an outdated addon back to life. But apparently the require() function does no longer its job. Here's a solution for it, but it only works on windows: [url]http://facepunch.com/showthread.php?t=1226065[/url] Is there an alternative to require("x.lua")? (And yes I'm completely new to this)
does anyone know of a way to convert an svg to vector tables? or should i just use an image :v i want a scalable ui icon
Is it better to have one hook that runs and checks everything? Or does it really matter how many hooks I have for that one specific thing? Ex: When I join the server I have my money and experience set. Is it better to have the money and experience both set and checked in the same hook or in separate hooks? Or does it really not matter? I prefer file separation for organization, that's why i'm asking.
Having a strange issue with mysqloo. query:onSuccess doesn't seem to return data correctly.. [lua] function PLAYER:GetInitialXP() print("GETTING INITIAL XP") local xp = DB:query( "SELECT xp FROM PlayerData WHERE steam = '" .. self:SteamID() .. "' AND class = " .. self:GetHumanClass() ..";") local ply = self function xp:onSuccess(q, callback) print("QUERY SUCCESS GETINITIALXP") if (callback and callback[1]) then ply:SetNWInt("xp", callback[1][1]) ply:SetNWInt("level", ply:GetLevel()) ply:LoadData() else ply:buildclasses() end end function xp:onError(callback) print("QUERY FAILED GETINITIALXP") print(callback) end xp:start() end function PLAYER:buildclasses() print("BUILDING CLASSES") local ply = self for k, v in pairs(HumanClasses) do local build = DB:query("INSERT INTO IF NOT EXISTS PlayerData VALUES('" .. ply:SteamID() .. "'," .. k .. "," .. 0 .. ",'"..HumanClasses[k].DefaultWeapons.."','"..HumanClasses[k].DefaultTools.."','"..HumanClasses[k].DefaultMelee.."','perkshere'," .. 0 ..");") -- first time ever spawning on this server, create a entry in the db for them, build:start() ply:GetInitialXP() end end [/lua] As you can see here, they infinitely trade off running eachother. When i try to get the information from the SQL, it appears to return that it was a successful query, but it doesn't return the data correctly. What am i doing wrong?
[lua]lua_run MsgN(util.TableToJSON(util.JSONToTable('{"test":[["string", 5]]}'))) > MsgN(util.TableToJSON(util.JSONToTable('{"test":[["string", 5]]}')))... {"test":{"1":{"1":"string","2":5,"3":5}}}[/lua] ?
[QUOTE=brandonj4;38522722]Is it better to have one hook that runs and checks everything? Or does it really matter how many hooks I have for that one specific thing? Ex: When I join the server I have my money and experience set. Is it better to have the money and experience both set and checked in the same hook or in separate hooks? Or does it really not matter? I prefer file separation for organization, that's why i'm asking.[/QUOTE] I prefer calling it directly from the gamemode's function. If it's something simple just put it in the main function like this: [lua]function GM:PlayerInitialSpawn(pl) pl:SetMoney(pl.Money) -- Or however you set your money/exp pl:SetExp(pl.Exp) end[/lua] If it's more complex that that, you can always create localized functions (unless you need to call this from somewhere else). [lua] local function SetMoney(pl) -- Set money here end local function SetExp(pl) -- Set exp here end function GM:PlayerInitialSpawn(pl) SetMoney(pl) SetExp(pl) end[/lua] Or maybe just one function. [lua]local function SetDefaults(pl) -- Set everything here end function GM:PlayerInitialSpawn(pl) SetDefaults(pl) end[/lua] IIRC, hooks run before the actual function, so keep that in mind.
[QUOTE=Dark Slayre;38528187]Hooks run before the actual function, so keep that in mind.[/QUOTE] Yes, I know quite a bit about the lua syntax. I'm making a very complex gamemode that's why i'm asking. [QUOTE]local function SetMoney(pl) -- Set money here end local function SetExp(pl) -- Set exp here end function GM:PlayerInitialSpawn(pl) SetMoney(pl) SetExp(pl) end[/QUOTE] I have separate files that just use hook.Add instead for the individual attributes. Every single attribute goes in the order of: 1. Checking if the directory exists. 2. Checking if the table exists. 3. Send the data.
I am trying to code a custom HUD, but it won't work. Here are the hooks: [lua] hook.Add( "HUDPaint", "PaintOurHud", HUDPaint ); [/lua] [lua] hook.Add("HUDShouldDraw", "HideOurHud", hidehud) [/lua]
[QUOTE=Pon-3;38530059]I am trying to code a custom HUD, but it won't work. Here are the hooks: [lua] hook.Add( "HUDPaint", "PaintOurHud", HUDPaint ); [/lua] [lua] hook.Add("HUDShouldDraw", "HideOurHud", hidehud) [/lua][/QUOTE] How do the functions look?
[QUOTE=Archemyde;38523077]Having a strange issue with mysqloo. query:onSuccess doesn't seem to return data correctly.. [lua] function PLAYER:GetInitialXP() print("GETTING INITIAL XP") local xp = DB:query( "SELECT xp FROM PlayerData WHERE steam = '" .. self:SteamID() .. "' AND class = " .. self:GetHumanClass() ..";") local ply = self function xp:onSuccess(q, callback) print("QUERY SUCCESS GETINITIALXP") if (callback and callback[1]) then ply:SetNWInt("xp", callback[1][1]) ply:SetNWInt("level", ply:GetLevel()) ply:LoadData() else ply:buildclasses() end end function xp:onError(callback) print("QUERY FAILED GETINITIALXP") print(callback) end xp:start() end function PLAYER:buildclasses() print("BUILDING CLASSES") local ply = self for k, v in pairs(HumanClasses) do local build = DB:query("INSERT INTO IF NOT EXISTS PlayerData VALUES('" .. ply:SteamID() .. "'," .. k .. "," .. 0 .. ",'"..HumanClasses[k].DefaultWeapons.."','"..HumanClasses[k].DefaultTools.."','"..HumanClasses[k].DefaultMelee.."','perkshere'," .. 0 ..");") -- first time ever spawning on this server, create a entry in the db for them, build:start() ply:GetInitialXP() end end [/lua] As you can see here, they infinitely trade off running eachother. When i try to get the information from the SQL, it appears to return that it was a successful query, but it doesn't return the data correctly. What am i doing wrong?[/QUOTE] still looking for a solution. Any info would help.
[QUOTE=brandonj4;38522722]Is it better to have one hook that runs and checks everything? Or does it really matter how many hooks I have for that one specific thing? Ex: When I join the server I have my money and experience set. Is it better to have the money and experience both set and checked in the same hook or in separate hooks? Or does it really not matter? I prefer file separation for organization, that's why i'm asking.[/QUOTE] Anyone else care to share their input?
[QUOTE=brandonj4;38530572]Anyone else care to share their input?[/QUOTE] Neater is better. If you want to do several things that are completely different then having several hooks is certainly a good idea. If the things you want to do are related/share some information/require a certain sequence then a single all-encompassing function is probably appropriate.
[QUOTE=Crazy Quebec;38530700]Neater is better. If you want to do several things that are completely different then having several hooks is certainly a good idea. If the things you want to do are related/share some information/require a certain sequence then a single all-encompassing function is probably appropriate.[/QUOTE] Thanks for the feedback, I was thinking of going towards that direction in the end.
[QUOTE=Darkwater124;38530210]How do the functions look?[/QUOTE] There you go: [lua] /*-------------------------------------------------------------------- Start HUD Painting --------------------------------------------------------------------*/ local vars = { font = "TargetID", padding = 10, margin = 35, text_spacing = 2, bar_spacing = 5, bar_height = 16, width = 0.25 }; local colors = { background = { border = Color( 0, 0, 0, 255 ), background = Color( 115, 115, 115, 10 ) }, text = { shadow = Color( 0, 0, 0, 200 ), text = Color( 222, 222, 222, 255 ) }, health_bar = { border = Color( 255, 0, 0, 255 ), background = Color( 255, 0, 0, 75 ), shade = Color( 255, 104, 104, 255 ), fill = Color( 232, 0, 0, 255 ) }, armor_bar = { border = Color( 0, 0, 255, 255 ), background = Color( 0, 47, 255, 75 ), shade = Color( 136, 136, 255, 255 ), fill = Color( 0, 47, 255, 255 ) } }; function HUDPaint( ) client = client or LocalPlayer( ); -- set a shortcut to the client if( !client:Alive( ) ) then return; end -- don't draw if the client is dead local _, th = hud:TextSize( "TEXT", vars.font ); -- get text size( height in this case ) local i = 2; -- shortcut to how many items( bars + text ) we have local width = vars.width * ScrW( ); -- calculate width local bar_width = width - ( vars.padding * i ); -- calculate bar width and element height local height = ( vars.padding * i ) + ( th * i ) + ( vars.text_spacing * i ) + ( vars.bar_height * i ) + vars.bar_spacing; local x = vars.margin; -- get x position of element local y = ScrH( ) - vars.margin - height; -- get y position of element local cx = x + vars.padding; -- get x and y of contents local cy = y + vars.padding; hud:PaintPanel( x, y, width, height, colors.background ); -- paint the background panel local by = th + vars.text_spacing; -- calc text position local text = string.format( "Health: %iHP", client:Health( ) ); -- get health text hud:PaintText( cx, cy, text, vars.font, colors.text ); -- paint health text and health bar hud:PaintBar( cx, cy + by, bar_width, vars.bar_height, colors.health_bar, client:Health( ) / 100 ); by = by + vars.bar_height + vars.bar_spacing; -- increment text position local text = string.format( "Armor: %iSP", client:Armor( ) ); -- get suit text hud:PaintText( cx, cy + by, text, vars.font, colors.text ); -- paint suit text and suit bar hud:PaintBar( cx, cy + by + th + vars.text_spacing, bar_width, vars.bar_height, colors.armor_bar, client:Armor( ) / 100 ); end hook.Add( "HUDPaint", "PaintOurHud", HUDPaint ) function hidehud(name) for k, v in pairs({"CHudHealth", "CHudBattery"})do if name == v then return false end end end hook.Add("HUDShouldDraw", "HideOurHud", hidehud) [/lua]
[QUOTE=Archemyde;38530396]still looking for a solution. Any info would help.[/QUOTE] Define "not correctly"
[QUOTE=Archemyde;38530396]still looking for a solution. Any info would help.[/QUOTE] Guessing you missed the strings try adding this > [lua]class = " .. self:GetHumanClass() ..";") [/lua] to [lua]class = '" .. self:GetHumanClass() .."';") [/lua] See if that works
[QUOTE=BL00DB4TH;38531446]Define "not correctly"[/QUOTE] i've actually fixed the issue. the code was moving forward whether or not the info was received.
Working on updating a chatbox, error I keep getting: [lua] [ERROR] ...s/cauztik's chatbox/lua/cauztik_chatbox/cl_init.lua:59: attempt to index upvalue 'Chatbox' (a nil value) 1. v - ...s/cauztik's chatbox/lua/cauztik_chatbox/cl_init.lua:59 2. oldHookCall - lua/includes/modules/hook.lua:75 3. unknown - ...s/cauztik's chatbox/lua/cauztik_chatbox/cl_init.lua:25 [/lua] [lua] hook.Add("PlayerBindPress", "Cauztik's Chatbox - Open", function(ply, bind, pressed) if string.find(bind, "messagemode2") then Chatbox:Open(true) return true elseif string.find(bind, "messagemode") then Chatbox:Open(false) return true end end) [/lua] Any help would be deeply appreciated, thanks in advance.
[QUOTE=Apozen;38532439]Working on updating a chatbox, error I keep getting: [lua] [ERROR] ...s/cauztik's chatbox/lua/cauztik_chatbox/cl_init.lua:59: attempt to index upvalue 'Chatbox' (a nil value) 1. v - ...s/cauztik's chatbox/lua/cauztik_chatbox/cl_init.lua:59 2. oldHookCall - lua/includes/modules/hook.lua:75 3. unknown - ...s/cauztik's chatbox/lua/cauztik_chatbox/cl_init.lua:25 [/lua] [lua] hook.Add("PlayerBindPress", "Cauztik's Chatbox - Open", function(ply, bind, pressed) if string.find(bind, "messagemode2") then Chatbox:Open(true) return true elseif string.find(bind, "messagemode") then Chatbox:Open(false) return true end end) [/lua] Any help would be deeply appreciated, thanks in advance.[/QUOTE] Your chatbox variable is likely out of the scope of the anonymous function you have attached to the hook. Woah, deja vu.
What would be considered a way of making a team on serverside then sending it to clientside? I don't have specific teams at the start of my gamemode. People are allowed to make their own. I'm just confused about how to access the team clientside when the player makes it serverside with a console command, and since team.SetUp() is a shared function. I would try it with usermessages but I can't access garrysmod at the moment.
Just send a usermessage or net message that calls team.SetUp clientside since shared is just both server and client running the same thing.
[QUOTE=Chessnut;38534687]Just send a usermessage or net message that calls team.SetUp clientside since shared is just both server and client running the same thing.[/QUOTE] Alright that's what I thought. Thanks for the reply!
Sorry, you need to Log In to post a reply to this thread.