#(Livewaffle) Adding firerate to a gun

72 messages · Page 1 of 1 (latest)

past shard
#

I have a gun set up like this ```raycast:
type: world
events:
on player right clicks block with:AWP:
- define start_location <player.eye_location>
- define target_location <[start_location].ray_trace[range=32;default=air;ignore=<player>;raysize=.4]>
- playeffect crit <[start_location].points_between[<[target_location]>].distance[2]> quantity:1 visibility:100 offset:0
- playsound <player.location> sound:entity_firework_rocket_blast pitch:.7 volume:.3

shot_sniper:
type: world
events:
on player right clicks block with:AWP:
- define hit <player.precise_target_position.y>
- define Target <player.target||null>
- if <[hit]> >= <player.target.eye_location.y.sub[0.05]> && <[hit]> <= <player.target.eye_location.y.add[0.70]>:
- hurt 100 <[Target]> source:<player>
- else if <[hit]> >= <player.target.eye_location.y.sub[1.4]> && <[hit]> <= <player.target.eye_location.y.add[0.70]>:
- hurt 100 <[Target]> source:<player>
is there anyway to add fire rate? such asAWP:
type: item
material: carrot_on_a_stick
display name: <&l><white>AWP
mechanisms:
custom_model_data: 2
flags:
gun:
stats:
```?

clear ospreyBOT
#

(Livewaffle) Adding firerate to a gun

#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

gritty cargo
#

wait pls

#

!haste

patent kernelBOT
gritty cargo
#

trying to read that in discord is just awful

#

paste it there and send the link

past shard
gritty cargo
#

yeah you can do this in two ways

#

!c ratelimit

patent kernelBOT
# gritty cargo !c ratelimit
Group

queue

Syntax

ratelimit [<object>] [<duration>]

Short Description

Limits the rate that queues may process a script at.

Description

Limits the rate that queues may process a script at.
If another queue tries to run the same script faster than the duration, that second queue will be stopped.

Note that the rate limiting is tracked based on two unique factors: the object input, and the specific script line.
That is to say: if you have a 'ratelimit <player> 10s', and then a few lines down a 'ratelimit <player> 10s',
those are two separate rate limiters.
Additionally, if you have a 'ratelimit <player> 10s' and two different play...

gritty cargo
#

or flags

#

independently of what you choose, you should definitely, always, have a - ratelimit <player> 1t on all player right clicks something events!

#

or it'll fire twice

#

if you want to go with ratelimit, yeah just change 1t to 1s, and you'll only be able to shoot it once every second

#

but that's it, it just prevents you from doing that script for x amount of time

#

if you want it to play particles, sound, anything else for the sake of being pretty, go with flags

#

like

#
- if <player.has_flag[gun_cooldown]>:
  - narrate "oops sorry you're on cooldown, your gun exploded and you died"
  - kill <player>
- else:
  - shooting logic
  - flag <player> gun_cooldown expire:1s
#

smth like this

#

OF COOURSE with the ratelimit 1t before that

after player right clicks block with:gun:
- ratelimit <player> 1t
- if <player.has_flag[gun_cooldown]>:
  - narrate "oops sorry you're on cooldown, your gun exploded and you died"
  - kill <player>
- else:
  - shooting logic
  - flag <player> gun_cooldown expire:1s
past shard
#

Do you have any idea what flags it would be for gun_cooldown or just ratelimit

gritty cargo
#

wdym

past shard
#
  • if <player.has_flag[gun_cooldown]>: the gun_cooldown
#

Would you know how to setup gun_cooldown?

gritty cargo
#

huh? that's just a flag

#

flags can be named anything

#

they dont have intrinsic function or value unless you code them to

#

i could give you a flag named head_made_of_poo but that wouldn't make your head automatically be made of poo

past shard
#

Ah

gritty cargo
#

i think the guide on flags goes into this better iirc

#

!g flag

patent kernelBOT
past shard
#

is there like a dictionary type thing on every flag?

#

like the meta docs

gritty cargo
#

you're severely misunderstanding what a flag is

#

a flag isn't premade

#

it doesn't do anything

#

it isn't anything rather than a value you give to something

#

what you do with that value, or what that value does to anything, is not premade

#

YOU need to make that

#

your gun cooldown flag could be named "my_flag_123" and it wouldnt change a single thing

past shard
#

Ah

#

this is a flag right with - flag?

gritty cargo
#

yeah its on the guide page about flags and is using - flag

past shard
#

so to setup a flag like that would it be - flag player right clicks?

gritty cargo
#

check the flag command's usage

#

!c flag

patent kernelBOT
# gritty cargo !c flag
Group

core

Syntax

flag [<object>|...] [<name>([<#>])](:<action>)[:<value>] (expire:<time>)

Short Description

Sets or modifies a flag on any flaggable object.

Description

The flag command sets or modifies custom data values stored on any flaggable object (the server, a player/NPC/entity, a block location, ...).
See also !language flag system.

This command supports data actions, see !language data actions.

Flags by default are added permanently (or for the lifetime of the object they're attached to).
You can optionally specify a system time the flag will expire at, using either a DurationTag or a TimeTag.
If a DurationTag is used, it will be equivalent to: <util.time_now.add[<your_duration_here>]>

past shard
#

Do i do something like - flag player gun expire:1s and make it check if you have this then puts you on cooldown?

gritty cargo
#

yeah your logic sounds fine

#

try it

past shard
#

So it doesnt limit for 1 second is there anything wrong with this code?

gritty cargo
#

as i said before, if you just want to prevent users from shooting, use only the ratelimit
only use flags for this if you want to do something else when preventing users from shooting

#

choose which one to do

past shard
#

Dumb question but is like ratelimit for like delays between shooting for such as a sniper has a long time before being able to be shot

gritty cargo
#

ratelimit is for limiting the rate at which the script is processed

#

if you do ratelimit at 1 minute, the script will run, and then will only be able to be ran again in one minute

#

its the simplest form of a "cooldown"

past shard
#

Ok ill go with that

#

Ok so i have it setup to be able to shoot every 4 seconds

#

And im guessing i can tune the time between shots for fire rates

#

Thank you