console_restart - Console auto-restarter. -
Gh05t_ - 16.01.2012
Instructions:
1. Download the application.
2. Extract the application to the directory containing the server console (samp-server.exe).
3. Execute the console application.
Downloads:
http://www.sendspace.com/file/22agl0
http://www.mediafire.com/?d3s8zi6b75b2dfi
Source:
Код:
#include <iostream>
#include <windows.h>
#include <tlhelp32.h>
int ProcessHANDLE(char *process)
{
int icount (0); HANDLE hpoint (NULL); PROCESSENTRY32 process2;
if((hpoint = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)) == INVALID_HANDLE_VALUE) return -1;
process2.dwSize=sizeof(PROCESSENTRY32);
while((Process32Next(hpoint, &process2)) == TRUE) if(stricmp(process2.szExeFile,process) == 0) ++icount;
CloseHandle(hpoint);
return icount;
}
int main(void)
{
ShellExecute(NULL, NULL, "samp-server", NULL, NULL, SW_SHOWNORMAL);
std::cout << "console executed..." << std::endl;
char *ProcessName = "samp-server.exe";
int ireturn = ProcessHANDLE(ProcessName);
int iminute (0), isecond (0), ihour (0);
if(ireturn != -1)
if(ireturn != 1) return 0;
else if(ireturn == 1) do
{
Sleep(1000);
isecond++;
if(isecond == 60) { iminute++; isecond = 0;}
if(iminute == 60) { ihour++; iminute = 0; }
printf("time: %dh, %dm, %ds\n", ihour, iminute, isecond);
int ireturn2 = ProcessHANDLE(ProcessName);
if(ireturn2 == 0)
{
isecond = 0; iminute = 0; ihour = 0;
std::cout << "console terminated..." << std::endl;
ShellExecute(NULL, NULL, "samp-server", NULL, NULL, SW_SHOWNORMAL);
std::cout << "console executed..." << std::endl;
}
} while (true);
}
Re: console_restart - Console auto-restarter. -
Naruto_Emilio - 16.01.2012
Any pictures?
Re: console_restart - Console auto-restarter. -
Gh05t_ - 16.01.2012
Quote:
Originally Posted by Naruto_Emilio
Any pictures?
|
Err, sure? I thought it would have been self-explanitory?
Re: console_restart - Console auto-restarter. -
Juniior - 18.01.2012
Hey, I get an error when compiling.
pawn Код:
C:\Users\Junior\Desktop\RFRP\gamemodes\rfrp.pwn(1) : fatal error 100: cannot read from file: "iostream"
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
Re: console_restart - Console auto-restarter. -
Gh05t_ - 18.01.2012
Quote:
Originally Posted by Juniior
Hey, I get an error when compiling.
pawn Код:
C:\Users\Junior\Desktop\RFRP\gamemodes\rfrp.pwn(1) : fatal error 100: cannot read from file: "iostream"
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
|
This isn't PAWN related code. Download the application, extract it to your folder containing samp-server.exe and execute it.
Re: console_restart - Console auto-restarter. -
Guitar - 07.03.2012
That's just what I need, finally a cute little tool that auto-restarts my server
. Great job buddy!
Re: console_restart - Console auto-restarter. -
TheGamer! - 10.03.2012
Why not make a simple .bat?
Re: console_restart - Console auto-restarter. -
Gh05t_ - 10.03.2012
Quote:
Originally Posted by TheGamer!
Why not make a simple .bat?
|
This monitors the servers process, and will re-execute the application if it's terminated (
willingly or unwillingly), this is why it differs to the other one.
Re: console_restart - Console auto-restarter. -
KingHual - 11.03.2012
Too bad this would only work on Windows (correct me if I'm wrong).
Re: console_restart - Console auto-restarter. -
Gh05t_ - 11.03.2012
Quote:
Originally Posted by king_hual
Too bad this would only work on Windows (correct me if I'm wrong).
|
I have no knowledge in relation to development on a system using Linux (assuming this is what you meant).