English PHP: Viewing server data icon

21 comments
10.07.11 06:46:04 pm
like 13 like it!
4 kb, 868 Downloads
Apache uwu
User
Offline Off
Updated for CS2D 1.0.0.6 and PHP >= 5.4.

Methods

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

Returns an associative array with the format

Code:
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

Code:
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)
        )
    ...
)
imageimage
edited 8×, last 29.01.18 05:44:17 pm
ok This file has been reviewed and approved by Seekay (04.12.15 01:50:29 am)

Comments

21 comments
Goto Page
To the start Previous 1 2 Next To the start

Log in!

You need to log in to be able to write comments!Log in
18.07.15 05:43:09 pm
like I like it!
Up
Hajt
User
Offline Off
Nice script
edited 2×, last 20.07.15 02:02:25 am
Up
blood2d
User
Offline Off
ok to fix , you need edit with notepad ,

search

$players=hexdec(substr($v_temp,-8,2));

and change for this:

$players=hexdec(substr($v_temp,-4,2));

is only this. Thanks
15.08.11 04:53:33 pm
like I like it!
Up
IWhoopedPythagoras
BANNED
Offline Off
http://94.228.211.23/server.php?ip=94.228.211.23&port=36965

The amount of players is not always shown correctly.
22.07.11 06:20:31 am
Up
Lee
Moderator
Offline Off
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
22.07.11 05:45:43 am
Up
Apache uwu
User
Offline Off
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.
22.07.11 05:41:38 am
Up
Lee
Moderator
Offline Off
Quote:
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

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


Where status goes something like
Code:
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

Code:
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
22.07.11 03:02:47 am
Up
Apache uwu
User
Offline Off
It's a script, since it's not compiled. You hacked save file? o.o careful don't use that word too often.
22.07.11 02:55:47 am
like I like it!
Up
Ultimate programmer
BANNED
Offline Off
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!
22.07.11 02:19:14 am
Up
Apache uwu
User
Offline Off
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?
22.07.11 02:08:32 am
Up
Lee
Moderator
Offline Off
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.
22.07.11 12:44:41 am
Up
Apache uwu
User
Offline Off
@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
21.07.11 01:29:32 pm
like I like it!
Up
DC
Admin
Offline Off
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.
21.07.11 09:44:53 am
like I like it!
Up
kalis
User
Offline Off
make script give rcon too :))
21.07.11 09:42:23 am
like I like it!
Up
tom282f3
User
Offline Off
Great PHP app! cool! I lov it
21.07.11 08:59:15 am
like I like it!
Up
buraxia3
User
Offline Off
I agree with Ax3 its excellent!
13.07.11 09:58:36 am
like I like it!
Up
Ax3
User
Offline Off
Excellent! Thank you, man, i wanted it! 5/5
11.07.11 05:56:03 pm
like I like it!
Up
maPmaKer
User
Offline Off
This is so great. Very good man
10.07.11 11:23:39 pm
like I like it!
Up
ULtiMa
User
Offline Off
Wow, nice koss..err.. Textual Context.
10.07.11 07:13:51 pm
like I like it!
Up
Andrez
User
Offline Off
waw


gj i like it...?

5/5,Awesome
10.07.11 07:13:28 pm
like I like it!
Up
Starkkz
Moderator
Offline Off
Nice script. Btw, Make one that gives you the password and the rcon password xD.
To the start Previous 1 2 Next To the start