Dateien

> > CS2D > Misc. > PHP: Viewing server data
DateiübersichtCS2D-ÜbersichtMisc.-Übersicht

Englisch PHP: Viewing server data >

21 Kommentare4 kb, 877 Downloads

alt PHP: Viewing server data

Apache uwu
User Off Offline

Updated for CS2D 1.0.0.6 and PHP >= 5.4.

Methods

> CS2D::getInfo($ip, $port);

Returns an associative array with the format

1
2
3
4
5
6
7
8
9
10
11
Array (
    [Name] => Server Name
    [Map] => de_dust
    [Players] => 14 / 32 (Bots: 0)
    [Password] => None
    [U.S.G.N. only] => Off
    [Fog of War] => Off
    [Friendly Fire] => Off
    [Lua] => Uses Lua Scripts!
    [Game Mode] => Deathmatch
)

> CS2D::getPlayers($ip, $port)

Returns an associative array with the format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Array (
    [3] => Array
        (
            [name] => Player
            [score] => 7
            [deaths] => 0
            [team] => Counter-Terrorist
        )

    [another_id] => Array
        (
            [name] => Player 2
            [score] => 9
            [deaths] => 8
            [team] => Terrorist (or Spectator)
        )
    ...
)
8× editiert, zuletzt 29.01.18 17:44:17
Zugelassen von Seekay

Download Download

4 kb, 877 Downloads

Kommentare

21 Kommentare
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

Logge dich ein!

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

alt

Hajt
User Off Offline

Nice script
Ich mag es!
2× editiert, zuletzt 20.07.15 02:02:25

alt

Lee
Moderator Off Offline

as far as I can recall, if gamemode is standard, then the next to last byte of the packet is omitted, otherwise the byte corresponding to the gamemode is added in right before the last byte.

On the other hand, if you're curious about how cs2d's network works, jermuk, flood, and I worked on a clone this past year at https://github.com/FloooD/custom_cs2dsrv/tree/master/src

alt

Apache uwu
User Off Offline

Omg nice--I wouldn't never have thought of that.

Standard gamemode is different from the other games modes btw.

That :nothing becomes 2 zeros when it's standard which is weird.

alt

Lee
Moderator Off Offline

Zitat
So this would be the same idea as 'modding'. I'm not understanding your post, how could I get those bools without using my current method?


Hmm, if I recall, the server info response looks something like

1
01 00 fb status len sv_name len sv_map online sv_max sv_gamemode?:nothing bot_count

Where status goes something like
1
2
3
4
5
6
7
8
9
bit position
1 - has password
2 - usgnonly
3 - fow
4 - ff
5 - version
6 - not standard mode
7 - lua
8 - dedicated
So, to find out if the server supports lua, simply and with 2^6 or 0x40

1
2
3
4
5
6
7
8
pass = status&0x01
usgn = status&0x02
fow  = status&0x04
ff   = status&0x08
sver = status&0x10
gm   = status&0x20
lua  = status&0x40
dedi = status&0x80

alt

Apache uwu
User Off Offline

It's a script, since it's not compiled. You hacked save file? o.o careful don't use that word too often.

alt

Ultimate programmer
BANNED Off Offline

Nice! I think It is awesome program. I have made program to read and edit files for bytes.I have hacked save file of one game and made it done!
Ich mag es!

alt

Apache uwu
User Off Offline

So this would be the same idea as 'modding'. I'm not understanding your post, how could I get those bools without using my current method?

alt

Lee
Moderator Off Offline

In case you're curious, the O(1) (constant time in all modern ALU at least) way of retrieving whether a certain bit has been set in a number that DC is suggesting is to create a number (the mask) with all other bits set to zero, and then bitwise and the mask to the number. Since these masks are just numerical constants, and since they only have one bit set, they will always be an exponent of base two (which makes allocating them on the fly very fast and easy). Anyways, here's an idiomatic example. Say we want to retrieve the third bit of a number, we simply ask for the value of num&(2^(3-1)) or num&4.

alt

Apache uwu
User Off Offline

@DC how is it done in CS2D? I find it easier just to "mod" it, which is dividing the hexdec by 2 every time until the number reaches 1--recording if the mod returns 1 (true) or 0 (false)...


What I don't understand is why you decided to use 128, 64, 8, 4, 1 for all the bool values.

You could have made it , 1, 2, 4, 8, 16, 32, etc so the bit would be smaller.

Very good programming on your half

alt

DC
Admin Off Offline

step 5 would have been much easier and faster with some binary/bitwise ANDs (& in php) but I still like it because it's working and there are comments and tabs in it.
Ich mag es!

alt

kalis
User Off Offline

make script give rcon too :))
Ich mag es!

alt

tom282f3
User Off Offline

Great PHP app! cool! I lov it
Ich mag es!

alt

buraxia3
User Off Offline

I agree with Ax3 its excellent!
Ich mag es!

alt

Ax3
User Off Offline

Excellent! Thank you, man, i wanted it! 5/5
Ich mag es!

alt

maPmaKer
User Off Offline

This is so great. Very good man
Ich mag es!

alt

ULtiMa
User Off Offline

Wow, nice koss..err.. Textual Context.
Ich mag es!

alt

Andrez
User Off Offline

waw


gj i like it...?

5/5,Awesome
Ich mag es!

alt

Starkkz
Moderator Off Offline

Nice script. Btw, Make one that gives you the password and the rcon password xD.
Ich mag es!
Zum Anfang Vorherige 1 2 Nächste Zum Anfang