• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=Acecool;47232443]My recursive resource.AddSingleFile Lua file - add it and forget it.. simply add your data to your gamemodes/<gmname>/content/ folder: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_downloads_using_recursive_resource_system.lua.html[/url][/QUOTE] "The old / outdated recursive resource loader..." This implies there's a new one, where is it? By the way, Acecool, I think you need to have an index somewhere that links to every one of your guides. It should be something that people can find on their own, not something that you have to link to every time someone needs it. What if you're not around?
I'm working on bringing up my site but only having 4 hours every 48 or so means slow going... Likely going for surgery in the next few months so I'd like to have it up by then so regardless of what happens, it'll be up.
[QUOTE=Author.;47230679]Put the png picture somewhere in materials folder, and do something like this; [lua] local Mat = Material("path_to_image.png") -- want to cache OUTSIDE of loop -- inside HUDPaint hook or whatever surface.SetMaterial( Mat ) -- set the material to what we cached previously surface.SetDrawColor( 255, 255, 255 ) -- white means all colors are the colors in the picture surface.DrawTexturedRect( x, y, w, h ) -- same as surface.DrawRect draw.NoTexture() -- just in case you have anything else in here that can draw a material, very big chance you dont[/lua][/QUOTE] I seem to get a little white square This is my code I have atm [lua] function myhud() local client = LocalPlayer() if !client:Alive() then return end local DrawHealth = LocalPlayer():Health() or 0 draw.RoundedBox( 3, 5, 925, 300, 150, Color(0, 0, 0, 215)) -- Draw the base for our hud draw.RoundedBox( 3, 10, 932, (285) * DrawHealth / 100, 20, Color( 255, 0, 0, 255)) draw.SimpleText( "Health", "chatfont", 55, 931, Color( 0, 0, 0), TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM ) local Mat = Material("/materials/like80.png") surface.SetMaterial( Mat ) -- set the material to what we cached previously surface.SetDrawColor( 255, 255, 255 ) -- white means all colors are the colors in the picture surface.DrawRect( 69, 69, 200, 200 ) -- same as surface.DrawRect draw.NoTexture() -- just in case you have anything else in here that can draw a material, very big chance you dont end hook.Add("HUDPaint", "myhud", myhud) local tohide = { -- This is a table where the keys are the HUD items to hide ["CHudHealth"] = true, ["CHudBattery"] = true, ["CHudAmmo"] = true, ["CHudSecondaryAmmo"] = true } [/lua]
I'm planning on creating a HUD that tells you how much damage was dealt to a specific bodypart. Should I use ply:SetNWInt() or something else?
[QUOTE=ROFLBURGER;47234074]I'm planning on creating a HUD that tells you how much damage was dealt to a specific bodypart. Should I use ply:SetNWInt() or something else?[/QUOTE] You could just send the bodypart that was hurt via net messages, and store it clientside.
[QUOTE=Author.;47234155]You could just send the bodypart that was hurt via net messages, and store it clientside.[/QUOTE] Ok yeah found that to be more viable because I'm just sending damage and theres no easy way to detect if a value using SetNWInt has changed
How do I set a vehicle's position?
[QUOTE=Ott;47234983]How do I set a vehicle's position?[/QUOTE] Explain further so I don't just give a stupid answer like ent:SetPos() :v:
[vid]https://a.pomf.se/jilook.mp4[/vid] And yes, I am calling this serverside.
[QUOTE=Ott;47235006][vid]https://a.pomf.se/jilook.mp4[/vid] And yes, I am calling this serverside.[/QUOTE] You have to use either Spawn or Activate on it to set its position after calling SetPos. It has something to do with the server trying to keep all of its physobjs together or something random iirc.
-snip- ninja'd
After you call Spawn( ) on a vehicle, there have been some reports that bodygroups / skins / etc... may change. I haven't confirmed this but I'm just forwarding reports that were sent to me just in case it is true. I'm unable to verify it until I'm back in SC in a few days, so you may want to verify if it is in fact true, and then you may want to simply copy the data and re-apply it after moving it. It's easy enough to redirect SetPos and SetAngles just in case it is true to set up everything...
Im trying to make a simple counter for the amount of games a player has on TTT.. But every time the map resets, it recreates their record instead of adding to the previously added record. [CODE] hook.Add("TTTBeginRound", "GMGC.TTTBeginRound", function() for k, ply in pairs(player.GetAll()) do if ply:GetObserverMode() == OBS_MODE_NONE and ply:SteamID() != "BOT" then local UID = ply:UniqueID() if not GMGC.Counter[UID] then local Data = {} Data.Games = 1 Data.DisplayCount = false GMGC.Counter[UID] = Data else GMGC.Counter[UID].Games = GMGC.Counter[UID].Games + 1 end end GMGC.SaveLog() end end) [/CODE] I've checked out the text file I save the data in and I see the unique ID appear more than once..
I know you can do [code] ENT = scripted_ents.Get( "sent_thing" ) [/code] and save your changes by doing [code] scripted_ents.Register( ENT,"sent_thing" ) [/code] But it seems to only work on entities, is there something similar you can do for weapons?
[code] SWEP = weapons.Get( "weapon_thing" ) weapons.Register( SWEP ,"weapon_thing" , true ) [/code] You can also use GetStored instead of Get
[QUOTE=Jvs;47236443][code] SWEP = weapons.Get( "weapon_thing" ) weapons.Register( SWEP ,"weapon_thing" , true ) [/code] You can also use GetStored instead of Get[/QUOTE] Do you even understand how stupid I feel now?! (Thanks!)
How come this doesn't work?: [CODE]hook.Add("PlayerCanPickupItem", "restrict item pickup", function(ply, ent) local isBuilding = ply:GetNWBool("building") if isBuilding then return false ply:PrintMessage(HUD_PRINTTALK, "You cannot pick up items while in building-mode.") else return true end end)[/CODE] My error: [CODE][ERROR] addons/darkrpmodification/lua/darkrp_modules/fp_buildermode/sv_buildermode.lua:41: 'end' expected (to close 'if' at line 39) near 'ply' 1. unknown - addons/darkrpmodification/lua/darkrp_modules/fp_buildermode/sv_buildermode.lua:0 [/CODE] The sv_buildermode file is where the code is from.
Move the ply:PrintMessage above return false. Returning ends the function. You can't do anything else after it. [code] hook.Add("PlayerCanPickupItem", "restrict item pickup", function(ply, ent) local isBuilding = ply:GetNWBool("building") if isBuilding then ply:PrintMessage(HUD_PRINTTALK, "You cannot pick up items while in building-mode.") return false else return true end end)[/code]
[QUOTE=Fillipuster;47236563]How come this doesn't work?: [CODE]hook.Add("PlayerCanPickupItem", "restrict item pickup", function(ply, ent) local isBuilding = ply:GetNWBool("building") if isBuilding then return false ply:PrintMessage(HUD_PRINTTALK, "You cannot pick up items while in building-mode.") else return true end end)[/CODE] My error: [CODE][ERROR] addons/darkrpmodification/lua/darkrp_modules/fp_buildermode/sv_buildermode.lua:41: 'end' expected (to close 'if' at line 39) near 'ply' 1. unknown - addons/darkrpmodification/lua/darkrp_modules/fp_buildermode/sv_buildermode.lua:0 [/CODE] The sv_buildermode file is where the code is from.[/QUOTE] return should always be called last otherwise the code below it won't be ran. [CODE]hook.Add("PlayerCanPickupItem", "restrict item pickup", function(ply, ent) local isBuilding = ply:GetNWBool("building") if isBuilding then ply:PrintMessage(HUD_PRINTTALK, "You cannot pick up items while in building-mode.") return false -- Will stop the code here and won't execute "return true" end return true -- You can also use returns like this it looks better end)[/CODE]
So another quick question when making a hud what is it that you call for the current amount of ammo in your clip and then total amount you have left. So I know how Health is just Health() and Armor is Armor().
How do i invert mousex movement? So if you turn left you turn right and other way around basically. Ive tried some stuff with CreateMove but it doesnt seem like itll work with SetMouseX
[lua]LocalPlayer():GetActiveWeapon():Clip1()[/lua] Returns amount of ammo in primary clip.
I'm creating a chair using the prisoner pod script like this: [lua] local chair = ents.Create("prop_vehicle_prisoner_pod") chair:SetPos(pos) chair:SetAngles(rotation) chair:SetModel("models/pnati/tychochair.mdl") chair:SetKeyValue("vehiclescript", "scripts/vehicles/prisoner_pod.txt") --chair:SetKeyValue("limitview", "0") chair:Spawn() chair:Activate() chair:SetParent(gametable) --chair:GetPhysicsObject():EnableMotion(false) [/lua] Only problem is whenever I use the chair, the entry animation takes a very long time (approximately 2.3 mins). The animation seems to go to the bottom of the chair model. When I am fully in the chair my view is rotated very oddly. When I call ply:EnterVehicle(chair) my view is from the bottom of the chair model. [editline]1st March 2015[/editline] Oh dear [t]http://i.imgur.com/X9gTpxG.jpg[/t] [editline]yee[/editline] How do I set the sit?
ya thats annoying i had the same issue before never fixed it. im sure its easy to fix
[QUOTE=Xaotic;47237167]How do i invert mousex movement? So if you turn left you turn right and other way around basically. Ive tried some stuff with CreateMove but it doesnt seem like itll work with SetMouseX[/QUOTE] Use InputMouseApply or SetupMove depending on what you're trying to do. If you're trying to control the camera view, either will work. Trying to control movement, I'd go with SetupMove because it's shared. [QUOTE=Fillipuster;47236563]How come this doesn't work?: [/QUOTE] A tip on using hook.Add... you're sharing the call with other potential hook.Adds and GM: function as well. If you return non-nil, you prevent any other hook.Add or the GM function from being called. When using hook.Add, target specific behavior and only return if the hook requires it... Also, your getter doesn't have a default value -- while isBuilding should still be nil if not set, it'd good practice to use a default value as the second argument ( eg false ); the actual error has been resolved in a prior post -- making calls after a return statement..
So my friends, how would I measure the G force on a physics object? PhysObj/GetInertia and GetInvIntertia returns the same value after the initial call for some reason so it feels mighty useless. Any other way?
[QUOTE=Hoffa1337;47242062]So my friends, how would I measure the G force on a physics object? PhysObj/GetInertia and GetInvIntertia returns the same value after the initial call for some reason so it feels mighty useless. Any other way?[/QUOTE] A single g-force is just whatever the acceleration is divided by the gravity on the object. So you would most likely have to do some trickery with either the force applied to an object, or the velocity over time in order to get that acceleration value needed. As for the value of gravity, Earth is 9.8m/s^2, but I think if you do the value of sv_gravity in-game, it should be the correct value, assuming everything else is done in in-game units. 1. If you know the force on an object, and the objects mass ([IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/PhysObj/GetMass"]PhysObj:GetMass[/URL]), then you can use force divided by mass to get acceleration. 2. If you know the speed of an object at two points in time, then you can do the change in velocity divided by the time to get the acceleration. Option 1 would be your easiest bet in my opinion, but both aren't too hard to implement.
Hey, anyone know a way to disable muzzle flashes on SWEPs when a weapon event calls them? I'm having trouble figuring out how to do this. SWEP.CSMuzzleFlashes only makes the muzzle flash look strange, rather than disabling its event. Any help would be appreciated. Oh, and I've also tried viewmodel:StopParticles() and viewmodel:StopParticleEmission() or whatever that was. Neither work.
Can someone please help me with a day/night system using the painted skybox stuff? I dont need anything too fancy, just the skybox needs to have the usual sunrise/sunset/start etc, the light level in the map needs to change and I need to be able to get the hour and minute of the "day" as well as specify how long a "day" is. I should be able to do the streetlights and stuff myself. If you are interested in helping, shoot me a PM or add me on Steam or something.
I'm using the DrawBlur function from NutScript and I'm getting blurred edges (image below). How could I make these sharper (consistent colour/transparency)? [t]http://i.imgur.com/7pbLEvM.png[/t] The function: [lua] local blur = Material("pp/blurscreen") function DrawBlur(panel, amount) local x, y = panel:LocalToScreen(0, 0) local scrW, scrH = ScrW(), ScrH() surface.SetDrawColor(255, 255, 255) surface.SetMaterial(blur) for i = 1, 3 do blur:SetFloat("$blur", (i / 3) * (amount or 6)) blur:Recompute() render.UpdateScreenEffectTexture() surface.DrawTexturedRect(x * -1, y * -1, scrW, scrH) end end [/lua]
Sorry, you need to Log In to post a reply to this thread.