• What do you need help with? V3
    6,419 replies, posted
[QUOTE=ajminifigure;36977615]Thanks. but one question. Is that serverside, client side, or shared? and can you give me an example of 1 team 2 classes? thanks.[/QUOTE] That's serverside, as OnRoundStart is a serverside only hook. 1 team 2 classes example? ok know at your shared.lua, you should probably have something like: [lua] team.SetUp( TEAM_PLAYER, "Players", Color( 255, 255, 255 ), true ) team.SetSpawnPoint( TEAM_PLAYER, { "info_player_start", "info_player_terrorist", "info_player_rebel", "info_player_deathmatch" } ) team.SetClass( TEAM_PLAYER, { "Player" } ) [/lua] You need to make another class, and add a new line at the shared.lua like [lua] team.SetClass( TEAM_PLAYER, { "Boss" } ) [/lua] and set the player to the boss class on the round start using the code I gave on the last post. the boss class would be like: [lua] local CLASS = {} CLASS.DisplayName = "Boss" CLASS.WalkSpeed = 400 CLASS.CrouchedWalkSpeed = 0.2 CLASS.RunSpeed = 600 CLASS.DuckSpeed = 0.2 CLASS.JumpPower = 200 CLASS.PlayerModel = "models/player/breen.mdl" CLASS.DrawTeamRing = true CLASS.DrawViewModel = true CLASS.CanUseFlashlight = true CLASS.MaxHealth = 10000 CLASS.StartHealth = 10000 CLASS.StartArmor = 0 CLASS.RespawnTime = 0 CLASS.DropWeaponOnDie = false CLASS.TeammateNoCollide = false CLASS.AvoidPlayers = false CLASS.Selectable = false CLASS.FullRotation = false function CLASS:Loadout( pl ) pl:Give( "weapon_crowbar" ) end player_class.Register( "Boss", CLASS ) [/lua] and your "player" class would be something like: [lua] local CLASS = {} CLASS.DisplayName = "Player" CLASS.WalkSpeed = 400 CLASS.CrouchedWalkSpeed = 0.2 CLASS.RunSpeed = 600 CLASS.DuckSpeed = 0.2 CLASS.JumpPower = 200 CLASS.PlayerModel = "models/player/breen.mdl" CLASS.DrawTeamRing = true CLASS.DrawViewModel = true CLASS.CanUseFlashlight = true CLASS.MaxHealth = 100 CLASS.StartHealth = 100 CLASS.StartArmor = 0 CLASS.RespawnTime = 0 CLASS.DropWeaponOnDie = false CLASS.TeammateNoCollide = false CLASS.AvoidPlayers = false CLASS.Selectable = false CLASS.FullRotation = false function CLASS:Loadout( pl ) pl:Give( "weapon_smg1" ) end player_class.Register( "Player", CLASS ) [/lua]
OK. one final question, where do I put the class files? [editline]28th July 2012[/editline] "and set the player to the boss class on the round start using the code I gave on the last post." In the code on the last post, it says "SetTeam(2)" how would I change it for classes?
how can i make it so prop gibs are spawned only on the client? or disable prop_physics gibbing altogether? when i break a prop_physics it spawns more prop_physics nearby that only seem to fade once the client has interacted with them. it's messing up a prop detection script i have and plus gibs can pile up and mess with performance so i'd rather disable them altogether.
How do people blur the background behind a transparent derma such as what I have here: [lua] //Create a local variable to store our Derma local mainWindow //Add the concommand to open the Derma concommand.Add('+mainwindow', function() //Making the DFrame mainWindow = vgui.Create( 'DFrame' ) mainWindow:SetPos( ScrW() / 2 - 250, ScrH() / 2 - 250 ) mainWindow:SetSize( 500, 500 ) mainWindow:SetDraggable( false ) mainWindow:SetVisible( true ) mainWindow:SetTitle( 'mainWindow' ) mainWindow:ShowCloseButton( false ) mainWindow:MakePopup() mainWindow.Paint = function() surface.SetDrawColor( 0, 0, 0, 150 ) surface.DrawRect( 0, 0, mainWindow:GetWide(), mainWindow:GetTall() ) surface.SetDrawColor( 0 ,0, 0, 255 ) surface.DrawOutlinedRect( 0, 0, mainWindow:GetWide(), mainWindow:GetTall() ) surface.SetDrawColor( 0, 0, 0, 255 ) surface.DrawRect( 1, 1, mainWindow:GetWide() - 2, 22 ) end end) //Add concommand to close the Derma concommand.Add('-mainwindow', function() mainWindow:Remove() end) [/lua] Also what would be a good way to draw big text onto a derma? End aim is to make a ping/fps meter. Im still learning
nvm found it
[QUOTE=usa;36984447]How do people blur the background behind a transparent derma such as what I have here: [lua] //Create a local variable to store our Derma local mainWindow //Add the concommand to open the Derma concommand.Add('+mainwindow', function() //Making the DFrame mainWindow = vgui.Create( 'DFrame' ) mainWindow:SetPos( ScrW() / 2 - 250, ScrH() / 2 - 250 ) mainWindow:SetSize( 500, 500 ) mainWindow:SetDraggable( false ) mainWindow:SetVisible( true ) mainWindow:SetTitle( 'mainWindow' ) mainWindow:ShowCloseButton( false ) mainWindow:MakePopup() mainWindow.Paint = function() surface.SetDrawColor( 0, 0, 0, 150 ) surface.DrawRect( 0, 0, mainWindow:GetWide(), mainWindow:GetTall() ) surface.SetDrawColor( 0 ,0, 0, 255 ) surface.DrawOutlinedRect( 0, 0, mainWindow:GetWide(), mainWindow:GetTall() ) surface.SetDrawColor( 0, 0, 0, 255 ) surface.DrawRect( 1, 1, mainWindow:GetWide() - 2, 22 ) end end) //Add concommand to close the Derma concommand.Add('-mainwindow', function() mainWindow:Remove() end) [/lua] Also what would be a good way to draw big text onto a derma? End aim is to make a ping/fps meter. Im still learning[/QUOTE] If I can remember correctly you can't blur backgrounds on a painted panel?
[QUOTE=usa;36984447]How do people blur the background behind a transparent derma such as what I have here:[/QUOTE] [lua]local matBlurScreen = Material( "pp/blurscreen" ) function _R.Panel:DrawBackgroundBlur( blurAmnt ) blurAmnt = blurAmnt or 5 surface.SetMaterial( matBlurScreen ) surface.SetDrawColor( 255, 255, 255, 255 ) local x, y = self:LocalToScreen( 0, 0 ) for i=0.33, 1, 0.33 do matBlurScreen:SetMaterialFloat( "$blur", blurAmnt * i ) render.UpdateScreenEffectTexture() surface.DrawTexturedRect( x * -1, y * -1, ScrW(), ScrH() ) end end[/lua]
[QUOTE=Kopimi;36983027]how can i make it so prop gibs are spawned only on the client? or disable prop_physics gibbing altogether? when i break a prop_physics it spawns more prop_physics nearby that only seem to fade once the client has interacted with them. it's messing up a prop detection script i have and plus gibs can pile up and mess with performance so i'd rather disable them altogether.[/QUOTE] You probs need to mess with the EntityTakeDamage hook and [b][url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index6d8e.html]Entity.GibBreakClient [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
What do I go about doing for sending a large usermessage? I'm using glon.encode and tables can get pretty large.
-snip- Wiki was wrong and outdated. :<
[QUOTE=jrj996;36987232]What do I go about doing for sending a large usermessage? I'm using glon.encode and tables can get pretty large.[/QUOTE] In gmod 12 use datastream. In gmod 13 use the net library.
Also consider whether you really really need to send so much data to the client.
On an old clan server of mine, they added a sign into the map (not via sourceSDK because there was no map change, must have been lua). This sign allowed VIPs to pass through it but didn't allow guests. Can anybody help me to determine how to check this? I know plycheckgroup etc. but I'm wondering how they made a physical sign that allowed no collision depending on a players UserGroup in lua? If this is too difficult, on SourceSDK how can I make a trigger_teleport check for the usergroup in ULX? Is there any way? Would anybody know how to do this? Or to help me with this? Many thanks in advance!
You can use ShouldCollide([URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8483.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8483.html[/URL]) hook to check if one entity is the player and if the other entity is that sign, you then check if the player in the correct group and return false if he is so he can walk right through it.
[QUOTE=TOMASAS;36990248]You can use ShouldCollide([URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8483.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8483.html[/URL]) hook to check if one entity is the player and if the other entity is that sign, you then check if the player in the correct group and return false if he is so he can walk right through it.[/QUOTE] So like [code]local function ShouldCollideTestHook( ent1, ent2 ) if ( ent1:IsPlayer() and ent1:CheckGroup("vip") and ent2:IsPlayer() ) then return false end end hook.Add( "ShouldCollide", "ShouldCollideTestHook", ShouldCollideTestHook )[/code] I know for a fact that isn't fully correct, but can anyone fix that up a little? I can make the entity of the barrier myself
I figure it might be more useful to ask here, as opposed to bumping the thread I made. It's a pretty simple issue. [url]http://facepunch.com/showthread.php?t=1201466[/url]
[CODE] local function ShouldCollideTestHook( ent1, ent2 ) if ((ent1:IsPlayer() and ent1:CheckGroup("vip")) and ent2.SignWall) or (ent1.SignWall and (ent2:IsPlayer() and ent2:CheckGroup("vip"))) then return false end end hook.Add( "ShouldCollide", "ShouldCollideTestHook", ShouldCollideTestHook )[/CODE] This should work, assuming you set a variable called SignWall on the sign wall entity.
[IMG]http://puu.sh/MMp2[/IMG] Does anyone know how the controls on the propertysheet are done? Like the 'create', 'join' and 'management' parts.
[url]http://glua.me/bin/?path=/lua/vgui[/url] The source for most if not all of derma.
Alright, this has me stumped. Assume I'm trying to search a string for any occurrences of weapon names in the form of "weapon_*". Obviously, string.gmatch is my best option, but why does this code not work properly? [CODE] print( args[1] ) for k, v in string.gmatch( args[1], "^weapon_%a+" ) do print( v ) ply:Give( v ) end[/CODE] And yes, args[1] prints a valid entity name. Is there a problem with my pattern?
[QUOTE=randomscript;36992533]Alright, this has me stumped. Assume I'm trying to search a string for any occurrences of weapon names in the form of "weapon_*". Obviously, string.gmatch is my best option, but why does this code not work properly? [CODE] print( args[1] ) for k, v in string.gmatch( args[1], "^weapon_%a+" ) do print( v ) ply:Give( v ) end[/CODE] And yes, args[1] prints a valid entity name. Is there a problem with my pattern?[/QUOTE] gmatch doesn't like the ^. [editline]29th July 2012[/editline] [code]/home/lexi % lua Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio > a = "weapon_test" > b = "(weapon_%a+)" > =string.find(a,b) 1 11 weapon_test > =string.gmatch(a,b)() weapon_test[/code] [editline]29th July 2012[/editline] Also there's no key in string.gmatch's returns. it's just for match in string.gmatch(...) do [editline]29th July 2012[/editline] unless you've got multiple capture groups, in which case it's for match1,match2,match3 in string.gmatch(...) do
[QUOTE=Lexic;36993267]gmatch doesn't like the ^. [editline]29th July 2012[/editline] [code]/home/lexi % lua Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio > a = "weapon_test" > b = "(weapon_%a+)" > =string.find(a,b) 1 11 weapon_test > =string.gmatch(a,b)() weapon_test[/code][/QUOTE] Tried replacing my code with [CODE]for k, v in string.gmatch( args[1], "(weapon_%a+)" ) do[/CODE] Errored when I tried triggering the entity in question, printed this in console [CODE]weapon_crowbar weapon_pistol nil [@addons\testing\lua\entities\sent_dispensary\init.lua:37] bad argument #1 to 'Give' (string expected, got nil)[/CODE] [editline]29th July 2012[/editline] That fixed it right up, thanks!
[QUOTE=Lexic;36993267] [editline]29th July 2012[/editline] Also there's no key in string.gmatch's returns. it's just for match in string.gmatch(...) do [editline]29th July 2012[/editline] unless you've got multiple capture groups, in which case it's for match1,match2,match3 in string.gmatch(...) do[/QUOTE]
First time coding in LUA. [CODE]if LocalPlayer():KeyDown(IN_JUMP) then PrintMessage(HUD_PRINTCENTER, 'You jumped!') end [/CODE] I just want a message to be displayed when I push spacebar. Loaded this code through the gmod console with no errors, but when i push space, nothing happens.
[QUOTE=lawlavex;36994251]First time coding in LUA. [CODE]if LocalPlayer():KeyDown(IN_JUMP) then PrintMessage(HUD_PRINTCENTER, 'You jumped!') end [/CODE] I just want a message to be displayed when I push spacebar. Loaded this code through the gmod console with no errors, but when i push space, nothing happens.[/QUOTE] You could message them with LocalPlayer():ChatPrint('You jumped!'). Add a Think hook aswell or a timer. Think: [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2902.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2902.html[/URL] Timer.Create: [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index9643.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index9643.html[/URL] Actually it's: LocalPlayer():PrintMessage(HUD_PRINTCENTER, 'You jumped!')
[QUOTE=brandonj4;36994479]You could message them with LocalPlayer():ChatPrint('You jumped!').[/QUOTE] His code only runs once rather than when a hook is called.
Im trying to figure out how this affects the weapon hold types of a swep, because im trying to fix the hold types local ActIndex = {} ActIndex["pistol"] = ACT_HL2MP_IDLE_PISTOL ActIndex["smg"] = ACT_HL2MP_IDLE_SMG1 ActIndex["grenade"] = ACT_HL2MP_IDLE_GRENADE ActIndex["ar2"] = ACT_HL2MP_IDLE_AR2 ActIndex["shotgun"] = ACT_HL2MP_IDLE_SHOTGUN ActIndex["rpg"] = ACT_HL2MP_IDLE_RPG ActIndex["physgun"] = ACT_HL2MP_IDLE_PHYSGUN ActIndex["crossbow"] = ACT_HL2MP_IDLE_CROSSBOW ActIndex["melee"] = ACT_HL2MP_IDLE_MELEE ActIndex["slam"] = ACT_HL2MP_IDLE_SLAM ActIndex["normal"] = ACT_HL2MP_IDLE ActIndex["knife"] = ACT_HL2MP_IDLE_KNIFE ActIndex["sword"] = ACT_HL2MP_IDLE_MELEE2 ActIndex["passive"] = ACT_HL2MP_IDLE_PASSIVE ActIndex["fist"] = ACT_HL2MP_IDLE_FIST
I tried that, and still, nothing happened. Should I be in multiplayer for it to work? Here's the new code: [CODE]if LocalPlayer():KeyDown(IN_JUMP) then LocalPlayer():ChatPrint('You Jumped') end[/CODE] Am I missing something? EDIT: Added a hook, now i got an error saying [lua\msg.lua:5] '<eof>' expected near 'end'
[QUOTE=lawlavex;36994592]I tried that, and still, nothing happened. Should I be in multiplayer for it to work? Here's the new code: [CODE]if LocalPlayer():KeyDown(IN_JUMP) then LocalPlayer():ChatPrint('You Jumped') end[/CODE] Am I missing something? EDIT: Added a hook, now i got an error saying [lua\msg.lua:5] '<eof>' expected near 'end'[/QUOTE] Show all of your code instead of the block of 3 lines.
Here's the full code [CODE]hook.Add("Think", "spacebar", jump) if LocalPlayer():KeyDown(IN_JUMP) then LocalPlayer():PrintMessage(HUD_PRINTCENTER, 'You Jumped') end end[/CODE]
Sorry, you need to Log In to post a reply to this thread.