• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
Is there a function that i can use to show a tip text when i put the mouse over an image?
How would i make it so a chat command only works when looking at an entity? Thanks.
[QUOTE=vontiagaming;47744569]How would i make it so a chat command only works when looking at an entity? Thanks.[/QUOTE] If you don't care about the range look into this.. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetEyeTrace]Player:GetEyeTrace[/url] Otherwise.. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/TraceLine]util.TraceLine[/url]
[QUOTE=Mornedil;47741528]I'm also pretty new at lua, but have some experience with game programming before :P. As for controlling the player's angles with WASD, you should look into [URL="http://wiki.garrysmod.com/page/Player/SetEyeAngles"]SetEyeAngles[/URL]. To turn movement keys into numeric variables, you can do the following: (This can be very useful in order to use those key presses to calculate the eye angle vectors) [CODE]--ply should be the player entity local w = ply:KeyDown(IN_FORWARD) and 1 or 0 --set variable to 1 if KeyDown is true, or set it to 0 if KeyDown is false. local s = ply:KeyDown(IN_BACK) and 1 or 0 local a = ply:KeyDown(IN_MOVELEFT) and 1 or 0 local d = ply:KeyDown(IN_MOVERIGHT) and 1 or 0[/CODE] I just learned about how to do that, so.. if it gives an error, enclose within ( ), like: [CODE]local w = ( ply:KeyDown(IN_FORWARD) and 1 or 0 )[/CODE] KeyDown returns either true or false depending on if you press the key or not. so in the above code, the variables w, a, s and d will be set to 1 if you're holding the key, and 0 if you're not. I'm not sure how to make the player always walk forward with WASD, instead of strafing or moving backwards. As for checking for walls to prevent players from walking up/down in corridors, maybe [URL="http://wiki.garrysmod.com/page/util/TraceLine"]TraceLine[/URL] ?[/QUOTE] Yes! You definitely got me set on the right path, I think. I'm going to be working on this before work tomorrow. Thank you so much for the suggestions; you rock!
Am I missing something with SetNWBool? It doesn't seem to be syncing to the client. Serverside: [code] > for k,v in pairs( player.GetAll() ) do v:SetNWBool("test", true ) end > for k,v in pairs( player.GetAll() ) do print(v:GetNWBool("test")) end true [/code] Clientside: [code] ] lua_run_cl for k,v in pairs( player.GetAll() ) do print( v:GetNWBool("test") ) end false [/code]
Quetsion about sending models/textures to the client: The official [URL="https://github.com/adamdburton/pointshop-extras"]pointshop extras[/URL] addon has a script which sends everything the specified folders to the client. But, I've noticed that on lots of servers that use the pointshop, these files get sent [B]every time[/B] the player joins. Can the script be adjusted to first check if the client has the files, and only download/update them if the client's files doesn't match up with the server's files? [CODE]-- Add model and material folders here as required -- WARNING: THIS WILL TELL CLIENTS TO DOWNLOAD EVERYTHING POSSIBLE FROM THESE FOLDERS -- I RECOMMEND YOU BE SELECTIVE local models = { 'astronauthelmet', 'cakehat', 'duncehat', 'fish', 'gmod_tower', 'lordvipes/mariohat', 'props/cs_office', 'props/de_tides', 'santa', 'vikinghelmet' } local materials = { 'models/astronauthelmet', 'models/cakehat', 'models/duncehat', 'models/gmod_tower', 'models/sam', 'models/santa', 'models/vikinghelmet', 'models/lordvipes/mariohat', 'models/samus', 'models/fish', 'models/props/cs_office', 'models/props/de_tides', 'psicons' } -- end function resource.AddDir(dir) local f, d = file.Find(dir .. '/*', 'GAME') for k, v in pairs(f) do resource.AddSingleFile(dir .. '/' .. v) end for k, v in pairs(d) do resource.AddDir(dir .. '/' .. v) end end for _, mf in pairs(models) do resource.AddDir('models/' .. mf) end for _, mf in pairs(materials) do resource.AddDir('materials/' .. mf) end[/CODE]
You could network and compare the util.CRC or file.Time() date of the file if you want exact matches (probably not worth tbh), otherwise file.Exists() them. Simple if statement inside the AddSingleFile for loop.
Bigger problem seems to be usage of serverdl instead of fastdl. If you use fastdl that should not happen.
Anyone got any decent ways of drawing a radial menu, my maths sucks ass :( Guess it would be similar to how CSGO's is drawn
[lua]local places = 360 / #thingstodraw do local x0, y0 = 0, 0 local px, py = ScrW() / 2, ScrH() / 2 local sizex, sizey = ScrH() / 2.8, ScrH() / 2.8 for i = 0, 360, places do i = i + 180 local x1 = math.sin( math.rad( i ) ) * sizex local y1 = math.cos( math.rad( i ) ) * sizey if ( i - 180 ) > 0 then local index = math.Round( ( i - 180 ) / places ) surface.SetDrawColor( 255, 255, 255, 255) surface.DrawRect( x0 + px - 60, y0 + py, 120, 45 ) end x0 = x1 y0 = y1 end end [/lua] some old code i had lying arround here. Dunno who make it tbh, but kudos to him.
I decided to just make a workshop addon with all the models and put it as a force download.
What exactly is the replacement for the old [CODE]self:DrawEntityOutline( 1.0 )[/CODE] code?
How can I make a sort of "bubble" around a model? That is, create a clientside model that's the same, except with bones inflated, that floats around the original model, and apply a texture to it? I pretty much described what I need to do, I think, but I honestly have no idea how I could do that.
[QUOTE=DonnieLewis;47753364]What exactly is the replacement for the old [CODE]self:DrawEntityOutline( 1.0 )[/CODE] code?[/QUOTE] [url]http://wiki.garrysmod.com/page/halo/Add?[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/gsub]string.gsub[/url] it's not regex though, the closest thing lua has is patterns, which are similar
I need to ask again if someone could give me any pointers regarding DLabels height. Using SetWrap( true ) results in the text automatically jumping down a line - great, but how am I supposed to know how tall the text is? Using GetTall() just returns the one-line height. This is the solution I have right now but it doesn't work properly, for example a 3 line tall DLabel gives another amount of padding to the next DLabel than if it was a 1 or 2 lines, while I just want 2 lines in everyone: [CODE] for i, v in pairs( Laws.Default ) do text[ count ] = vgui.Create( "DLabel", holder ); text[ count ]:SetPos( 0, padding ); text[ count ]:SetColor( Color( 255, 255, 255, 255 ) ); text[ count ]:SetText( v ); text[ count ]:SetWide( holder:GetWide() - 10 ); text[ count ]:SetWrap( true ); text[ count ]:SetAutoStretchVertical( true ); w, h = surface.GetTextSize( text[ count ]:GetText() ); mathc = math.Round( text[ count ]:GetWide() / ( holder:GetWide() - 10 ), 0 ); padding = padding + h + h * ( mathc + 1 ); count = count + 1; end [/CODE] I tried looking for \n and for each of those add a certain amount to padding but it seems like there's no \ns :/
[QUOTE=Busan1;47755121]I need to ask again if someone could give me any pointers regarding DLabels height. Using SetWrap( true ) results in the text automatically jumping down a line - great, but how am I supposed to know how tall the text is? Using GetTall() just returns the one-line height. This is the solution I have right now but it doesn't work properly, for example a 3 line tall DLabel gives another amount of padding to the next DLabel than if it was a 1 or 2 lines, while I just want 2 lines in everyone: [CODE] for i, v in pairs( Laws.Default ) do text[ count ] = vgui.Create( "DLabel", holder ); text[ count ]:SetPos( 0, padding ); text[ count ]:SetColor( Color( 255, 255, 255, 255 ) ); text[ count ]:SetText( v ); text[ count ]:SetWide( holder:GetWide() - 10 ); text[ count ]:SetWrap( true ); text[ count ]:SetAutoStretchVertical( true ); w, h = surface.GetTextSize( text[ count ]:GetText() ); mathc = math.Round( text[ count ]:GetWide() / ( holder:GetWide() - 10 ), 0 ); padding = padding + h + h * ( mathc + 1 ); count = count + 1; end [/CODE] I tried looking for \n and for each of those add a certain amount to padding but it seems like there's no \ns :/[/QUOTE] Any reason you aren't using docking ? From the way they are laid out each one could be docked to the top and they should flow down easy enough.
Does anyone know how to add sounds to be played at a specific time in a SWEP's reload animation? Is the best method to use timers? If not, is there a better method?
I am trying to make a script that keep the ammo the same for a player when they die. The weapons are FA:S. [lua] for k,v in pairs( savedammo ) do local split = string.Explode("/", v ) print(split[1].." " ..split[2]) target_ply:SetAmmo(split[1],split[2]) end [/lua] I am getting all of their guns ammo by creating a loop with GetWeapons then creating this variable [lua] local ammo = ply:GetAmmoCount( v:GetPrimaryAmmoType() ).. "/" ..v:GetPrimaryAmmoType() [/lua] and putting it into the table savedammo. It should work, because the split[1] and split[2] are the correct values but it never sets the ammo to that..The values that it gives for that print are [lua] 120 48 [/lua]
tonumber?
[QUOTE=PortalGod;47760514]tonumber?[/QUOTE] OMFG. I just smashed my face aganist my keyboard twice. I was trying to find out why for hours....
[DEL]Trying to modify weapon stats server-side (I know I have to update the values client-side) by: [code] hook.Add("OnEntityCreated", "SWSOnEntityCreate", function(ent) if ent:IsWeapon() then ent.Primary.Damage = 5 end end) [/code] However it does not work, resulting in Primary being nil. Printing ent results in the weapon but no way of modifying any stats. Any help?[/DEL] Got it. It was due to Primary not being set until next frame.
Trying to implement a team limit on a shitty game mode I'm making. The function I made. I know its equal to 0, I just did that to test if this would work at all. [CODE]local function TeamLimit(ply) if team.NumPlayers(2) == 0 then ply:ChatPrint("Team is full") return false end end[/CODE] Hook I made to hook onto the function to control team switching [CODE]hook.Add("TeamSwitch","Limit",TeamLimit)[/CODE] Team Switching function [CODE]local function TeamSwitch(ply,text) text = string.lower(text) if (string.sub(text,1) == "!juggernaut") then ply:SetTeam(2) ply:Spawn() ply:StripWeapons() ply:Give("weapon_crowbar") ply:SetWalkSpeed(50) ply:SetRunSpeed(200) end end [/CODE] I'm new to lua, so bare with me. Any help is appreciated.
[QUOTE=matrixninja;47761506]Trying to implement a team limit on a shitty game mode I'm making. The function I made. I know its equal to 0, I just did that to test if this would work at all. [CODE]local function TeamLimit(ply) if team.NumPlayers(2) == 0 then ply:ChatPrint("Team is full") return false end end[/CODE] Hook I made to hook onto the function to control team switching [CODE]hook.Add("TeamSwitch","Limit",TeamLimit)[/CODE] Team Switching function [CODE]local function TeamSwitch(ply,text) text = string.lower(text) if (string.sub(text,1) == "!juggernaut") then ply:SetTeam(2) ply:Spawn() ply:StripWeapons() ply:Give("weapon_crowbar") ply:SetWalkSpeed(50) ply:SetRunSpeed(200) end end [/CODE] I'm new to lua, so bare with me. Any help is appreciated.[/QUOTE] You can't hook a function of your own, what you can do is hook into this: [url]http://wiki.garrysmod.com/page/GM/PlayerCanJoinTeam[/url] inside the hook, you check: how many is in the team(your TeamLimit function) if TeamLimit returns true(he can join) then run your TeamSwitch function What you can do is also hook.Call = making your own hook but that seems unecessary [CODE] hook.Add( "PlayerCanjoinTeam", "ofgsdhodhjf", function( ply, team ) // team is the number of your team if( #team.GetPlayers( team ) > #team.GetPlayers( other team(s) ) or just == 2 ) then return false; // team is full else return true; // he can join team end end ); hook.Add( "PlayerSpawn", "seoesgko", function( ply ) for i, v in pairs( exampleLoadoutTable[ ply:Team() ] ) do ply:Give( v ); end end ); [/CODE]
I'm trying to create a duplicate model of another... I want to perfectly mimic the bone positions / angles, but I don't know how to do that! How can I word that better? How could I replicate the bone pose of a model, and apply it to another? Model [B]A[/B] was raising its hands while kicking a ball, I want model [B]B[/B] to look the same. [editline]20th May 2015[/editline] Let's see if I can answer my own question. Correct me if I'm wrong, but I would have to use [B]GetBoneMatrix[/B] for each and every bone on model [B]A[/B], and [B]SetBoneMatrix[/B] on the bones of model [B]B[/B]? But is that efficient?
[QUOTE=WalkingZombie;47761618]I'm trying to create a duplicate model of another... I want to perfectly mimic the bone positions / angles, but I don't know how to do that! How can I word that better? How could I replicate the bone pose of a model, and apply it to another? Model [B]A[/B] was raising its hands while kicking a ball, I want model [B]B[/B] to look the same. [editline]20th May 2015[/editline] Let's see if I can answer my own question. Correct me if I'm wrong, but I would have to use [B]GetBoneMatrix[/B] for each and every bone on model [B]A[/B], and [B]SetBoneMatrix[/B] on the bones of model [B]B[/B]? But is that efficient?[/QUOTE] [url]http://wiki.garrysmod.com/page/Entity/GetPhysicsObjectCount[/url] [url]http://wiki.garrysmod.com/page/Entity/GetPhysicsObjectNum[/url] [url]http://wiki.garrysmod.com/page/Entity/GetBonePosition[/url] you probably need those and then get the bone from model 2 and SetPos/SetAngles like the bone for model 1
[QUOTE=WalkingZombie;47761618]I'm trying to create a duplicate model of another... I want to perfectly mimic the bone positions / angles, but I don't know how to do that! How can I word that better? How could I replicate the bone pose of a model, and apply it to another? Model [B]A[/B] was raising its hands while kicking a ball, I want model [B]B[/B] to look the same. [editline]20th May 2015[/editline] Let's see if I can answer my own question. Correct me if I'm wrong, but I would have to use [B]GetBoneMatrix[/B] for each and every bone on model [B]A[/B], and [B]SetBoneMatrix[/B] on the bones of model [B]B[/B]? But is that efficient?[/QUOTE] Bone merge by AddEffects [url]http://wiki.garrysmod.com/page/Entity/AddEffects[/url] . Old wiki has an example [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4e03.html[/url]
[QUOTE=Busan1;47761531]You can't hook a function of your own, what you can do is hook into this: [url]http://wiki.garrysmod.com/page/GM/PlayerCanJoinTeam[/url] inside the hook, you check: how many is in the team(your TeamLimit function) if TeamLimit returns true(he can join) then run your TeamSwitch function What you can do is also hook.Call = making your own hook but that seems unecessary [CODE] hook.Add( "PlayerCanjoinTeam", "ofgsdhodhjf", function( ply, team ) // team is the number of your team if( #team.GetPlayers( team ) > #team.GetPlayers( other team(s) ) or just == 2 ) then return false; // team is full else return true; // he can join team end end ); hook.Add( "PlayerSpawn", "seoesgko", function( ply ) for i, v in pairs( exampleLoadoutTable[ ply:Team() ] ) do ply:Give( v ); end end ); [/CODE][/QUOTE] [CODE]hook.Add("PlayerCanJoinTeam","CanJoin",function(ply,team) if(team.GetPlayers(2) == 0) then return false else return true end end );[/CODE] That's what I have so far, what next? Still a bit confused.
[QUOTE=matrixninja;47761748][CODE]hook.Add("PlayerCanJoinTeam","CanJoin",function(ply,team) if(team.GetPlayers(2) == 0) then return false else return true end end );[/CODE] That's what I have so far, what next? Still a bit confused.[/QUOTE] In whatever way your team changing is set up, once a player attempts to switch team, that hook "PlayerCanJoinTeam" will be run. If you return false, the player can't change team, if you return true, the player can change team. [url]http://wiki.garrysmod.com/page/GM/PlayerCanJoinTeam[/url]
How would I go about making my own tracers for ShootBullet? If I can somehow capture the traces from ShootBullet, I'd be golden, but that's not possible, is it?
Sorry, you need to Log In to post a reply to this thread.