PHP Start - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: PHP Start (
/showthread.php?tid=149345)
PHP Start -
aimless - 21.05.2010
Code:
private function Run($sCommand)
{
require('auth.php');
require('GetServer.php');
shell_exec('cd /var/www/sampservers/s1');
shell_exec('./samp02Xsvr');
shell_exec('cd'.GAME_DIRECTORY.'');
shell_exec('nohup'.GAME_BIN_NAME.'&');
exec('nohup'.GAME_BIN_NAME.'&');
$sCommand = 'cmd /C '.$sCommand;
$oShell = new COM("WScript.Shell");
$oShell->Run($sCommand, 0, false);
$aTemp = array();
proc_close(proc_open('cd'.GAME_DIRECTORY.'nohup ./s1 &', array(), $aTemp));
return true;
}
Code:
public function Start()
{
require('auth.php');
require('GetServer.php');
shell_exec('cd /var/www/sampservers/s1');
shell_exec('./samp02Xsvr');
shell_exec('cd'.GAME_DIRECTORY.'');
shell_exec('nohup'.GAME_BIN_NAME.'&');
exec('nohup'.GAME_BIN_NAME.'&');
$this->Run('start /D "'.GAME_DIRECTORY.'" /B '.GAME_BIN_NAME);
$aTemp = array();
proc_close(proc_open('cd'.GAME_DIRECTORY.'nohup ./s1 &', array(), $aTemp));
return true;
}
Code:
public function Stop()
{
require('auth.php');
require('GetServer.php');
$this->Run('taskkill /F /IM '.GAME_BIN_NAME.' /T');
return true;
}
I'm trying to start the server.
Here's what I've got so far but it does not seem to start the server, it's a variation of Nitok's Starter code (
http://forum.sa-mp.com/index.php?topic=138092.0) - I took the Windows version of the code and add bits into it to see if I could start SA-MP on a linux server but.. phail.
Any help...?
Re: PHP Start -
Westie - 22.05.2010
Technically it's a variation of my code, but oh well.
You would need separate scopes for Linux and Windows (Linux doesn't have the COM object). And don't use shell_exec();
...and I don't appreciate people adding my MSN without asking.
Re: PHP Start -
aimless - 22.05.2010
If I can't use shell_exec() what function do I use to start the server?