question before i attempt something

Submit your code requests, and if you are good at coding come help others with their requests.
Post Reply
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

ok folks heres one for you, i know this must be possible but i have no clue how to do it, how do you run an EXE from code within another EXE

for example, im wanting to make a /bootmap command
so in game u can type /bootmap aresden /bootmap middleland
etc and the GServer you are on will attempt to boot up the other map from in game..

ooh ooh also.. can you end a task using code?

cause being able to kill a dead gameserver b4 trying to boot it wud be sweet..

u must be able to or else task manager wouldnt be able to.. but the big question is, does anyone know how? :P

/edit

ooh, CreateProcess and TerminateProcess, but they look complicated :P ill play wif em tomorrow.
Orkl
Loyal fan
Posts: 376
Joined: Sat Sep 17, 2005 2:31 pm

Post by Orkl »

google.com knows how.
<!--QuoteBegin-crazymnig88+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (crazymnig88)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->by notepad??? it didn't show any code, just show words wif no mean<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd--><br><!--QuoteBegin-charlie+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (charlie)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->he'll probably save it as 600pagebook.bmp<br><br>400gb file plzkthnx<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd-->
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

i did look their first:P but seeing the definition of a function and actually being able to use it are 2 entirely different things,

i havent had a go yet i got home late it will have to wait till tomorrow.

bone-you
Spamtastic
Posts: 1310
Joined: Wed Mar 16, 2005 3:12 am

Post by bone-you »

ShellExecuteA()
<img src='http://www.helbreathx.net/sig/sig.jpeg' border='0' alt='user posted image' /><br><a href='http://mafia.cheats4us.org/index.php?x=231030' target='_blank'>#1 on Mafia :D</a><br><!--QuoteBegin-Slipknight+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Slipknight)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->100mb Internet, burstable too 10GB oc192<br>his speed can go up too 10gbs<br>...<br>Yes my car can have a top speed of 1000mph<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd--><br>^^ I wonder where the retard went to.
marleythe9
Loyal fan
Posts: 391
Joined: Sat Mar 26, 2005 12:41 am

Post by marleythe9 »

you mean like start up another HGserver, or just the map?
<img src='http://freewebs.com/trickro/70s.png' border='0' alt='user posted image' /><img src='http://freewebs.com/trickro/70s2.jpg' border='0' alt='user posted image' />
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

to start up another Gserver
and hopefully end task on one thats running if it is,

so assuming you have one thats crashed, a GM can type /boot aresden and on the host pc it will end task on the aresden Gserver, and start it up again :)

Charles
Loyal fan
Posts: 418
Joined: Wed Nov 26, 2003 8:20 pm

Post by Charles »

why not just make an autoboot???
<i>"Always write good code. Feel bad to write bad code."</i>
-Blurr-
noob
Posts: 27
Joined: Mon Aug 30, 2004 11:30 pm

Post by -Blurr- »

Yeah, I'm pretty sure that some HGServers stop Responding after a while on their own. Probably due to bad coding or something like that. So he wants a program or something that will close it and re-open it through a in-game command.
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

yeh, and the reason i want it in game is so GM's can do it without access to the host PC
the autoboot idea is sound but that doesnt detect when a HG hangs does it ?
1+12
Member
Posts: 173
Joined: Sat Feb 04, 2006 5:05 pm

Post by 1+12 »

Nope, It detects if the HGServer is closed, if it is, it re-opens it.
Charles
Loyal fan
Posts: 418
Joined: Wed Nov 26, 2003 8:20 pm

Post by Charles »

if you're in game then when you exit an hg.. it will have a pop up for the player data not saved. so you would have to go back to windows anyhow to close it. so there is really no point. i suggest that you remove the messagebox in the hg if you are going to do an in-game cmd.

zero posted the shellexecute line which is used to execute a program. there is, however, another function inside the shellexecute that is used which is createprocess. that function is strictly for the use of opening a program. shell can do other things though but createprocess is actually meant to open an exe/program. i advise that you look into studying these functions and become familiar with them so that you can come up with your own code to open and close an exe.

if you make a stable and clean coded hg. you woulnd't run into any of these problems.
<i>"Always write good code. Feel bad to write bad code."</i>
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

the first part i think u misunderstood there, i want it so that if a HG hangs on my PC my GM's can reboot it, without access to my PC, lol it would be pointless if i wanted it to reboot HG's myself i agree :P

and yes i agree if the HG was perfect then this wouldnt happen, but no matter what HG iv worked on, who's, or how stable they claim it to be, theres always some player who manages to find some completely random way of crashing the thing, and its just getting on my nerves:P

so i figured a remote map reboot was a better idea than the GM's having to wait around for the hoster to come home so they can get a map back up, i cant be the only one that has this problem surely? :P

hell even HBint GMs had to wait hours on end to get maps back up when they crashed.

oh /edit, you also implied that i was waiting for someone to do the code for me as you said you suggest i come up with my own code to do it, i just wanna make it clear that i always try my hardest to come up with my own code and only use what other people post as a guide.
so dont worry im not askin for babysitting here i was just makin sure i was on the right track :)

iv never actually learnt C++ everything i have coded i have figured out from lookin at the HB sources and backwards engeneering it to figure out whats goin on, thats why a lot of the time im guessing :P

also thats why a lot of the time i will post here first just to make sure my brain isnt randomly makin stuff up :P
Charles
Loyal fan
Posts: 418
Joined: Wed Nov 26, 2003 8:20 pm

Post by Charles »

hmm... you should have stated your first post more clearly. include the whole part about making it remotely accessible.
<i>"Always write good code. Feel bad to write bad code."</i>
bone-you
Spamtastic
Posts: 1310
Joined: Wed Mar 16, 2005 3:12 am

Post by bone-you »

createprocess - file: taskkill.exe params: /F /IM HGMAPNAME.exe

example would be the aresden town : HGARESDEN.exe. That way you can differentiate between hgs and don't close the wrong one. This will kill the hg without save or a popup. Only used for hanging apps.

After that, use shellexecute or createprocess as has been said.



STARTUPINFO si;
PROCESS_INFORMATION pi;
char * szCmdline = "taskkill.exe /F /IM hgname.exe";

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );

CreateProcess( NULL, (LPTSTR*)szCmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );//kills the hg

ShellExecute(NULL, "open", "<fully_qualified_path_to_folder>+hg", NULL, NULL, SW_SHOWNORMAL);//reopens it
<img src='http://www.helbreathx.net/sig/sig.jpeg' border='0' alt='user posted image' /><br><a href='http://mafia.cheats4us.org/index.php?x=231030' target='_blank'>#1 on Mafia :D</a><br><!--QuoteBegin-Slipknight+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Slipknight)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->100mb Internet, burstable too 10GB oc192<br>his speed can go up too 10gbs<br>...<br>Yes my car can have a top speed of 1000mph<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd--><br>^^ I wonder where the retard went to.
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

nice one bone that makes sence i can see how to do it now, it was the usage of those commands i was unsure of, you'v sorted me out now :)
Post Reply