• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
What's the easiest way to slectively send certain files to some clients, but not others? For example, say I had an admin menu and only wanted staff members to be sent the files that contain it, and not just send it to every user that connects to the server. Is it possible to individually Include() files for clients? It seems like using AddCSLuaFile only marks the file to be sent to clients upon joining the server, so that wouldn't work in this application. Is it even feasible to selectively send lua from the server to the client and have them run it, or should I be looking at some way of hosting the file as text somewhere and then HTTP fetching it? I'm a bit clueless about this.
You cannot selectively AddCSLuaFile - you would either have to network the file string to the client after they join or fetch it with HTTP.
Hey, I want to make a bullet-like SENT that doesn't obey gravity but the constantly moves in the direction supplied when spawned and at a constant speed, in a smooth, not-jerky fashion. I dont ask for too much code, just a point in the right direction. I thought It could work like this ent:Spawn ent:CustomFunctionForSettingDirection(dir)--- or ent.Direction = dir
PhysObj/ComputeShadowControl
You could also just disable gravity and air drag give it a push in the direction you want.
is there a way to get or designate the first 3 columns in a DPanel if I'm using "draw.RoundedBox" to draw the columns? (Scoreboard) For example I know by default the game sorts the players by how many frags they have so if I just wanted the DPanel to do 'x' if 'top 3 players' how would I do that with draw.RoundedBox'es? I've looked into: Category But I don't want to over complicate the code if I don't have to. I'm looking for something that functions like for i = 1, 3 do layout:Add( Label( "Best Players" .. i ) ) end but for draw.RoundedBox
for i = 1, 3 do local p = vgui.Create("Panel") function p:Paint(w,h) draw.RoundedBox(4,0,0,w,h,color_white) end layout:Add( p ) end
how would i go on about adding client:Health() etc to the draw.RoundedBox? function OGNHud() local client = LocalPlayer() if not client:Alive() then return end if (client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == "Camera") then return end   draw.RoundedBox(0,30,600,300,135,Color(86,86,86,200)) draw.RoundedBox(0,40,610,185,25,Color(255,0,0,200)) draw.RoundedBox(0,40,645,185,25,Color(0,0,255,200)) draw.RoundedBox(0,40,680,185,25,Color(34,139,34,200)) draw.SimpleText("Health: "..client:Health() .. "%", "Times", 45, 612, Color(255, 255, 255, 255), 0, 0) draw.SimpleText("Armor: "..client:Armor() .. "%", "Times", 45, 647, Color(255, 255, 255, 255), 0, 0) draw.SimpleText("Hunger: "..client:Armor() .. "%", "Times", 45, 682, Color(255, 255, 255, 255), 0, 0) end hook.Add("HUDPaint", "OGNHud", OGNHud)
Set the box width to math.max(Health, 0) / MaxHealth * MaxWidth Some other code tips: Make your OGNHud function local You should use GetActiveWeapon:IsValid() instead of NULL comparisons You need to use GetClass on the weapon to do comparisons with the class name. Also, did you mean gmod_camera for the SWEP name?
I was on a website and was told that It would be smart to add the camera thing, Im just gonna remove it lmao thanks!
If I do that it ends up creating a new panel how would I make it so that it counts the draw.RoundedBoxes for this code? for k,v in pairs(player.GetAll()) do local PlayerPanel = vgui.Create("DPanel", PlayerList) PlayerPanel:SetSize(PlayerList:GetWide(), 100) PlayerPanel:SetPos(0,0) PlayerPanel:SizeToContents() --PlayerPanel:SetWrap( true ) PlayerPanel.Paint = function() local score = v:Frags() * 200 - v:Deaths() * 300 --v is the player. draw.RoundedBox( 0, 0, 50, PlayerPanel:GetWide(), PlayerPanel:GetTall(), Color( 50, 50, 50, 255)) draw.SimpleText(v:GetName().." Score: "..score,"Default2", 50, 69, Color(255, 255, 255 )) end I'm guessing something along the lines of "for i = 1, 3 do" somewhere at the top where "k,v in pairs" I just don't know how to word it because I don't want it to only draw 3 rounded boxes I just want it to count the first three and add something to those first 3. Sorry for the headache
Worked enough for me but neat function code_gs. Only problem now is that it has a trail Anderson disappears on collision, frame before deletion and the trail moves a bit. A little annoying but wouldn't be nice to solve. ALSO Level 10! Been waiting too lonng
Having trouble with NPC's I create. They refuse to shoot at me after setting the target/enemy and giving them a weapon. I'm trying to make it actually shoot at me after they are spawned, but they just aim at my direction, but doesn't shoot. They will hit me if I move too close though. local npccop = ents.Create( "npc_combine_s" ) npccop:SetPos( TheVector ) npccop:SetAngles( TheAngle ) npccop:Give( table.Random( BANK2_NPCCOPS_RandomWeapons ) ) npccop:SetSaveValue( "m_vecLastPosition", ply:GetPos() ) npccop:SetSchedule( SCHED_FORCED_GO )                 npccop:SetEnemy( ply ) npccop:SetTarget( ply ) npccop:Spawn() Seems pretty strange :/ Was hoping someone has had this problem before, or can guide me in some direction from here.
So I need to execute some code with NW2Vars in a PlayerTick hook, to take advantage of prediction. However, I don't want it to run every player tick, I want to skip some ticks. If I do that, will prediction still work? I ask that because the tick where stuff is processed may not be the same as the server.
Try setting schedule and target before spawning
Trying to make a death screen for my server, I have this: function playerDies( victim, weapon, killer )     draw.RoundedBox(0,0,0,5000,200,Color(0,0,0,255)) draw.RoundedBox(0,0,850,5000,200,Color(0,0,0,255)) draw.SimpleText("You have died. Press F2 in <time> seconds to respawn.","Times30",350,80,Color(255,255,255,255),5,5) draw.SimpleText("You can wait for an ERU to revive you. If you were RDMed, you can call and admin by saying '@' followed by your message in chat.","Times20",150,925,Color(255,255,255,255),5,5) local tab = {} tab[ "$pp_colour_colour" ] = 0.20 tab[ "$pp_colour_contrast" ] = 1   DrawColorModify( tab )  RunConsoleCommand("cl_drawhud","0") end   hook.Add( "PlayerDeath", "playerDeathTest", playerDies ) but it doesn't seem to work, any suggestions?
Could you give the specific instance?
I'm working on a stealth mod. Every player tick, the server and clients calculate the level of detection every NPC has with that client. The variable is stored in a NW2Int. I've been told those functions work well with prediction, that's why I use playertick. However, I don't want it to be calculated every playertick, I want it to have a delay using Curtime(). However, depending on when the player connects to the server, the tick where the server calculates detection may not be the same tick the client uses. I want to know if that will break prediction (I really don't know how it works).
If the calculation is shared, you could always let the client calculate the stealth level and never sync up with the server, but that would depend on your implementation.
You won't "break prediction". Just calculate it clientside and serverside and set it as often as you want on either. The system will handle the rest and make sure that the server's value overrides client whenever they're different.
I thought about that, but I was afraid that any interruption in the connection, or performance problems on the client would desync the variables. I would need to resync it periodically or something like that, it would be more complicated. Thanks again Bobblehead!
Just keep in mind that variables like the NPC's position/angles, CurTime, and player CUserCmds' will always be in sync with the server, so if you can build your logic around that then it will always stay in sync.
How can i make my health armor etc. show the health as the bar moves local function OGNHud() local client = LocalPlayer() if not client:Alive() then return end draw.RoundedBox(0,ScrW()/1280*30,ScrH()/1024*700,400,115,Color(86,86,86,200)) draw.RoundedBox(0,ScrW()/1280*40,ScrH()/1024*710,185,25,Color(255,0,0,200)) draw.RoundedBox(0,ScrW()/1280*40,ScrH()/1024*745,185,25,Color(0,0,255,200)) draw.RoundedBox(0,ScrW()/1280*40,ScrH()/1024*780,185,25,Color(34,139,34,200)) draw.SimpleText("Health: "..client:Health() .. "%", "Times", 45, 712, Color(255, 255, 255, 255), 0, 0) draw.SimpleText("Armor: "..client:Armor() .. "%", "Times", 45, 747, Color(255, 255, 255, 255), 0, 0) draw.SimpleText("Hunger: "..client:Armor() .. "%", "Times", 45, 782, Color(255, 255, 255, 255), 0, 0) end hook.Add("HUDPaint", "OGNHud", OGNHud) code_gs said to set the width to math.max(Health, 0 ) / 100*710 but it gave me this error: [ERROR] lua/hudtest.lua:41: bad argument #1 to 'max' (number expected, got nil)   1. max - [C]:-1    2. v - lua/hudtest.lua:41     3. unknown - lua/includes/modules/hook.lua:84
Health was just an example - you have to fill it in with actual code (client:Health()).
So I have been fighting with scaling for a few days with Derma and I can not figure out what the hell is wrong. I am using the scaling method listed in this guide on the wiki but I am having a problem to where it scales just fine on lower resolutions but it does not scale properly at higher resolutions. Whats even weirder is it seems like only the background DImage panel is not scaling correctly. Does anyone know how to solve this? I am pulling my hair out at this point. Below are some references of what I am experiencing. 1600x900 windowed this is what I run my gmod at when I code 1176x664 windowed 1920x1080 windowed
ah ok
If I run this on my clients such that on each client newMaterial:IsError() is false: https://files.facepunch.com/forum/upload/710/d7ae78c9-8e24-45aa-bb13-02adfaffba23/image.png And I later run this serverside on some prop: https://files.facepunch.com/forum/upload/710/08d74a97-5ecf-40b2-97be-92125a0f6f1f/image.png ... Nothing happens, the entity's material isn't set, ent:SetSubMaterial is ignored. I confirmed that Material("!".."SomeExactName"):IsError() is true on the server. Is it happening because the server thinks the material isn't loaded right? How can I fix this? The same exact code runs just fine on a pre-made material such as "models/shiny".
Is there a way to embed something like such: [code]<iframe src="https://www.twitch.tv/streamname/chat?popout=" frameborder="0" scrolling="no" height="500" width="350"></iframe> <iframe src="https://player.twitch.tv/?channel=streamname" frameborder="0" allowfullscreen="true" scrolling="no" height="378" width="620"></iframe><a href="https://www.twitch.tv/streamname?tt_content=text_link&tt_medium=live_embed" style="padding:2px 0px 4px; display:block; width:345px; font-weight:normal; font-size:10px; text-decoration:underline;">Watch live video from streamname on www.twitch.tv</a>[/code] and show it on a monitor? I suppose alternatively I could just load the webpage onto a monitor?
You can't create or use a CreateMaterial on the server. Just set it clientside on all clients.
Thanks for replying. I was creating the material separately on the client. My problem was that I was appending my own string to an existing material with "somedefaultmaterial".."myownsuffix". Apparently, that doesn't work very well and won't let you set the edited material. Changing the suffix to a prefix immediately solved it, like so: "myownprefix".."somedefaultmaterial".
Sorry, you need to Log In to post a reply to this thread.