SA-MP Forums Archive
Server must-haves - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Discussion (https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: Server must-haves (/showthread.php?tid=404742)



Server must-haves - Sinner - 04.01.2013

Introduction

Let's face it, as well as a coder as you are you can't do everything yourself. At one point your gamemode will require additional includes, plugins and filterscripts. I made this discussion so we can elaborate on the things any server should at least have. I know of a couple any server needs--depending on the server type--and you are free to add more.

Command processors

Any and all servers need a command processor. Sure you can write every command under OnPlayerCommandText using strcmp() and strok but this method is very outdated, unorganized and gets exponentially slower as you add more commands. You are better of using one of the very fast command processors available.
There are other processors available, I will not go over them as they are in one way or another based on the ones listed above.

Streamers

There is (to me) only 1 correct option here. Incognito's Streamer Plugin is written entirely in C++ and therefore skips a lot of overhead (PAWN uses more resources than C++), making it the fastest streamer available. A lot faster than any streamer written in PAWN.

ISP can stream a variety of things such as objects, (racing)checkpoints, pickups, ...

String scanners and modifiers

There are a few you can use depending on what you can to do.
Looping

For extremely fast and efficient looping though players, vehicles or custom arrays you made yourself, use foreach(). There are as far as I know no alternatives that give comparable speed.

__
TBC, feel free to add to it. Template:
Code:
Subject

Explanation



Re: Server must-haves - JoBullet - 04.01.2013

YSI Server Includes as a base framework and modules system such as PAWN-Boilerplate by Slice(which also includes YSI and some other cool stuff.)


Re: Server must-haves - steki. - 04.01.2013

Actually, strtok in most of cases (using with zcmd-based command processor) is faster than sscanf and is almost the same as explode. Not to mention it's a better practice.


Re: Server must-haves - Lorenc_ - 04.01.2013

https://sampforum.blast.hk/showthread.php?tid=216730

Slice is now officially my new idol.


Re: Server must-haves - SuperViper - 04.01.2013

You forgot split.


Re: Server must-haves - JoBullet - 04.01.2013

Quote:
Originally Posted by Stewie`
View Post
Actually, strtok in most of cases (using with zcmd-based command processor) is faster than sscanf and is almost the same as explode. Not to mention it's a better practice.
False.


Re: Server must-haves - Sinner - 04.01.2013

Quote:
Originally Posted by SuperViper
View Post
You forgot split.
Quote:

I know of a couple any server needs--depending on the server type--and you are free to add more.

And yes, thank you I will add it to the topic.


Re: Server must-haves - rjjj - 04.01.2013

People think of optimisation so much that one of the most important libraries has been forgotten :


https://sampforum.blast.hk/showthread.php?tid=292813



I hope that I have helped .


Re: Server must-haves - Sasino97 - 06.01.2013

Quote:
Originally Posted by Sinner
View Post
Command processors

Any and all servers need a command processor. Sure you can write every command under OnPlayerCommandText using strcmp() and strok but this method is very outdated, unorganized and gets exponentially slower as you add more commands. You are better of using one of the very fast command processors available.
I know that using the default string compare function slows down the server when the strings to compare are a lot, but I'm too used to that, I actually use this: #define Command(%0) !strcmp(cmd, %0, true). I never figured out how ycmd works.


Re: Server must-haves - Sinner - 06.01.2013

To elaborate on strcmp() based command processors

strcmp() itself is actually very fast. The problem is that as you add more commands, the if-else structure gets larger and larger. Eventually the server will need to go through all the if-else blocks, checking wether or not the player typed the command, which will be slower as you make more commands.

The y_cmds topic features a chart that visualized the speed difference between strcmp() based commands and command systems that call the function directly.



© Y_Less


Re: Server must-haves - Y_Less - 06.01.2013

That's not a second for 170 commands, that is for several thousand runs combined.


Re: Server must-haves - Sinner - 06.01.2013

Quote:
Originally Posted by Y_Less
Посмотреть сообщение
That's not a second for 170 commands, that is for several thousand runs combined.
My apologies I must have read over that, I'll edit my post.


Re: Server must-haves - Y_Less - 06.01.2013

To be fair, I'm not sure how clear I actually made that in the original post - I'm not very good at highlighting important points.


Re: Server must-haves - JoBullet - 06.01.2013

The fundamental workings of y_commands and zcmd are actually simple and quite reasonable.
If you have a command named "testcmd" its faster to call a function with that name directly(actually all functions that handle commands have common prefix for faster searches), so it's basically amortized constant time; O(1), than doing strcmp compares(let's say that's basic operation) is O(n)(where "n" is number of commands) i.e. linear time. That is clearly shown with the graph above.