• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
like this....? function GM:PlayerDeath(victim, inflictor, attacker) if attacker:IsPlayer() and victim:IsPlayer() and attacker ~= victim  then end attacker:SetFrags(attacker:Frags() + 1) end returns "attempt to call method 'Frags' a nil value" or function GM:PlayerDeath(victim, inflictor, attacker) if attacker:IsPlayer() and victim:IsPlayer() and attacker ~= victim  then attacker:SetFrags(attacker:Frags() + 1) end end returns no lua errors, scoreboard doesn't update.
What is your scoreboard code? Is it default?
Kind of it's basically sandbox with a new derma/text/etc. init.lua: hastebin scoreboard lua: hastebin I can provide anything else you need. Sorry I'm so damn slow at this
First of all, use this: https://hastebin.com/ubohalumuv.lua Second, do the player's frags change properly with that code? Use print(attacker:Frags()) after the player's frags are changed to see if they're properly updating. If they are, then it's an issue with your scoreboard code.
I did as you said with function GM:PlayerDeath(victim, inflictor, attacker) if attacker:IsPlayer() and victim:IsPlayer() and attacker ~= victim  then print(attacker:Frags())  end end result is no lua errors and nothing printing in console or command window. So the problem is with the scoreboard then?
It's the second; if it doesn't update then it's an issue with your scoreboard code OR you didn't put the PlayerDeath code in the correct place.
Thank you to the both of you. I can finally get some damned sleep tonight. I know it's not much but... enjoy your coins!
New question: local Frags = Player:Frags() local Deaths = Player:Deaths() -1 local score = Frags + Deaths I want score to equal Frags plus Deaths. I want Deaths to subtract points from the score. This is telling the lua to subtract 1 "nothing" if the player dies. How do I code this?
local score = Player:Frags() - Player:Deaths()
Okay but what if I wanted each Frag to give... 200 points and each death to subtract 300 points, how would I code that?
local score = Player:Frags() * 200 - Player:Deaths() * 300 All math
okay I'll give it a try, thanks again
alright after tinkering around for a little while I came up with this: local ply for k,v in pairs( player.GetAll()) do local Frags = v:Frags(200) local Deaths = v:Deaths(300) local score = v:Frags() - v:Deaths() end which I want to be called on this line draw.SimpleText(v:GetName().."score"..v:GetNWInt("playerLvl"),"Default2", 50, 69, Color(255, 255, 255 ), TEXT_ALIGN_CENTER) But I don't know how to call the actual score for "score" in the draw.SimpleText.
That's not what I'm trying to do. I'm trying to set a value for frags (it'll give you 200 points per kill) and deduct deaths (it will take away 300 points per death) to give you the value of "score".
Is there a way to removeor change a player's air acceleration? I need to prevent players from canceling out being pushed simply by moving against the push direction
I already gave you the exact code above to calculate the score.
I'm currently making a weapon switcher. What would be the appropriate way to ensure it doesn't open when another menu is open or the player is scrolling with their physgun?
Yeah sorry I was trying to see if it could be done another way, just to see if I actually understood what you wrote. In any case that looks like the simplest way to do it. I just don't know how to call 'local score' with 'draw.SimpleText'
I don't think there's a way to tell if another menu is open without checking each panel individually, but you can stop physgun scrolling by returning true in a GM/PlayerBindPress hook for invnext and invprev.
Not sure why i'm getting this error. Does it have to do with being client side? [ERROR] addons/h_fatigue/lua/autorun/client/cl_stamina.lua:14: attempt to call method 'Alive' (a nil value) 1. fn - addons/h_fatigue/lua/autorun/client/cl_stamina.lua:14 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:109 The file: local str local PLAYER = LocalPlayer() local Fatigue hook.Add( "HUDPaint", "staminaHUDThing", function() if !PLAYER:Alive() then return end if PLAYER:GetActiveWeapon() == "Camera" then return end Fatigue = PLAYER:GetNWInt( "OxygenLevel" ) //if FatigueStart then if PLAYER:WaterLevel() == 3 or PLAYER:WaterLevel() == 2 or Fatigue < 599 then draw.RoundedBoxEx(16, ScrW() / 2 - 101, ScrH() - 40 + 0.5, 202, 32, Color(125, 125, 125, 255), true, false, false, true) draw.RoundedBoxEx(16, ScrW() / 2 - 100, ScrH() - 38, 200, 30, Color( 255, ( Fatigue / 10 ) * 2.55, ( Fatigue / 10 ) * 2.55, 255 ), true, false, false, true) surface.SetFont( "Trebuchet24" ) if Fatigue < 600 && Fatigue > 200 then str = "Fatigued"  elseif Fatigue < 200 then str = "Exhausted"  else str = "" end local size = {} size.h, size.w = surface.GetTextSize( str ) draw.DrawText(str, "Trebuchet24", ScrW() / 2 - ( size.w / 2 ), ScrH() - 35, Color(255, 255, 255), TEXT_ALIGN_CENTER) end end )
This is the wrong snippet to show us. Give us the actual HUD drawing code.
What is the best way to play around with ProjectedTexture? In which clientside hooks should I Create ProjectedTexture? Update ProjectedTexture?
hook.Add("EntityEmitSound", "RemoveCobmineCameraSound", function(data) local ent = data.Entity if IsValid(ent) and ent:GetClass() == "npc_combine_camera" then data.SoundLevel = 55 // mute end end) // I want to mute the sound of the combine camera.
Have you tried returning false instead of setting the sounds level?
I want to be able to lower the sound...
But in the code comments you said you wanted to mute the sound, also you used level 55 which going off the wiki at least says "Stop the sound". If you just want to edit the sound then return true in the hook, Return true to apply all changes done to the data table.
You should treat ProjectedTextures like you would treat entities: create it only once and keep it around until you don't need it anymore, then remove it. It doesn't matter which hook you create it in, that depends on what you want to use it for. If you want it as part of a custom entity, you should create it in the entity's Initialize hook, and delete it when the entity is deleted. You should use Update only after you make any changes to it, including changing its position or angle, and including the initial set-up. On the wiki, functions that need you to call Update after them say this explicitly in their description. Again, it doesn't matter which hook this is in, just do it in the same code block where you change the Hope that helps!
Thank you for explanation
I've made some kind of a queue system for panels (they are poping one after one), but now wondering... Which way is better? Create a few panels, make them invisible until I want to show them Make a local function for each panel (which creates and returns it) and add it to queue, then just call this function when needed
Depends on if the nature of the queue allows you to frontload all the panels when the player connects or if it's more dynamic so you can't do it on initialize anyway. Best to do it in initialize unless it's a dynamic menu.
Sorry, you need to Log In to post a reply to this thread.