Dateien

> > CS2D > Lua Scripts > Better Knockback
DateiübersichtCS2D-ÜbersichtLua Scripts-Übersicht

Englisch Better Knockback >

6 Kommentare625 b, 12 Downloads

alt Better Knockback

BcY
Reviewer Off Offline

• Better and optimized Knockback script for your server.

You can easily add more weapons and related knockback values:
1
2
3
4
5
6
local items = {
--Check for weapon ids = https://www.cs2d.com/weapons.php
	[10] = { knockback = 20 },
	[30] = { knockback = 15 },
	[32] = { knockback = 15 }
}
√ You can edit it freely.
√ You can claim it yours.
√ You can share it wherever you want.
Zugelassen von Starkkz

Download Download

625 b, 12 Downloads

Kommentare

6 Kommentare
Zum Anfang Vorherige 1 Nächste Zum Anfang

Logge dich ein!

Du musst dich einloggen, um selber Kommentare verfassen zu können!Einloggen

alt

WatPz
User Off Offline

Good script OwO

@user DC: simply, the local initialization can ease the time when Lua needs the find the global var in the _G. If there are frequent calls, it may be helpful, otherside it's sh*t
Ich mag es!

alt

Ranu
User Off Offline

What @user BcY: and @user Gaios: have said are not entirely true.

@Gaios hat geschrieben
The boost can achieve a 30% improvement and is invoked through a hit hook, potentially calling the functions quite frequently within a single frame.
Total BS, made up and wrong data, and hit hook would NEVER be called every frame unless probably all the 32 players in the game shoot at once and that would only be for a few frames then the cycle would break due to difference in latency!

@user DC: No, it is a total waste of time especially in a script like this, it has no effect but making things look more complicated. However, Calling CS2D API through Lua in cs2d is quite not as fast it should be, so localizing the "parse", and "player" would be useful only if you have a function being called every frame with them inside of it, and that's super uncommon in CS2D, as far as I remember the lowest you can get with always hook is every 50 ms, so there is no case where you'll need it for the game.

Some Extra Info (IMPORTANT) >

Tl;dr Localizing doesn't really improve anything ×
5× editiert, zuletzt 23.01.24 21:54:09

alt

acm
User Off Offline

Wow, this is really very readable.
Ich mag es!

alt

Gaios
Reviewer Off Offline

@user DC: Well, this optimization isn't a big deal, so why not go for it? The boost can achieve a 30% improvement and is invoked through a hit hook, potentially calling the functions quite frequently within a single frame.
Ich mag es!

alt

BcY
Reviewer Off Offline

@user DC: Yes, here is the reference: lua.org/gems/sample.pdf

In this scenario it doesn't affect much but if considering to make complicated lua scripts, localising should be a must.

alt

DC
Admin Off Offline

1
2
3
4
5
6
local parse = parse
local math.atan2 = math.atan2
local math.cos = math.cos
local math.sin = math.sin
local math.floor = math.floor
local player = player
Out of curiosity: Is this an optimization to make things faster by making them local? Did you benchmark this? Does it really have a noticable effect?
1× editiert, zuletzt 04.01.24 20:55:48
Zum Anfang Vorherige 1 Nächste Zum Anfang