Forum

> > CS2D > Servers > Server, Lua and I.
Forums overviewCS2D overview Servers overviewLog in to reply

English Server, Lua and I.

8 replies
To the start Previous 1 Next To the start

old Server, Lua and I.

Nekomata
User Off Offline

Quote
I require a bit of information on this matter being. Currently I've been working on a script where as a player gains credits/money and purchases an item. Unlike any other rpg server, these items are mainly attributes and effects. Effects being as really fast called, multiple sprites, multiple of times.

Question being, all this, including players of around 20~30, using these effects. How much threshold of lag and side effects would there be? I'd be glad if the lag threshold would be around a dropping slightly of the ping to null but I highy doubt that'd be that cause.

Consider these 2 scenarios.

Scenario 1
>Player gets hit by 1 bullet using the "hit" hook.
>An effect is generated at a calculated position around him.
>Repeat if he's getting hurled at with a spray of bullets.

Scenario 2
>Player has a shield.
>Player is getting sprayed at with bullets.
>Each hit at the shield triggers a sprite with a tween animation.

The tween animations include alpha reduction and resize.

Therefore, question being since the basic protocols being provided by cs2d are;
Server -> {server lua} -> Client
at immense rates, which of course triggers to everyone in the server, immense populate.


Questions being;
1. How much lag would I be looking at here? (slight, immense) {if so, then question 2}
2. Is there some hack/fix to prevent - probably asking a lot, but atleast reduce the lag?


(and no, use of ">" is not greentext, it's my way of producing steps)

Before practically trying this out, I wanted to see if I could get some insight from this community, therefore,
DC senpai/peoplewithknowledgeinthisstuff, your graceful attendance plis.

old Re: Server, Lua and I.

Apache uwu
User Off Offline

Quote
Quote
...really fast called, multiple sprites, multiple of times...

...including players of around 20~30...


It'll look really cool for a single player game, but unfortunately will cause everyone on the server to have lag spikes.

Have you considered the usage of tween_* commands?

old Re: Server, Lua and I.

Nekomata
User Off Offline

Quote
Yes, I've been using tween for transparency and resizing.
Lag is the last thing I needed. o.O

And it looks cool too. ;_; I'll be implementing this by tomorrow to see how it goes, guess I'll post results here. o.O

old Re: Server, Lua and I.

omg
User Off Offline

Quote
1 image on hit is usually manageable for a good amount of players (like 20) as long as a ton of people arent getting hit at the same time, then it will start to lag significantly for most players

on my server, players make 6 images -per attack- (it makes regardless of whether or not it hits anything) plus an image on hit. these images last about 200 ms (if i remember correctly) and if i spray an m249 half the players in the server will lag significantly and a few of them will freeze and dc

old Re: Server, Lua and I.

Nekomata
User Off Offline

Quote
It's a server with about 20 players on average. A few players may have been able to buy that item but by the future, most players will probably have it.
Although some players don't use USGNs, which means no items whatsoever. The items aren't that cheap either. So hopefully that could be the fix.

Oh and here's a tip to reduce image bugs.
If you're doing this on a server with a lot of players, don't mask images. Make it a transparent PNG and then load it.
Following this procedure:
1. Load image
2. Mask Image
3. Etc
will cause the image to show it's original unmasked form for less than a second. Ofcourse, there won't be any issues but If you're a perfectionist then. ;0

old Re: Server, Lua and I.

VADemon
User Off Offline

Quote
There's no reason to use anything but PNG or, for pictures, JPEG.

One way to optimize the stuff may be that you only send image commands to nearby players, say 1 screen in radius. user DC could tell us whether or not Cs2d does this by default, but probably no.

Another way to go is to annoy user DC and ask for a feature that uses different parts of an image as single frames, as for example in the grenade explosion sprite. IMHO, shouldn't be hard to do, since it's already implemented. Params: image, frame X, (frame Y size will equal to image Y size for the sake of simplicity), in-game frames per image frame (1=each game frame a new frame is displayed, 2=each 2 game frames a new frame is shown etc)

old Re: Server, Lua and I.

DC
Admin Off Offline

Quote
@user VADemon: He isn't using frame-animations when I got it right so adding animation support wouldn't solve this particular problem. Tweens are cheap - except for the additional traffic they cause once for their setup. A frame animation setup would cause comparable traffic.

@user Nekomata: Unfortunately this might cause lags because of CS2D's serverside-only Lua architecture. Each image creation causes additional traffic. Each command to modify the image causes additional traffic too. Same for starting a tween. Doing this in a very high frequency with many players simply creates a huge amount of additional traffic in a short time.

There is no real way around this. user VADemon's idea to only send this effect to nearby players is probably the best optimization you can do. CS2D always sends images to all players if you tell it to do so. It can't optimize (not send the image to certain players) automatically because it can't know what you'll do with the images in future (local rendering however is optimized, so only visible images are displayed).

old Re: Server, Lua and I.

Pagyra
User Off Offline

Quote
user DC: Can you add lua command to work with animations, as is already done with explosion image?

Admin/mod comment

This is OT and I could but I probably won't /DC

old Re: Server, Lua and I.

Nekomata
User Off Offline

Quote
I see. Thanks a lot for the input. user VADemon's idea seems perfect for the situation. I never thought of it before but this could significantly reduce the lags and just apply the sprite callings to a specified radius around the player. o.o

I was at-first planning to use frame animation for a couple of different things. I was probably going to use MikuAuahDark's module for it or somehow develop my own but again, that would kill the clients. So tweening it is. ;0
After all the firsthand thing I want to stick to is for the players to be able to keep their fps from flipping since its a fast paced server.

Again, thanks for the replies. I'll work and implement it, let a week or so pass and see the results. If I find anything knowledgeable or a minor report on the lag effects I'll bump this thread. o.o

Cheers, for now.


P.S Just a really quick question to user DC. I don't know if this is a repeated question, but here goes o.o; are there any plans to enhance the client->server->client sync for better multiplayer performance in cs2d any time in the future?
To the start Previous 1 Next To the start
Log in to reply Servers overviewCS2D overviewForums overview