Forum

> > Off Topic > [PHP]Message to Server
Forums overviewOff Topic overviewLog in to reply

English [PHP]Message to Server

6 replies
To the start Previous 1 Next To the start

old [PHP]Message to Server

Marcell
Super User Off Offline

Quote
I would like to send custom text by web to my game server throught this script, but i dunno how to define the text inside input

Any tip or suggestion or fix?

the script is:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php


function send_command($ip,$port,$rcon,$command) {
 $fp = @fsockopen("udp://".$ip, $port, $errno, $errstr);
 if ($fp){
      $request = chr(1).chr(0).chr(242).chr(strlen($rcon)).$rcon.pack("S",strlen($command)).$command;
      fwrite($fp, $request);
 }
}


$name = "Owner";
echo "<input type='text' name='$msg'";


if (isset($_REQUEST['send'])) {
send_command("192.168.1.69",36963,"asdasd","say ©255255255".$name.": ".$msg);
}



?>

old Re: [PHP]Message to Server

Yates
Reviewer Off Offline

Quote
@user Gaios: You don't need it if you execute the script like he is doing now.

Sadly, the dedicated server does not (to my knowledge) support command input from outside.

old Re: [PHP]Message to Server

Starkkz
Moderator Off Offline

Quote
@user Yates: unless he wasn't talking about CS2D's dedicated server.

But if he was, he could just go and use file us [Lua 5.1] LuaSocket 3.0 x86 Windows/Linux/MacOS .

Edit: Ignore what I just said, I realized it actually is the dedicated server's IP. It can handle regular RCon commands.

Edit2:
I'm not sure how you'd do it in PHP, but this is how I'd do it in Lua.
1
2
3
4
5
6
7
8
9
10
local RCon = "Some rcon"
local Command = "Some command"

local CommandLength = string.len(Command)
local Short1 = CommandLength - math.floor(CommandLength/256)*256
local Short2 = (CommandLength - Short1)/256

Request = string.char(1) .. string.char(2) .. string.char(242)
Request = Request .. string.char(string.len(RCon)) .. RCon
Request = Request .. string.char(Short1) .. string.char(Short2) .. Command
edited 3×, last 27.02.16 09:49:19 pm
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview