#recharging grenades
1 messages · Page 1 of 1 (latest)
timer.Create("youraddon_grenadecheck", 20, 0, function()
for k, v in pairs(player.GetAll()) do
v:CheckForGrenade()
end
end)
function PLAYER:CheckForGrenade()
if not self:HasWeapon("weapon_frag") then
self:Give("weapon_frag")
end
end
or something
it gave an error
well you'd wanna create the timer for ever player
attempt index ply nil value something
well yeah
define player
in this case
you want to target every player
well
actually
i wrote that wrong
try that
also, you need to make sure y ou define PLAYER as the player metatable
local PLAYER = FindMetaTable("Player")
somewhere before that other code
its just a way of doing it
but what part of the code is it used in
so when i save the script it gave an error about PLAYER
and after 20 seconds passed it gave an error about
CheckForGrenade
you can copy the error messages from the console like text
[weapons] addons/weapons/lua/autorun/nadecharge.lua:7: attempt to index global 'PLAYER' (a nil value)
- unknown - addons/weapons/lua/autorun/nadecharge.lua:7
[weapons] addons/weapons/lua/autorun/nadecharge.lua:7: attempt to index global 'PLAYER' (a nil value)
- unknown - addons/weapons/lua/autorun/nadecharge.lua:7
[weapons] addons/weapons/lua/autorun/nadecharge.lua:3: attempt to call method 'CheckForGrenade' (a nil value)
- unknown - addons/weapons/lua/autorun/nadecharge.lua:3
Timer Failed! [youraddon_grenadecheck][@addons/weapons/lua/autorun/nadecharge.lua (line 1)]
[weapons] addons/weapons/lua/autorun/nadecharge.lua:3: attempt to call method 'CheckForGrenade' (a nil value)
- unknown - addons/weapons/lua/autorun/nadecharge.lua:3
Timer Failed! [youraddon_grenadecheck][@addons/weapons/lua/autorun/nadecharge.lua (line 1)]
how do you define a player meta thing
if this code then it should work i think
beacuse i put that
oh i see now
did you put that before the timer code?
like at the top out of functions and stuff
after
well its causing an error because code is read by the computer from top to bottom
and since you defined it after the timer it doesn't know what that is
lol
yea my bad
errors?
i thought it gave faster than 20 seconds
it turns out not the case it works like intended
so no problems
oh ok
whats the rest of the code?
send it but make sure to put single quotes around it
i think i know the issue
timer starts before the player check
timer should start after the player gets into ammo count 0
oh yeah, if u just create a timer outside of everything it'll start whenever the code loads
i think putting a check over ammo count shouldn't be that hard
also I would switch to visual studio code instead of notepad++
i do not have that
its free
thats kinda overkill
for lua
but it would help alot since the gmod extension
without it I would be using the wiki 3x as much
i like to know what arguments i need to use for a function, or if a function even exists really quick
ok so i will trying to mash this code with my old code
gmod extension?
im talking about visual studio code not visual studio if thats what your thinking about
i need to delete give weapon_frag and make it start the code at the bottom
ohh okay
how do i do that
ok first u need to fix your if statements inside of getammocount
if ammocount 0 is wrong since there isnt any conditional, a conditional is <=, >=, ==, or !=. its a symbol that sits between two variables (in this case your ammocount and 0) that compares the two. so you would put ==
read last part of my msg
ye also not necessary but put a space after the == for better readability
is there too much end?
ok your missing two more ends but its formatted kinda weird so lemme write it out for you
[weapons] addons/weapons/lua/autorun/nadecharge.lua:1: attempt to index global 'Player' (a function value)
- unknown - addons/weapons/lua/autorun/nadecharge.lua:1
yeah holdon, could you send the code from if ammocount == 0 to right before function PLAYER:CheckForGrenade?
like as text not as screenshot
if ammocount == 0 then
timer.Create("youraddon_grenadecheck", 20, 0, function()
for k, v in pairs(player.GetAll()) do
v:CheckForGrenade()
end
end)
wait isn't there supposed to be function
before timer.create
if ammocount == 0 then
timer.Create("youraddon_grenadecheck", 20, 0, function()
for k, v in pairs(player.GetAll()) do
v:CheckForGrenade()
end
end)
end
try adding this in, its nothing you really did wrong you just accidentally moved around some of the ends and it pasted in weird so it was hard to read
eof means end of file, i was expecting that to happen since it was still kinda messy. functions and if statements need proper ends so whenever it kinda falls into the void for a lack of an end it causes that error.
add an end to the bottom right before function PLAYER:CheckForGrenade() and it should fix it
can you send what it looks like right now?
thats alot of fuckin ends
yeah i said that too
oh remove the two ends at the bottom
ok
[weapons] addons/weapons/lua/autorun/nadecharge.lua:20: 'end' expected (to close 'function' at line 5) near '<eof>'
can you send a screenshot but with line numbers on the left?
add one end below the highlighted one
[weapons] addons/weapons/lua/autorun/nadecharge.lua:1: attempt to index global 'Player' (a function value)
- unknown - addons/weapons/lua/autorun/nadecharge.lua:1
i hate coding
which one
Player:GetAmmoCount
on both local and function?
i mean just change Player into PLAYER on line 5
it gave the same exact error
ok i understand now
gimme a sec
your gonna have to make a hook, which is basically hitchhiking onto a game event to run your own code
wat da hell
bruh hwat is this
and you can ironsight while running
but running animation overrides ironsight for some reason
how can i fix that
uhh you would make either a running ironsight animation or modify the viewmodel pos instead of using an animation for the ironsights
but your grenade recharging is really easy to fix
i just took forever cause i had to type the code in discord lol
it's already doing that
which one
ok then you either need it to stop it from playing the running animation or have ironsights running anim
really tho let me help u fix that recharging grenade script it will only take like 5 mo mins
sure actually
also i would get vscode now
how do i do the first part
no idea what that is
visual studio code
im scared to send a link cause it might time me out again
its the one with the blue icon
the reason you should get it is because it has autocompletion
is your profile picture from komegatze
yea i think
i thought notepad also has that
yea but its pretty weak compared to vscode with the gmod lua extension
trust me your gonna save alot of time
the extension name is GLua Enhanced btw
you find it in here when u get the program
im testing out my new code
ill be able to send it pretty soon
i think i did everything right
yup!
i got ur code gimme a sec
make sure its in lua/autorun/server/ in ur mod's folder
i added alot of comments so i hope they might help
like?
oh
i read it as commands
instead of comments
oh and one extra thing: when you make the function PLAYER:CheckForGrenade it simply adds that function to all players you have access to, if that makes any sense. since it adds it to the table (see how PLAYER is declared above it) that all player entities use.
are you sure code works
i completed the gauntlent in 23 seconds and i am waiting here for the last 15 seconds and no greandes coming?
oh fuck nevermind
i'm dumb
antiscreamer?? i need
oops i spoiled it
its almost ready i could probably release it today
wtf is an anti screamer
you will get 10000000000000 likes
it overrides functions that draw textures to the screen to do nothing then adds the calls to a list that you can look over to see if any mods are trying to be mailcious
what about sound
def obfuscate ur code
i actually never encountered a screamer addon
its all local functions and variables
one dumbass kept showing me his screamer addon
but other than that i never saw one in the workshop
if you want 100% security you need to download the mod locally and rename the script files so that a screamer couldnt override them
is it possible to double the speed of a weapon through lua
ill brb for 5 minutes but if you mean firerate and the weapon is lua based then yea
weapon is vanilla hl2
and how does firerate would even work on a grenade
Wontairr code me friends to play with
.d
its hardcoded u cant mod vanilla hl2 weapons unless lua data n stuff idk is made for it
what about
when i press a button
it speeds things up for the weapon
and stuff
beacuse grenade takes exactly 1.3 seconds to draw and throw with my quick nade code that i stole
while punching somebody like you are in yakuza is frame 0
ok ye there really isnt any way
yes
anything lower than 1.3 it doesn't throw
i was thinking maybe speed up the draw and throw animation based on multipliers
so instead of 1.3
it should come out at 0.6
or something
but only when this code is used or something idk
UGH I HATE RETAR DED CODES
IT JUST DOESN'T MAKE SENSE
IT SHOULD WORK
NOT BUG OUT AT FUCKING FRAME 15 AND LOOP IT
The computer only knows to do what you tell it to do
If it’s not working then you told it to do something wrong
nuh
i didn't wrote shitty lua
it's impossible
basically it didn't recognize act_vm_idle_lowered for every weapon
except the shotgun
and shotgun doesn't recognize idletolow
but every other weapon does
and i couldn't fix it with lua
so i fixed it with qc
anyways that isn't the issue
how do i disable a code based on an another code
beacuse ironsight and running animation clash
running animation takes priority
while ironsight needs to have priority
" if inIronsights then return end"
shouldn't something like this end the running animation or something?
after this didn't work i tried something like "if inIronsights then seqToPlay = vm:LookupSequence("idle01")"
but it did not work
Do you think that you can just put English in camel case and the computer will just understand?
It’s fine to be a beginner but you’re so confident it’s funny
You’ll have to check with the specific gun mod
but this code uses inIronsights not me
It’s hard to say whatever addons you might be running work
Fair enough haha
That’s not the right thing
Wait what do you wanna do again sry
ironsight should prioritize over running
but right now it's the other way around
scope animation
I think maybe you can use StartCommand hook and check if player is scoping with weapon
But someone might tell you there’s a better way
Yeah stop the player from running using startcommand if they are scoping in with a weapon
StartCommand has a ucmd object and you can change inputs
GPT will honestly do something like that for you
I don’t recommend it if you want to actually learn though
well that is one way to fix it but if player scopes in while running it would cause the same issue no?
Theoretically as soon as you start scoping the StartCommand hook will instantly remove any sprint input
Maybe
I’ve not actually written any glua in a long time lol
it shouldn't remove the input it should override the animation
The sprinting animation?
When you stop sprinting the animation stops bro
yeah but
Oh you mean they should sprint and scope at the same time..?
yes
but sprint animation shouldn't override the damn scope
that just slows down the gameplay
y'know
also how do you make the scope work like it does in arccw or something
somebody was talking about fov and stuff in development but i didn't understand
do you want me to send you both ironsight and running animation .lua?
code isn't exactly mine i stole it
wait could the lua name overriding it?
nah it's not it
should i give credit to you for the code when i publish the addon considering you wrote the entire thing
i have like 7 more people to ask before publishing
and if they do not respond in a week i kinda don't care
nah no need
@wicked hollow how do i put the code into this
put ```lua
if not GetConVar("sv_rechargeable_grenades"):GetBool() then return end
at the top of the hook function.
you dont need local = for the createconvar its just a function that stores a convar in whatever source uses to store them. also u dont want the last FCVAR u put, and theres a hanging comma at the end (u just need help text at the end no min max)
?
like this
or one below the --
[functions] addons/functions/lua/autorun/server/sv_rechargeablegrenades.lua:12: attempt to index a nil value
- unknown - addons/functions/lua/autorun/server/sv_rechargeablegrenades.lua:12
at the top of the hook*'s* function i mean
like right before if ammoid == 10
i meant to say the function that the hook is creating
also you forgot to do the stuff i said after the code block
also why are you still on notepad++ lol
u got an extra comma next to FCVAR_ARCHIVE
also by help text i mean the description of the command
oh whoops
normally u just put "Enables (whatever it enables)"
yeah thats good, also i have nooo idea how that works i haven't messed with that in a while
i would decompile a mod that has that setup already
yeah i did that
didn't understand shit tho
also it doesn't work
when convar is set to 0 it still gives me the grenade
i restarted the game
still giving me grenades
it's at 0 too
sorry it took me a while to come back
@wicked hollow how could one turn a swep with base, let's say arccw into a swep with no base
@spring charm need help again
i can't get this to work it gives an error texture
now it's showing nothing at all
i hate vmt
or code
whichever is causing the porblem
you should always send all the info you have. example: how those textures are being used in code, what do the vmt files look like, etc. it saves time for the person trying to help, since even if long times pass, they don't have to ask you for the extra details in times when you may not be on.
i fixed it actually vtf was the problem
for some reason no mipmaps caused it to not show up
now i need to do
find how to make a pcf work
and overlay it on the screen
and turn arccw base weapon into a normal swep with no base
help me wink wink
there is not a single addon that i can build this shit over
is it possible fade in and out vmts?
wdym like have it fade out on the edges
do that in the texture
unless there is a way idk
fade out as in
textures fades in and out
or something
oh like flashing? could you send the code u use to display the texture?
the other code at the top is this
it instantly appears rn
it wasn't doing that when it was a png
remove the multiplier on the frametime and see what happens
it's giving an error now
lua/includes/util.lua:304: attempt to perform arithmetic on local 'to' (a nil value)
- Lerp - lua/includes/util.lua:304
- v - addons/progressive low health overlays/lua/autorun/bloodscreenprogressive.lua:42
3. unknown - lua/includes/modules/hook.lua:96 (x113)
i don't know how to do the code text thingy
note the symbol is the ~ without shift not '
local healthThresholds = {
{threshold = 10, image = Material("vgui/damage/damage_overlay_red2bloom.vmt")},
{threshold = 30, image = Material("vgui/damage/damage_overlay_redbloom.vmt")},
{threshold = 40, image = Material("vgui/damage/damage_overlay_orangebloom.vmt")},
}
local currentAlpha = 0
local targetAlpha = 0
local fadeSpeed = 3
local selectedImage = nil
local previousImage = nil
local previousAlpha = 0
hook.Add("HUDPaint", "HealthBasedImageOverlay", function()
local ply = LocalPlayer()
if not IsValid(ply) then return end -- Check if the player is valid
local health = ply:Health()
if not ply:Alive() then
targetAlpha = 0
selectedImage = nil
else
local newSelectedImage = nil
for _, data in ipairs(healthThresholds) do
if health <= data.threshold then
newSelectedImage = data.image
break
end
end
if newSelectedImage ~= selectedImage then
previousImage = selectedImage
previousAlpha = currentAlpha
selectedImage = newSelectedImage
end
targetAlpha = selectedImage and 255 or 0
end
currentAlpha = Lerp(FrameTime())
previousAlpha = Lerp(FrameTime())
if previousAlpha > 0 and previousImage then
surface.SetDrawColor(255, 255, 255, previousAlpha)
surface.SetMaterial(previousImage)
surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
end
if currentAlpha > 0 and selectedImage then
surface.SetDrawColor(255, 255, 255, currentAlpha)
surface.SetMaterial(selectedImage)
surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
end
end)
oh i said remove the multiplier for frame time not the whole function args
like remove the * fadespeed part
oh
make sure to keep an eye on what arguments functions require
if u hover over lerp it should show it
otherwise check the wiki
ok code is fucking with me right now
it said
")" is expected near "fadespeed"
so i deleted the other args
except fadespeed
then it gave me an error again
saying the same exact thing
currentAlpha = Lerp(FrameTime() fadeSpeed, currentAlpha, targetAlpha)
previousAlpha = Lerp(FrameTime() fadeSpeed, previousAlpha)
[progressive low health overlays] addons/progressive low health overlays/lua/autorun/bloodscreenprogressive.lua:42: ')' expected near 'fadeSpeed'
[progressive low health overlays] addons/progressive low health overlays/lua/autorun/bloodscreenprogressive.lua:42: ')' expected near 'fadeSpeed'
then i deleted currentalpha and target alpha and previous alpha
then it gave the same thing
i wanna punch the code sometimes
lol its not messing with you.
can you see what the issue is here?
Lerp(FrameTime() fadeSpeed, currentAlpha, targetAlpha)
its for both lines using lerp
wontair i still don't understand code
i get it but im just trying to reap some results
basically take a look at the first part before currentAlpha
its hard to explainn but
Lerp(FrameTime() fadeSpeed this doesnt work because the two variables (FrameTime and fadeSpeed) are just "floating" . as in there is nothing that connects them to eachother. thats why it gets all confused because it expected the lerp function to close with a ). you would have to put a sign like + or * to connect them back.
anyways i wanted u to get rid of the * fadeSpeed part and u only got rid of the * so thats why its causing errors. i think that maybe the fadespeed is making it lerp too fast? lerp is linear interpolation btw
getting rid of * fadespeed is also causing the same issue tho?
with the same exact error but this time it's currentAlpha
did you remove the comma
i mean after frametime
currentAlpha = Lerp(FrameTime() currentAlpha, targetAlpha)
previousAlpha = Lerp(FrameTime() previousAlpha, 0)
so i need a + or a *?
^
Performs a linear interpolation from the start number to the end number.
This function provides a very efficient and easy way to smooth out movements.
See also math. ease for functions that allow to have non linear animations using linear interpolation.
This function is not meant to be used with constant value in the first argument if you're dea...
see the top part
example shows lerpanimation
which we are using a vmt that has no animation
number lerp numbet t is just numbers
so we just give it numbers?
gah fuck this
do you know how to use a pcf
no sorry
you should probably be doing simpler things right now to hone in some coding basics
its hard to resist doing cool stuff but you cant build a house without a foundation
keep the gmod wiki open btw while you work
pcf is already ready i just need to put it at the screen when player gets hurt
sourcegame2sourcegame porting experience
everything is ready you just need to know how to do shit after that point
pcf is a particle effect file