• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
Exactly as Blasteh says. CLIENT and SERVER execute independently of one another. Just because something is shared doesn't mean it executes on both at the same time or affects the other, it simply means both realms have access to that variable name; even the memory address / reference will be different. There are hooks that do get called on both client and server at near-enough of around the same time that we can say they are executed simultaneously but they aren't. SetupMove for example is used by both client and server so what ever you do there ( as long as the file is in shared realm ) will happen on both. My realm doc goes into more depth: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_tutorial_quizzes/explanation_of_realms.lua.html[/url] [editline]18th March 2015[/editline] [QUOTE=Vipes;47347466]Someone wrote an ambiance script for me, and I'm having some problem with it. The problem might be me though. As for the error [code][ERROR] lua/autorun/client/ambiance.lua:146: attempt to index global 'ambientScript' (a nil value) 1. unknown - lua/autorun/client/ambiance.lua:146[/code][/QUOTE] Change ambientScript to ambient Note: Actually, change: [code]for i = 1, #_sounds do ambientScript.addSound( _sounds[ i ] ) end if (not _playing) then ambientScript.playSounds( ) _playing = true end [/code] to [code]for i = 1, #_sounds do ambient.addSong( _sounds[ i ] ) end if (not _playing) then ambient.playSongs( ) _playing = true end [/code]
-snip-
So I'm trying to derive DListView, because pasting my custom paint method every time I want to use a DListView in my menus would be kinda inelegant. So far, so good; I'm gonna skip pasting the paint method code and other such stuff since I've already checked and it's all unrelated to the problem I'm facing: [CODE]local RListView = {} derma.DefineControl( "RListView", "Data View", RListView, "DListView" )[/CODE] Pretty straight-forward. However, even if I use that exact code, this is the result I'm getting: [IMG]http://i.imgur.com/IQ1opot.png[/IMG] Now, I'm not really a fan of weird buttons appearing out of nowhere. I'd much rather have the derived element [url=http://i.imgur.com/p2AMk4q.png]look just like the original[/url]. Any idea what might be causing that surplus button to appear, or perhaps how I could look into debugging it? Something that might help me determine which elements I've actually got on my screen, maybe?
[QUOTE=CodingBeast;47326777]I use a custom font in one of my scripts. It works fine for me but for most of the people using it the font downloads but doesn't work. The font is located in resources/fonts/fairview-smallcaps.otf and here is the code i use to generate the font: [LUA]--[[--------------------------------------------------------- Name: Fonts -----------------------------------------------------------]] local function CreateHUDFonts( i, font, name, weight ) --> Size local CurrentFontSize = 12 + i * 2 --> Create surface.CreateFont( name .. CurrentFontSize, { font = font, size = CurrentFontSize, weight = weight, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, }) end --[[--------------------------------------------------------- Name: Font Loop -----------------------------------------------------------]] for i=1,20 do --> Crete Fonts CreateHUDFonts( i, "Fairview-SmallCaps", "TCB_Premium_Fairview_", 100 ) end[/LUA] And yes it added to the download list: [LUA]--[[--------------------------------------------------------- Name: Download Fonts -----------------------------------------------------------]] resource.AddSingleFile( "resource/fonts/fairview-smallcaps.otf" )[/LUA] Does any of you know what could cause this issue?[/QUOTE] Anyone know a fix for this issue?
When you open the file in windows font viewer, does this part [t]http://i.imgur.com/jCeA2Ue.png[/t] say "Fairview-SmallCaps"? [editline]ee[/editline] Is there any way I can get the server's current gamemode on the client while addons are still loading? I'm attempting to prevent gamemode-specific addons from loading when the gamemode isn't correct, but I can't get the client part figured out.
[QUOTE=zerf;47350031][/QUOTE] [CODE]GetConVar('gamemode'):GetString()[/CODE] or [CODE]engine.ActiveGamemode()[/CODE]
- snip: i dont even read things -
[code] function SWEP:DrawHUD() local oldRT = render.GetRenderTarget( ) local rt = GetRenderTarget( "scopeRT", ScrH( ) / 3, ScrH( ) / 3 ) local rtMat = CreateMaterial( "scopeRTMat", "UnlitGeneric", { ["$basetexture"] = scopeRT } ) render.SetRenderTarget( rt ) render.SetViewPort( 0, 0, ScrW( ), ScrH( ) ) render.Clear( 0, 0, 0, 255 ) local CamData = {} CamData.angles = LocalPlayer():EyeAngles() CamData.origin = LocalPlayer():EyePos( ) CamData.x = 0 CamData.y = 0 CamData.w = ScrW() / 3 * 2 CamData.h = ScrH() / 3 * 2 CamData.fov = 30 CamData.drawhud = false CamData.drawviewmodel = false CamData.dopostprocess = false render.RenderView( CamData ) render.SetRenderTarget( oldRT ) render.SetViewPort( 0, 0, ScrW( ), ScrH( ) ) surface.SetTexture( rtMat ) surface.SetDrawColor( 255, 255, 255, 255 ) surface.DrawTexturedRect( ScrW( ) / 2 - ScrH( ) / 3, ScrH( ) / 6, ScrH( ) / 3 * 2, ScrH( ) / 3 * 2 ) end[/code] Results in: [code][ERROR] gamemodes/anathema/entities/weapons/awb_base/shared.lua:689: bad argument #1 to 'SetTexture' (number expected, got userdata) 1. SetTexture - [C]:-1 2. unknown - gamemodes/anathema/entities/weapons/awb_base/shared.lua:689 [/code] What's wrong?
You're looking for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/SetMaterial]surface.SetMaterial[/url], SetTexture is for hl2 defined gui elements.
Why does Tracenormal keep returning 'nil' in this simple script (it's for a STool)? [CODE] local Tracenormal = nil function TOOL:LeftClick( trace ) Tracenormal = trace.HitNormal return true end function TOOL:Think() if not Tracenormal == nil then print("TRACETEST:",Tracenormal) end end [/CODE] Is it because the tool is trying to find a function or var called 'trace.HitNormal'? By the way, the point of this tool is to pull the player toward whatever it hits, and I'm trying to use trace.HitNormal to do so- with something like this- [CODE] if not Tracenormal == nil then self:GetOwner():SetVelocity( Tracenormal * -1000 ) [/CODE] [editline]19th March 2015[/editline] I'd rather not use global variables if I don't have to, by the way.
Hello. I am having trouble with the include function. For some reason when I tr y to include a specific file on my server,it works perfectly, but on other servers it prints this: [CODE] Couldn't include file 'autorun\test\sh_mainconfig.lua' (File not found) Even though I am using a function which detects the file automatically. [/CODE] Could it be the difference of the OS? Mine I'd Linux, Thiers is Linux. No caps in the folders.
How does one make a 3d2d text display above an entity, and always facing the player's face?
[QUOTE=RedNinja;47354520]How does one make a 3d2d text display above an entity, and always facing the player's face?[/QUOTE] Which player? If it should use the player whose head it is over then use GetAngles from the player. If you want it to face the LocalPlayer that is drawing it over other players heads then just use the LocalPlayer GetAngles and add 180 to the yaw. Alternatively you can use RotateAroundAxis. You could also simply use local _x, _y = Vector( 0, 0, 0 ):ToScreen( ); -- where 0 0 0 becomes the player GetPos and you add value to 3rd 0 ( z ) to raise it up over the head... Then when you use _x and _y in your HUDPaint / draw text call, it'll always face the LocalPlayer and it'll get larger / smaller based on distance ( same with the cam.Start.... )
[QUOTE=Acecool;47354879]Which player? If it should use the player whose head it is over then use GetAngles from the player. If you want it to face the LocalPlayer that is drawing it over other players heads then just use the LocalPlayer GetAngles and add 180 to the yaw. Alternatively you can use RotateAroundAxis. You could also simply use local _x, _y = Vector( 0, 0, 0 ):ToScreen( ); -- where 0 0 0 becomes the player GetPos and you add value to 3rd 0 ( z ) to raise it up over the head... Then when you use _x and _y in your HUDPaint / draw text call, it'll always face the LocalPlayer and it'll get larger / smaller based on distance ( same with the cam.Start.... )[/QUOTE] I actually meant it to face the player's screen whenever he looks at it. It will be above an entity.
How do i convert SetNWString to net messages? Exemple this to net message? [code] self:SetNWString("Text"..i, "") self:SetNWInt("r"..i, 255) self:SetNWInt("g"..i, 255) self:SetNWInt("b"..i, 255) self:SetNWInt("a"..i, 255) self:SetNWInt("size"..i, 50) [/code]
[QUOTE=PwndKilled;47355242]How do i convert SetNWString to net messages? Exemple this to net message? [code] self:SetNWString("Text"..i, "") self:SetNWInt("r"..i, 255) self:SetNWInt("g"..i, 255) self:SetNWInt("b"..i, 255) self:SetNWInt("a"..i, 255) self:SetNWInt("size"..i, 50) [/code][/QUOTE] Don't bother, the crashes will be fixed.
[QUOTE=Robotboy655;47355276]Don't bother, the crashes will be fixed.[/QUOTE] Actually that code isn't very good because of that ..i there which suggests it's in the loop, if loop has too many iterations it may use quite a lot of entries in stringtable and make that 4096 limit easier to hit.
[QUOTE=Robotboy655;47355276]Don't bother, the crashes will be fixed.[/QUOTE] Alright, thx mate
Basically it wont recognize my entity, though when i make an error it does notify in console. When i'm trying to create it simply doesnt know the class. What can i do?
Is there a way to get what key a player has something bound to clientside? Specifically, I want to know which key a players flashlight is bound to.
[QUOTE=Drakehawke;47356259]Is there a way to get what key a player has something bound to clientside? Specifically, I want to know which key a players flashlight is bound to.[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/input/LookupBinding]input.LookupBinding[/url] argument: "impulse 100" (tested and working) [QUOTE=swadicalrag;47352933][CODE]GetConVar('gamemode'):GetString()[/CODE] or [CODE]engine.ActiveGamemode()[/CODE][/QUOTE] GetConVar():GetString returns the client's selected gamemode at the time. engine.ActiveGamemode() returns base at the time.
Can someone explain the CurTime to me ? i dont really get the concept in sweps they use it to delay the primary or secondary fire like ((CurTime()+ 0.5 ) why does it delay it ? isnt the curtime the time passed from the servers start if it means that and lets say the server has been running for 400 seconds and player wants to fire the swep again and shouldnt he be waiting 400.5 seconds to fire again ? can someone explain with details im gonna go insane because of ths
[code] [ERROR] addons/cw2/lua/cw/shared/cw_attachmentpossession.lua:14: Tried to use a NULL entity! 1. __newindex - [C]:-1 2. initCWVariables - addons/cw2/lua/cw/shared/cw_attachmentpossession.lua:14 3. postSpawn - addons/cw2/lua/cw/shared/cw_attachmentpossession.lua:53 4. unknown - addons/cw2/lua/cw/server/cw_hooks.lua:3 Timer Failed! [Simple][@addons/cw2/lua/cw/server/cw_hooks.lua (line 2)] [/code] Randomly happening really driving me crazy [ERROR] lua/includes/modules/net.lua:103: bad argument #1 to 'pairs' (table expected, got nil) net.WriteTable( sell.damage )
[QUOTE=shootbysteve;47357146]Can someone explain the CurTime to me ? i dont really get the concept in sweps they use it to delay the primary or secondary fire like ((CurTime()+ 0.5 ) why does it delay it ? isnt the curtime the time passed from the servers start if it means that and lets say the server has been running for 400 seconds and player wants to fire the swep again and shouldnt he be waiting 400.5 seconds to fire again ? can someone explain with details im gonna go insane because of ths[/QUOTE] You're right that [URL="http://wiki.garrysmod.com/page/Global/CurTime"]CurTime()[/URL] returns the value of time from the server's start. [URL="http://wiki.garrysmod.com/page/Weapon/SetNextPrimaryFire"]SetNextPrimaryFire[/URL] also uses that value. From my understanding, SetNextPrimaryFire gets the current time (CurTime), and checks it to the value given (Usually something like CurTime()+0.5). If the number provided is larger than CurTime(), then it prevents the SWEP from shooting again. Conversely, if the number provided is smaller than CurTime(), then it allows the weapon to shoot.
-snip-
Having an issue with a grenade I'm working with. I got all the animations to play when I want them but now when you go to throw the grenade it wont actually throw. (Doesn't print hi either) [lua] function SWEP:PrimaryAttack() self:SetNextPrimaryFire( CurTime() + 3 ) self.Weapon:SendWeaponAnim( ACT_VM_PULLPIN ) timer.Simple( 1, function() self.Weapon:SendWeaponAnim( ACT_VM_THROW ) end ) end function SWEP:GetGrenadeName() print("hi") return "ttt_gimnade_proj" end [/lua] I haven't modified ttt_gimnade_proj which was working before I added the SWEP:PrimaryAttack() function recently in order to add animations. Any ideas? Thanks Edit: Also, anyone know why I would be able to use the Last Used Weapon bind to go to my weapon but not to go from it to another weapon? Thanks
[QUOTE=YourStalker;47359085]Having an issue with a grenade I'm working with. I got all the animations to play when I want them but now when you go to throw the grenade it wont actually throw. (Doesn't print hi either) [lua] function SWEP:PrimaryAttack() self:SetNextPrimaryFire( CurTime() + 3 ) self.Weapon:SendWeaponAnim( ACT_VM_PULLPIN ) timer.Simple( 1, function() self.Weapon:SendWeaponAnim( ACT_VM_THROW ) end ) end function SWEP:GetGrenadeName() print("hi") return "ttt_gimnade_proj" end [/lua] I haven't modified ttt_gimnade_proj which was working before I added the SWEP:PrimaryAttack() function recently in order to add animations. Any ideas? Thanks Edit: Also, anyone know why I would be able to use the Last Used Weapon bind to go to my weapon but not to go from it to another weapon? Thanks[/QUOTE] Youre overriding PrimaryAttack. Doesnt grenadebase use PrimaryAttack? Can never remember if it uses that or Think
Why would this only draw a white square on the screen? [code] function SWEP:DrawHUD() local oldRT = render.GetRenderTarget( ) local rt = GetRenderTarget( "scopeRT", ScrH( ) / 3, ScrH( ) / 3 ) local rtMat = CreateMaterial( "scopeRTMat", "UnlitGeneric", { ["$basetexture"] = "scopeRT" } ) render.SetRenderTarget( rt ) render.SetViewPort( 0, 0, ScrW( ), ScrH( ) ) render.Clear( 0, 0, 0, 255 ) local CamData = {} CamData.angles = LocalPlayer( ):EyeAngles( ) CamData.origin = LocalPlayer( ):EyePos( ) CamData.x = 0 CamData.y = 0 CamData.w = ScrW( ) / 3 * 2 CamData.h = ScrH( ) / 3 * 2 CamData.fov = 30 CamData.drawhud = false CamData.drawviewmodel = false CamData.dopostprocess = false render.RenderView( CamData ) render.SetRenderTarget( oldRT ) render.SetViewPort( 0, 0, ScrW( ), ScrH( ) ) surface.SetDrawColor( 255, 255, 255, 255 ) surface.SetMaterial( rtMat ) surface.DrawTexturedRect( ScrW( ) / 2 - ScrH( ) / 3, ScrH( ) / 6, ScrH( ) / 3 * 2, ScrH( ) / 3 * 2 ) end[/code]
Ik this has been asked 100 times, but how would you go about setting the material of a weapon. Like a skin.
Does anyone know how i can search for mounted game contents from serverside? Clientside it works but oddly, serverside (dedicated server) it does not. CLIENTSIDE [lua] PrintTable({file.Find("models/items/*", "cstrike" )})... { 1: { 1 = cs_gift.dx80.vtx 2 = cs_gift.dx90.vtx 3 = cs_gift.mdl 4 = cs_gift.phy 5 = cs_gift.sw.vtx 6 = cs_gift.vvd } 2: { } } [/lua] SERVERSIDE [lua] PrintTable({file.Find("models/items/*", "cstrike" )})... { 1: { } 2: { } } [/lua] The ID argument seems to only work on client :/ Is there a solution to this?
Sorry, you need to Log In to post a reply to this thread.