• What do you need help with? V3
    6,419 replies, posted
I have this grapple hook: [url]http://www.garrysmod.org/downloads/?a=view&id=129537[/url]) and, with the help of someone, I converted it to work with TTT. Althought I have one problem, it will only shoot if you are about 30cm away from the object. Here is my shared.lua: [CODE]SWEP.Author = "Hxrmn, HOLOGRAPHICpizza" SWEP.Contact = "hello45044@gmail.com" SWEP.Purpose = "A Grappling Hook" SWEP.Instructions = "Left click to fire" SWEP.Base = "weapon_tttbase" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.AutoSpawnable = false SWEP.Kind = WEAPON_PISTOL SWEP.CanBuy = {ROLE_TRAITOR, ROLE_DETECTIVE} SWEP.AllowDrop = true SWEP.PrintName = "Grappling Hook" SWEP.DrawAmmo = false SWEP.DrawCrosshair = false SWEP.ViewModel = "models/weapons/v_crossbow.mdl" SWEP.WorldModel = "models/weapons/w_crossbow.mdl" SWEP.Primary.Ammo = "none" SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 local sndPowerUp = Sound("weapons/crossbow/hit1.wav") local sndPowerDown = Sound("Airboat.FireGunRevDown") local sndTooFar = Sound("buttons/button10.wav") //local sndShot = Sound("weapons/357/357_fire2.wav") if CLIENT then SWEP.PrintName = "Grappling Hook" SWEP.Slot = 1 -- Path to the icon material SWEP.Icon = "VGUI/ttt/icon_fall" -- Text shown in the equip menu SWEP.EquipMenuData = { type = "Weapon", desc = "Lets you use a rope to maneuver around a map." }; end if SERVER then AddCSLuaFile( "shared.lua" ) end function SWEP:Initialize() nextshottime = CurTime() //self:SetWeaponHoldType( "smg" ) end function SWEP:Think() if (!self.Owner || self.Owner == NULL) then return end if ( self.Owner:KeyPressed( IN_ATTACK ) ) then self:StartAttack() elseif ( self.Owner:KeyDown( IN_ATTACK ) && inRange ) then self:UpdateAttack() elseif ( self.Owner:KeyReleased( IN_ATTACK ) && inRange ) then self:EndAttack( true ) end //Changed from KeyDown to prevent random stuck-in-zoom bug. if ( self.Owner:KeyPressed( IN_ATTACK2 ) ) then self:Attack2() end end function SWEP:DoTrace( endpos ) local trace = {} trace.start = self.Owner:GetShootPos() trace.endpos = trace.start + (self.Owner:GetAimVector() * 14096) //15096 is length modifier. if(endpos) then trace.endpos = (endpos - self.Tr.HitNormal * 7) end trace.filter = { self.Owner, self.Weapon } self.Tr = nil self.Tr = util.TraceLine( trace ) end function SWEP:StartAttack() //Get begining and end poins of trace. local gunPos = self.Owner:GetShootPos() //Start of distance trace. local disTrace = self.Owner:GetEyeTrace() //Store all results of a trace in disTrace. local hitPos = disTrace.HitPos //Stores Hit Position of disTrace. //Calculate Distance //Thanks to rgovostes for this code. local x = (gunPos.x - hitPos.x)^2; local y = (gunPos.y - hitPos.y)^2; local z = (gunPos.z - hitPos.z)^2; local distance = math.sqrt(x + y + z); //Only latches if distance is less than distance CVAR local distanceCvar = GetConVarNumber("grapple_distance") inRange = false if distance <= distanceCvar then inRange = true end if inRange then if (SERVER) then if (!self.Beam) then //If the beam does not exist, draw the beam. //grapple_beam self.Beam = ents.Create( "trace1" ) self.Beam:SetPos( self.Owner:GetShootPos() ) self.Beam:Spawn() end self.Beam:SetParent( self.Owner ) self.Beam:SetOwner( self.Owner ) end self:DoTrace() self.speed = 10000 //Rope latch speed. Was 3000. self.startTime = CurTime() self.endTime = CurTime() + self.speed self.ddt = -1 if (SERVER && self.Beam) then self.Beam:GetTable():SetEndPos( self.Tr.HitPos ) end self:UpdateAttack() self.Weapon:EmitSound( sndPowerDown ) else //Play A Sound self.Weapon:EmitSound( sndTooFar ) end end function SWEP:UpdateAttack() self.Owner:LagCompensation( true ) if (!endpos) then endpos = self.Tr.HitPos end if (SERVER && self.Beam) then self.Beam:GetTable():SetEndPos( endpos ) end lastpos = endpos if ( self.Tr.Entity:IsValid() ) then endpos = self.Tr.Entity:GetPos() if ( SERVER ) then self.Beam:GetTable():SetEndPos( endpos ) end end local vVel = (endpos - self.Owner:GetPos()) local Distance = endpos:Distance(self.Owner:GetPos()) local et = (self.startTime + (Distance/self.speed)) if(self.ddt != 0) then self.ddt = (et - CurTime()) / (et - self.startTime) end if(self.ddt < 0) then self.Weapon:EmitSound( sndPowerUp ) self.ddt = 0 end if(self.ddt == 0) then zVel = self.Owner:GetVelocity().z vVel = vVel:GetNormalized()*(math.Clamp(Distance,0,7)) if( SERVER ) then local gravity = GetConVarNumber("sv_Gravity") vVel:Add(Vector(0,0,(gravity/100)*3.5)) //Player speed. DO NOT MESS WITH THIS VALUE! if(zVel < 0) then vVel:Sub(Vector(0,0,zVel/100)) end self.Owner:SetVelocity(vVel) end end endpos = nil self.Owner:LagCompensation( false ) end function SWEP:EndAttack( shutdownsound ) if ( shutdownsound ) then self.Weapon:EmitSound( sndPowerDown ) end if ( CLIENT ) then return end if ( !self.Beam ) then return end self.Beam:Remove() self.Beam = nil end function SWEP:Attack2() //Zoom. // self.Weapon:EmitSound( self.Secondary.Sound, 50, 100 ) if (CLIENT) then return end local CF = self.Owner:GetFOV() if CF == 90 then self.Owner:SetFOV(30,.3) elseif CF == 30 then self.Owner:SetFOV(90,.3) // self.Scope = true // elseif
Can someone give this a look for error and correct it? It keeps telling me: [CODE][ERROR] addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua:294: attempt to call global 'ValidEntity' (a nil value) 1. unknown - addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua:294 Timer Failed! [Simple][@addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua (line 293)]][/CODE] Heres the code: [CODE]local function GetCoffeeMsg(um) chat.AddText(Color(240, 175, 145), "Mr. Saturn", Color(255, 255, 255), ": " .. tbl[math.random(1, #tbl)]); for i = 1, math.random(7, 10) do timer.Simple((i * .08), function() if (IsValid(LocalPlayer())) then surface.PlaySound("mother/saturn_text.wav"); end end); end end usermessage.Hook("SaturnUWANTCOFFEE", GetCoffeeMsg); [/CODE] And this is getting a similar error. [CODE]local function physgunPickup(ply, ent) if (IsValid(ent.Saturn)) then return false; end if (ent:GetClass() == "mr_saturn") then if (!ent.CanGrav) then return false; end ent.SCHEDTime = 0; ent.ShouldWalk = true; return true; end if (ent.IsSaturnHat) then return false; end end hook.Add("PhysgunPickup", "MOTHERPhysgunPickup", physgunPickup);[/CODE]
[QUOTE=triset;39062358]Can someone give this a look for error and correct it? It keeps telling me: [CODE][ERROR] addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua:294: attempt to call global 'ValidEntity' (a nil value) 1. unknown - addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua:294 Timer Failed! [Simple][@addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua (line 293)]][/CODE] Heres the code: [CODE]local function GetCoffeeMsg(um) chat.AddText(Color(240, 175, 145), "Mr. Saturn", Color(255, 255, 255), ": " .. tbl[math.random(1, #tbl)]); for i = 1, math.random(7, 10) do timer.Simple((i * .08), function() if (IsValid(LocalPlayer())) then surface.PlaySound("mother/saturn_text.wav"); end end); end end usermessage.Hook("SaturnUWANTCOFFEE", GetCoffeeMsg); [/CODE][/QUOTE] Change IsValid(LocalPlayer()) to LocalPlayer():IsValid()
[QUOTE=Netheous;39062793]Change IsValid(LocalPlayer()) to LocalPlayer():IsValid()[/QUOTE] Correct me if I'm wrong, but those two are the exact same. [QUOTE=triset;39062358]Can someone give this a look for error and correct it? It keeps telling me: [CODE][ERROR] addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua:294: attempt to call global 'ValidEntity' (a nil value) 1. unknown - addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua:294 Timer Failed! [Simple][@addons/mr. saturn/lua/autorun/client/cl_saturn_autorun.lua (line 293)]][/CODE] [/QUOTE] I don't see "ValidEntity()" being called anywhere in your code, so the only thing that I can assume is that the version of the script you're giving us is not the same as the version that's returning that error. Re-check your lua/autorun/client/ folder and make sure that cl_saturn_autorun.lua is what you think it is.
[QUOTE=TehButter;39062855]Correct me if I'm wrong, but those two are the exact same.[/QUOTE] Actually, IsValid(X) is better cause it checks if the variable exists first.
If you're too lazy to look through the file you can always stick ValidEntity = IsValid at the top of the file It's better to replace the instances of ValidEntity with IsValid though.
[QUOTE=TehButter;39060837][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.[/QUOTE] Is it possible with the Steam API to send a group invite as well? If so, is there any documentation on how to do that?
[QUOTE=Crap-Head;39065574]Is it possible with the Steam API to send a group invite as well? If so, is there any documentation on how to do that?[/QUOTE] Not with that or the steam:// protocol, you might be able to with a binary module
[QUOTE=smithy285;39062101][b]//Only latches if distance is less than distance CVAR local distanceCvar = GetConVarNumber("grapple_distance") inRange = false if distance <= distanceCvar then inRange = true end if inRange then[/b][/QUOTE] Try and read the code next time, it's even commented.
How do I have the DoClick and remove itself? self:Remove() doesn't seem to be working, same with setvisible. [CODE]local TeamsListPanel={} function TeamsListPanel:Paint() end function TeamsListPanel:Init() local TeansListView = vgui.Create("DListView") TeansListView:SetParent(TeamsPanel) TeansListView:SetPos(10, 10) TeansListView:SetSize(TeamsPanel:GetWide()-35, TeamsPanel:GetTall()-115) TeansListView:SetMultiSelect(false) TeansListView:AddColumn("Team") TeansListView:AddColumn("Wins") TeansListView:AddColumn("Loses") TeansListView:AddColumn("Members") TeansListView:AddColumn("Locked") local TeamsCreateButton = vgui.Create("DButton") TeamsCreateButton:SetParent(TeamsPanel) TeamsCreateButton:SetPos(10, TeansListView:GetTall()+20) TeamsCreateButton:SetSize((TeamsPanel:GetWide()/2)-22, 50) TeamsCreateButton:SetText("Create Team") TeamsCreateButton.DoClick = function() self:Remove() end local TeamsJoinButton = vgui.Create("DButton") TeamsJoinButton:SetParent(TeamsPanel) TeamsJoinButton:SetSize((TeamsPanel:GetWide()/2)-23, 50) TeamsJoinButton:SetPos(TeamsPanel:GetWide()-TeamsJoinButton:GetWide()-25, TeansListView:GetTall()+20) TeamsJoinButton:SetText("Join Team") end vgui.Register("TeamsListPanel", TeamsListPanel) TeamsCreateListPanel = vgui.Create("TeamsListPanel",TeamsPanel)[/CODE]
Okay according to the errors I'm getting a table doesn't exist, yet when I use lua_run in the console it's returning it fine, here's the errors: [code] [ERROR] gamemodes/genericrp/gamemode/server/sv_metatable.lua:121: bad argument #1 to 'pairs' (table expected, got nil) 1. pairs - [C]:-1 2. GetInventoryItem - gamemodes/genericrp/gamemode/server/sv_metatable.lua:121 3. AddInventoryItem - gamemodes/genericrp/gamemode/server/sv_metatable.lua:149 4. unknown - lua_run:1 [/code] Related functions: [lua] function pl:GetInventoryItem(item) for k,v in pairs(self.Inventory) do -- Error here, I have no idea why. if table.HasValue(v,item) then return k, v[2] else return self:GetOpenSlot(), 0 end end end function pl:SetInventoryItem(slot,item,amt) print(item) if itemExists(item) then if amt > global_items[itemToKey(item)].MaxAmount then self.Inventory[slot][item] = global_items[itemToKey(item)].MaxAmount else self.Inventory[slot][item] = amt end local inv = util.TableToJSON(self.Inventory) tmysql.query("UPDATE players SET inventory='"..inv.."' WHERE steamid='"..self:SteamID().."'",callback) self:SyncData_client() else error("Invalid item ("..item.."?)") end end function pl:AddInventoryItem(item,amt) local slot, amount = pl:GetInventoryItem(item) self:SetInventoryItem(slot, item, amount + amt) end [/lua] Any suggestions? It might be obvious but I've been up for a good 18 hours so I'm pretty exhausted :v: EDIT: Ah wow, it was the fact that there was a pl and not a self.
[QUOTE=tissue902;39067453]How do I have the DoClick and remove itself? self:Remove() doesn't seem to be working, same with setvisible. [CODE]stuff[/CODE][/QUOTE] TeamsCreateButton.DoClick = function( self ) or function TeamsCreateButton:DoClick()
[QUOTE=BL00DB4TH;39068396]TeamsCreateButton.DoClick = function( self ) or function TeamsCreateButton:DoClick()[/QUOTE] I wasn't very clear on what I was trying to do. That just removes the button, id like to remove the TeamsCreateListPanel.
So I did some edits to this [URL="http://facepunch.com/showthread.php?t=1209676"]code[/URL], namely removing the gm in front of the functions, changing the font to default, and removing some extra code that seemed only specific to that gamemode. The only error I've seen in the console so far was about the gm nil value, but after removing gm from every function, that problem seems to have been solved. Now, there's simply no reference to the code at all: all that shows up in gmod is the default HUD. Here's the code: [CODE]paraHud = {}; paraHud.SUPER_SIZE = 0.05/2; -- 3D Hud Scale (Def: 0.05) paraHud.SUPER_DISTANCE = 25/2; -- 3D Hud Distance (Def: 25) paraHud.SUPER_ANGLE = 20; -- 3D Hud Angle (Def: 20) paraHud.SUPER_COLOR = Color(229, 178, 85, 255); paraHud.ScreenWidth = 0; paraHud.ScreenHeight = 0; paraHud.ScreenFOV = 0; -- 15 DEGREES -- 16:9 FOV90 (2/2/1) 0.4 DIFF -- 16:9 FOV75 (2.4/2/1) -- 16:10 FOV90 (2.15/2/1) 0.45 DIFF -- 16:10 FOV75 (2.6/2/1) -- 4:3 FOV90 (2.6/2/1) 0.55 DIFF -- 4:3 FOV75 (3.15/2/1) function HUDPaint() --paraHud.Health(); --paraHud.Need(); --paraHud.Test3D(); paraHud.CheckDimensions(); -- Draw 3D Hud cam.Start3D(EyePos(), EyeAngles()) --paraHud.SuperHud(); cam.End3D() --paraHud.GetPlayerInfo(); end function HUDShouldDraw(name) local draw = true; if(name == "CHudHealth" or name == "CHudBattery" or name == "CHudAmmo" or name == "CHudSecondaryAmmo") then draw = false; end return draw; end function paraHud.CheckDimensions() local width = ScrW(); local height = ScrH(); local fov = LocalPlayer():GetFOV(); if(paraHud.ScreenWidth ~= width or paraHud.ScreenHeight ~= height or (fov >= 75 and paraHud.ScreenFOV ~= fov)) then paraHud.ChangeRatios(width, height, fov); end return; end function paraHud.ChangeRatios(width, height, fov) local fovDiff = fov - 75; if(width / height == 16 / 9) then paraHud.SUPER_SIZE = 0.05 / (2.4 - 0.4 * (fovDiff / 15)); print("Changed to 16:9 mode!"); elseif(width / height == 16 / 10) then paraHud.SUPER_SIZE = 0.05 / (2.6 - 0.45 * (fovDiff / 15)); print("Changed to 16:10 mode!"); else paraHud.SUPER_SIZE = 0.05 / (3.15 - 0.55 * (fovDiff / 15)); print("Changed to 4:3 mode!"); end paraHud.ScreenWidth = width; paraHud.ScreenHeight = height; paraHud.ScreenFOV = fov; return; end function paraHud.Health3D(pl, pos, ang) local health = pl:Health(); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 ); draw.DrawText(health, "default", -440*4, 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ); cam.End3D2D(); surface.SetFont("default"); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText("/100", "default", (-440*2)+(surface.GetTextSize(health)/2), 194*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ); draw.DrawText("Alien Host", "default", -440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ); cam.End3D2D(); return; end function paraHud.Weapon3D(pl, pos, ang) local weapon = pl:GetActiveWeapon(); if(weapon ~= nil) then local weaponType = weapon:GetPrintName(); local weaponMag = weapon:Clip1(); local weaponAmmo = pl:GetAmmoCount(weapon:GetPrimaryAmmoType()); if(weaponMag < 0) then if(weaponAmmo > 0) then -- Basic cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 ); draw.DrawText(weaponAmmo, "default", 440*4, 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText(weaponType, "default", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); else -- Melee cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText(weaponType, "default", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); end elseif(weaponAmmo < 1 and weaponMag < 1) then -- No Ammo cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText(weaponType, "default", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); else -- Full cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText("/"..weaponAmmo, "default", 440*2, 194*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); draw.DrawText(weaponType, "default", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); surface.SetFont("default"); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 ); draw.DrawText(weaponMag, "default", (440*4)-(surface.GetTextSize("/"..weaponAmmo)*2), 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); end end return; end function paraHud.Need3D(pl, pos, ang) cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/(4*1.1) ); draw.DrawText("KILL", "default", -460*4, -257*4, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP ); cam.End3D2D(); surface.SetFont("default"); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/(2*1.1) ); draw.DrawText("10x", "default", (-458*2)+(surface.GetTextSize("PISS")/2), -255*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP ); draw.DrawText("Need", "default", -460*2, -270*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP ); cam.End3D2D(); end function paraHud.Inventory3D(pl, pos, ang) cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 ); draw.DrawText("1234567890", "default", 0, 300*4, paraHud.SUPER_COLOR, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ); surface.SetDrawColor(paraHud.SUPER_COLOR); surface.DrawLine(-200*4, 285*4, 200*4, 285*4); -- Top surface.DrawLine(-200*4, 360*4, 200*4, 360*4); -- Bottom surface.DrawLine(-200*4, 285*4, -200*4, 360*4); -- Left surface.DrawLine(200*4, 285*4, 200*4, 360*4); -- Right cam.End3D2D(); return; end function paraHud.SuperHud() local pl = LocalPlayer(); local plAng = EyeAngles(); local plPos = EyePos(); local pos = plPos; local centerAng = Angle(plAng.p, plAng.y, 0); pos = pos + (centerAng:Forward() * paraHud.SUPER_DISTANCE); centerAng:RotateAroundAxis( centerAng:Right(), 90 ); centerAng:RotateAroundAxis( centerAng:Up(), -90 ); local leftAng = Angle(centerAng.p, centerAng.y, centerAng.r); local rightAng = Angle(centerAng.p, centerAng.y, centerAng.r); leftAng:RotateAroundAxis( leftAng:Right(), paraHud.SUPER_ANGLE*-1 ); rightAng:RotateAroundAxis( rightAng:Right(), paraHud.SUPER_ANGLE ); local centerAngUp = Angle(plAng.p, plAng.y, 0); centerAngUp:RotateAroundAxis( centerAngUp:Right(), 98 ); centerAngUp:RotateAroundAxis( centerAngUp:Up(), -90 ); local leftAngUp = Angle(centerAngUp.p, centerAngUp.y, centerAngUp.r); local rightAngUp = Angle(centerAngUp.p, centerAngUp.y, centerAngUp.r); leftAngUp:RotateAroundAxis( leftAngUp:Right(), paraHud.SUPER_ANGLE*-1 ); rightAngUp:RotateAroundAxis( rightAngUp:Right(), paraHud.SUPER_ANGLE ); if(pl:Alive() == true and pl:Health() > 0) then cam.Start3D(plPos, plAng); cam.IgnoreZ(true); paraHud.Health3D(pl, pos, leftAng); paraHud.Weapon3D(pl, pos, rightAng); paraHud.Need3D(pl, pos, leftAngUp); paraHud.Time3D(pl, pos, rightAngUp); --paraHud.Inventory3D(pl, pos,
[QUOTE=tissue902;39068656]I wasn't very clear on what I was trying to do. That just removes the button, id like to remove the TeamsCreateListPanel.[/QUOTE] TeamsCreateListPanel:Remove() ?
[QUOTE=BL00DB4TH;39068935]TeamsCreateListPanel:Remove() ?[/QUOTE] Tried that. it removes the button for some reason. if you print TeamsCreateListPanel you get Panel: [name:][class:Label][10,489,206,50] which makes no sense. i feel this shouldnt be this difficult
[QUOTE=Chessnut;34510704][url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2c41.html?title=Gui.OpenURL[/url] [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7dc7.html?title=Surface.DrawCircle[/url] These aren't hard to find you know.[/QUOTE] Thanks dude I ended up on like 4 gmod tutorial wiki's looking for that specific one happy I went on facepunch like everyone told me it would help.
I need help in fixing the stacking system in my gamemode, I have a 36 slot inventory and when an item is in slot 1 it will stack, but any other slot it will use a whole new slot for a single item. Any ideas? Here's all code related to it. [lua] function pl:GetInventorySlot(slot) if self.Inventory[slot] then return self.Inventory[slot][1], self.Inventory[slot][2] else self.Inventory[slot] = {"None",0} self:GetInventorySlot(slot) end end function pl:GetOpenSlot() for k,v in pairs(self.Inventory) do if v[1] == "Empty" then return tonumber(k) end end end function pl:GetInventoryItem(item) for k,v in pairs(self.Inventory) do if table.HasValue(v,item) then print("Key: "..k) return k, v[2] else return self:GetOpenSlot(), 0 end end end util.AddNetworkString("recInventory") function pl:SetInventoryItem(slot,item,amt) if itemExists(item) or item == "Empty" then if slot > 0 && slot <= 36 then if amt > 0 then if amt > global_items[itemToKey(item)].MaxAmount then self.Inventory[slot]={item, global_items[itemToKey(item)].MaxAmount} print("Max: "..amt) else self.Inventory[slot]={item,amt} end else self.Inventory[slot] = {"Empty",0} end local inv = util.TableToJSON(self.Inventory) tmysql.query("UPDATE players SET inventory='"..inv.."' WHERE steamid='"..self:SteamID().."'",callback) net.Start("recInventory") net.WriteTable(self.Inventory) net.Send(self) end else error("Invalid item ("..item.."?)") end end function pl:AddInventoryItem(item,amt) local slot, amount = self:GetInventoryItem(item) local name, amountt = self:GetInventorySlot(slot) if slot then if amountt + amt <= global_items[itemToKey(item)].MaxAmount then print("Yep") self:SetInventoryItem(slot,item,amount + amt ) else print('Slot: '..slot..' | Amount: '..amount..' | Name: '..name..' | Amount 2: '..amountt) self:SetInventoryItem(self:,item, amt) end end end [/lua]
I'm having some trouble with a little gungame mode I'm working on. Whenever someone gets a new gun (IE after a kill), the model won't show up until they either fire a shot or switch to another weapon and back. I've looked around in other code like TTT's as to what happens when you pick up or get a gun, but I can't find anything. It's really weird. Any tips or tricks to add to the giveweapons function that gets called every time the player kills someone/spawns? It works fine when they spawn. [lua]function ply:GiveWeapons() self:StripWeapons() local y = self:GetNWInt("level") local wep = weplist[y] if wep ~= nil then self:Give(wep) self:Give("weapon_crowbar") self:SelectWeapon(wep) print(self:GetActiveWeapon()) else self:Give("weapon_crowbar") end end[/lua] Edit: Nevermind, I just switched to the crowbar then the new weapon, good enough
If you create a team on the client side shouldn't it show up on the server side too? If I create a team on the serverside then my scoreboards cant get any of the team info and team.GetAllTeams() only shows the 3 automatic ones. Also doesnt work in shared. Is this just a gmod13 bug or am I going to have to net the team list everytime it updates...
[QUOTE=Ruzza;39066108]Try and read the code next time, it's even commented.[/QUOTE] I feel stupid now D: Thanks for the help, I got it sorted now :D
Hi, I would like to know if it is unwise of me to do this on the client side since it is considered insecure? [lua] function HealthSubconciousness() if (LocalPlayer():Health() <= 90 && LocalPlayer():Health() > 80) then CL.HealthStatus = "Good"; end; if (!timer.Exists("RandomHSubTimer")) then timer.Create("RandomHSubTimer", math.Rand(20, 500), 0, function() chat.AddText(Color(100, 255, 100, 255), "You consider your health " .. CL.HealthStatus); end); end; end timer.Create("HSubTimer", 1, 0, HealthSubconciousness); [/lua] If so, I would make it in shared code instead.
[QUOTE=Christian;39073151]Hi, I would like to know if it is unwise of me to do this on the client side since it is considered insecure? [lua] function HealthSubconciousness() if (LocalPlayer():Health() <= 90 && LocalPlayer():Health() > 80) then CL.HealthStatus = "Good"; end; if (!timer.Exists("RandomHSubTimer")) then timer.Create("RandomHSubTimer", math.Rand(20, 500), 0, function() chat.AddText(Color(100, 255, 100, 255), "You consider your health " .. CL.HealthStatus); end); end; end timer.Create("HSubTimer", 1, 0, HealthSubconciousness); [/lua] If so, I would make it in shared code instead.[/QUOTE] Since the client can't modify anything to give them an advantage there, it's fine to run clientside.
I've edited the default scoreboard by adding a couple new columns, and it works just fine, the thing is, I edited the default file to do this. So when I update the server, I will lose what I did. I was wondering, is there some way to target a table, remove it, and replace it with my new one, then add it as an addon? I don't need to know how to make an addon, I just need to know how I could go about replacing a default gmod a table, if it's at all possible. Thanks!
[QUOTE=tinos;39073885]I've edited the default scoreboard by adding a couple new columns, and it works just fine, the thing is, I edited the default file to do this. So when I update the server, I will lose what I did. I was wondering, is there some way to target a table, remove it, and replace it with my new one, then add it as an addon? I don't need to know how to make an addon, I just need to know how I could go about replacing a default gmod a table, if it's at all possible. Thanks![/QUOTE] Need help changing death sounds such as in TTT. Heres what I've got: [lua] local deathsounds = { Sound("player/death1.wav"), Sound("player/death2.wav"), Sound("player/death3.wav"), Sound("player/death4.wav"), Sound("player/death5.wav"), Sound("player/death6.wav"), Sound("vo/npc/male01/pain07.wav"), Sound("vo/npc/male01/pain08.wav"), Sound("vo/npc/male01/pain09.wav"), Sound("vo/npc/male01/pain04.wav"), Sound("vo/npc/Barney/ba_pain06.wav"), Sound("vo/npc/Barney/ba_pain07.wav"), Sound("vo/npc/Barney/ba_pain09.wav"), Sound("vo/npc/Barney/ba_ohshit03.wav"), --heh Sound("vo/npc/Barney/ba_no01.wav"), Sound("vo/npc/male01/no02.wav"), Sound("hostage/hpain/hpain1.wav"), Sound("hostage/hpain/hpain2.wav"), Sound("hostage/hpain/hpain3.wav"), Sound("hostage/hpain/hpain4.wav"), Sound("hostage/hpain/hpain5.wav"), Sound("hostage/hpain/hpain6.wav") }; local function PlayDeathSound(victim) if not IsValid(victim) then return end sound.Play(table.Random(deathsounds), victim:GetShootPos(), 90, 100) end -- kill hl2 beep function DR:PlayerDeathSound() return true end [/lua]
[QUOTE=Ott;39057600]bump, this started happening to me too.[/QUOTE] Hey I noticed you quoted me, anyways I think this issue was being caused by DarkRP's /afk command, but I modified it to where it doesn't give the fake npc weapons, and I have never gotten this error since. (im pretty sure this is what was happening/what i did.) If you don't run darkrp then obviously I'm no help.
Would it be possible to get a table using LocalPlayer().tablename? The way I'm currently trying returns a nil value when I try access it on the client. Server [lua] for k,v in pairs(player.GetAll()) do v.Inventory = {"Item1", "Item2"} end [/lua] Client [lua] for k,v in pairs(LocalPlayer().Inventory) do print(v) end [/lua] Edit: The error I get is a [QUOTE]bad argument #1 to 'pairs' (table expected, got nil) [/QUOTE]
[QUOTE=prang123;39074935]Would it be possible to get a table using LocalPlayer().tablename? The way I'm currently trying returns a nil value when I try access it on the client. Server [lua] for k,v in pairs(player.GetAll()) do v.Inventory = {"Item1", "Item2"} end [/lua] Client [lua] for k,v in pairs(LocalPlayer().Inventory) do print(v) end [/lua] Edit: The error I get is a[/QUOTE] You'll have to network it yourself if you want to access it like that.
[QUOTE=prang123;39074935]Would it be possible to get a table using LocalPlayer().tablename? The way I'm currently trying returns a nil value when I try access it on the client. Server [lua] for k,v in pairs(player.GetAll()) do v.Inventory = {"Item1", "Item2"} end [/lua] Client [lua] for k,v in pairs(LocalPlayer().Inventory) do print(v) end [/lua] Edit: The error I get is a[/QUOTE] It's not accessible on the client if you're doing it on the server. Use net to send the information to the client.
[QUOTE=prang123;39074935]Would it be possible to get a table using LocalPlayer().tablename? The way I'm currently trying returns a nil value when I try access it on the client. Server [lua] for k,v in pairs(player.GetAll()) do v.Inventory = {"Item1", "Item2"} end [/lua] Client [lua] for k,v in pairs(LocalPlayer().Inventory) do print(v) end [/lua] Edit: The error I get is a[/QUOTE] Unfortunately, variables set on the player object serverside don't magically get synced to the client. Look into using the net library. You'll need to send a net message containing the inventory every time it changes to the player. [editline]3rd January 2013[/editline] BLARG ninja
Sorry, you need to Log In to post a reply to this thread.