[Tool/Web/Other] console_restart - Console auto-restarter.
#1

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); 
}
Reply
#2

Any pictures?
Reply
#3

Quote:
Originally Posted by Naruto_Emilio
Посмотреть сообщение
Any pictures?
Err, sure? I thought it would have been self-explanitory?


Reply
#4

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.
Reply
#5

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.
Reply
#6

That's just what I need, finally a cute little tool that auto-restarts my server . Great job buddy!
Reply
#7

Why not make a simple .bat?
Reply
#8

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.
Reply
#9

Too bad this would only work on Windows (correct me if I'm wrong).
Reply
#10

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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)