[Release] Source files for GunZ Remote ^ ^
GunZRemote Tool - Revision 1
Want to be able to run your server files without having to login to your dedi, or want your devs to run the server files without them knowing the dedicated server's info?
Well this is the solution, i introduce to you "GunZ Remote Tool" exclusive for RaGEZONE :)
Im releasing the source files so you can add your own custom shit to the program, what ever you do for the
client, do the same for the server :P
note: i went slowly through the server files so i commented most of the lines, but for the client i rushed it a bit so its a bit messy and i havent put many comments =P
------------------------------------------------------------------------------------------------------
GunZRemote Source
------------------------------------------------------------------------------------------------------
HOW TO USE :
1) Get a Delphi compiler, i suggest Delphi 2007
2) Open the Borland Project files with delphi
3) Click on compile/build and you have build it
4) If you would like to edit it, then please do so but leave my credits in the source :P
Server.pas
Code:
//////////////////////////////////////////////////////////////
// Bounty-Hunter's GunZ remote tool - Server Edition for //
// the RaGEZONE community, this package features both //
// Client and server, but this is the server source. //
// Feel free to redistribute as long as you give me //
// Credits for being the creator of this program, Yours //
// GunZ Dev and Delphi coder - Bounty-Hunter ;) //
// P.S so far it allows devs to delete and start server // //
///////////////////////////////////////////////////////////
unit Server;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IniFiles, Sockets, StdCtrls, Menus;
type
TRemoteServer = class(TForm)
Button1: TButton;
Memo1: TMemo;
Server: TTcpServer;
MainMenu1: TMainMenu;
Accounts1: TMenuItem;
CreateAccount1: TMenuItem;
DeleteAccount1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ServerAccept(Sender: TObject; ClientSocket: TCustomIpClient);
procedure CreateAccount1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
// the login Data Structure ///////////////////////////////
Tlogin = record
Username :string[12];// set the maximum characters to 12
Password:string[12];
Access :string;
keycode :string[8]; // Maximum Keycode length to 8
Logged :bool; // checks if user is logged in
end;
////////////////////////////////////////////////////////////
var
RemoteServer: TRemoteServer;
Data :TiniFile;
News :string;
MatchServer:string;
MatchAgent:string;
Locator:string;
Password:string;
Acc :Tlogin;
AccountDir :string;
Account :Tinifile;
implementation
{$R *.dfm}
procedure TRemoteServer.Button1Click(Sender: TObject);
var
Port :string ;
begin
Data := TiniFile.Create(GetCurrentDir +'\Server.ini');
Port := Data.ReadString('CONFIG','PORT','4331');
Server.LocalPort := Port;
Server.Active:= true;
Server.Open;
Memo1.Lines.Add('RemoteServer started on ' + Server.LocalHostAddr + ' And port ' + Port);
end;
procedure TRemoteServer.CreateAccount1Click(Sender: TObject);
begin
Account := TiniFile.Create(GetCurrentDir + '\Account\lol.ini');
Account.WriteString('ACCOUNT','Password','put user name here');
// Access when sent to client it will be read as a string
// so please put a string for access
// 1 = Owner 2 = Admin 3 = Dev
Account.WriteString('ACCOUNT','Access','put a access here');
Account.WriteString('ACCOUnt','Keycode','put keycode here');
end;
procedure TRemoteServer.FormCreate(Sender: TObject);
begin
AccountDir := GetCurrentDir + '\Account';
if fileexists(GetCurrentDir +'\Server.ini') = false then
begin
try
Data := TiniFile.Create(GetCurrentDir +'\Server.ini');
Data.WriteString('CONFIG','MatchServerPath','Put MatchServer Path here');
Data.WriteString('CONFIG','MatchAgentPath','Put MatchAgent Path here');
Data.WriteString('CONFIG','LocatorPath','Put Locator Path here');
Data.WriteString('CONFIG','PASSWORD','Put Password here'); //do u see that :P
Data.WriteString('CONFIG','PORT','4331');
Data.WriteString('CONFIG','NEWS','Put the news u want your devs to read');
finally
News := Data.ReadString('CONFIG','NEWS','my news goes here');
Data.Free;
end
end
else
begin
Data := TiniFile.Create(GetCurrentDir +'\Server.ini');
News := Data.ReadString('CONFIG','NEWS','my news goes here');
MatchServer := Data.ReadString('CONFIG','MatchServerPath','');
MatchAgent := Data.ReadString('CONFIG','MatchAgentPath','');
Locator := Data.ReadString('CONFIG','LocatorPath','');
Password := Data.ReadString('CONFIG','PASSWORD','');
Data.Free;
end;
end;
procedure TRemoteServer.ServerAccept(Sender: TObject;
ClientSocket: TCustomIpClient);
Var
Pass :string;
ServerFileR :string; //Server File Starter
DeleteFiler :string; //Server File Deleter
begin
//Login Packet////////////////////////////////////
//Login DataStructure
Acc.Username := ClientSocket.Receiveln('Username');
// creates a handle to read/write to the acocunt file
Account.Create(AccountDir + Acc.Username);
Acc.Password := ClientSocket.Receiveln('Password');
//added keycode, but doesnt do anything yet, maybe you can
// make it do something :P
Acc.keycode := Account.ReadString('ACCOUNT','Keycode',''); // doesnt do anything yet
Pass := Account.ReadString('ACCOUNT','Password','');
// Check if Account exists
if fileexists(AccountDir + Acc.Username) then
if Acc.Password = Pass then
begin
// tell the user he has logged in
ClientSocket.Sendln('pass','FAIL');
Acc.Access := (Account.ReadString('ACCOUNT','Access',''));
ClientSocket.Sendln(Acc.Access,'ACCESS');
Acc.Logged := true;
end
else
begin
// User has failed to login so tell him the bad news lol!
ClientSocket.Sendln('error','FAIL');
end
else if Acc.Logged = true then
begin
// End of login packet ////////////////////////////
///////////////////////////////////////////////////
//Sends the news packet
ClientSocket.Sendln(news,'NEWSPACKET');
{DeleteFiler, string declared above stores the DeleteServer
Packet as a string}
DeleteFiler := ClientSocket.Receiveln('DeleteServer');
{ServerFiler, a string declared above stores the ServerFiler
Packet as a string}
ServerFIler := ClientSocket.Receiveln('1');
//While the DeleteFiler string = to anything then do a loop
while DeleteFiler <> '' do
begin
//keep on getting the packet if user does multiple delete
DeleteFiler := ClientSocket.Receiveln('DeleteServer');
//if deletefiler packet is 'server' then it deletes MatchServer
if DeleteFiler = 'server' then
begin
deletefile(MatchServer);
RemoteServer.Caption := 'Server Deleted';
end
//or else if it is 'agent' then it deletes MatchAgent
else if DeleteFiler = 'agent' then
begin
deletefile(MatchAgent);
RemoteServer.Caption := 'Agent Deleted';
end
//or esle if it is 'locator' then deletes Locator
else if DeleteFiler = 'locator' then
begin
deletefile(Locator);
end;
end;
//while ServerFiler packet string = anything then do a loop
while SERVERFILER <> '' do
begin
RemoteServer.Caption := serverfiler;
ServeRFilEr := ClientSocket.Receiveln('1');
// if it equals to 'server' then start matchserver'
if ServerFiler = 'server' then
begin
memo1.Lines.Add('MatchServer has been started');
winexec(pansichar(MatchServer),SW_NORMAL);
end
//Starts MatchAgent
else if ServerFiler = 'agent' then
begin
memo1.Lines.Add('MatchAgent has been started');
winexec(pansichar(MatchAgent),SW_NORMAL);
end
else if ServerFiler = 'locator' then
begin
//Starts Locator
memo1.Lines.Add('Locator has been started');
winexec(pansichar(Locator),SW_NORMAL);
end;
{If you want to add your own functions, then please
Reply on the forums and ill get back to you as soon as
possible and also if you have any suggestions about this
program then please leave me a pm or reply on the forums.}
end;
end;
end;
end.
GRemote.pas
Code:
unit GRemote;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Sockets, sSkinManager, ComCtrls, sTabControl,IniFiles, StdCtrls,
ExtCtrls;
type
TGZRemote = class(TForm)
sSkinManager1: TsSkinManager;
PageControl1: TPageControl;
Setting: TTabSheet;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
SaveSettting: TButton;
Connect: TTabSheet;
Label4: TLabel;
Label5: TLabel;
Memo1: TMemo;
Client: TTcpClient;
Start: TButton;
Timer1: TTimer;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Account: TTabSheet;
Label6: TLabel;
Edit4: TEdit;
Label7: TLabel;
Edit5: TEdit;
procedure FormCreate(Sender: TObject);
procedure SaveSetttingClick(Sender: TObject);
procedure StartClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
//Login structure like the server side
type
Tlogin = record
Username :string;
Password :string;
Access :string;
Rank :string;
end;
var
GZRemote: TGZRemote;
Data: TiniFile;
IP: String;
Port: string;
Password: string;
Acc :Tlogin;
implementation
{$R *.dfm}
procedure SetupData();
begin
if fileexists(GetCurrentDir +'\Config.ini') = false then
begin
try
Data := TiniFile.Create(GetCurrentDir +'\Config.ini');
Data.WriteString('CONFIG','IP','127.0.0.1');
Data.WriteString('CONFIG','PORT','6000');
Data.WriteString('CONFIG','PASSWORD','');
showmessage('No config has been found');
finally
Data.free;
end;
end
else
begin
try
Data := TiniFile.Create(GetCurrentDir +'\Config.ini');
IP := Data.ReadString('CONFIG','IP','Error');
Port := Data.ReadString('CONFIG','PORT','Error');
PassWord := Data.ReadString('CONFIG','PASSWORD','Error');
finally
Data.Free;
end;
end;
end;
procedure TGZRemote.Button1Click(Sender: TObject);
begin
if client.Connected = true then
begin
client.Sendln('server','1');
end;
end;
procedure TGZRemote.Button2Click(Sender: TObject);
begin
if client.Connected = true then
begin
client.Sendln('agent','1');
end;
end;
procedure TGZRemote.Button3Click(Sender: TObject);
begin
if client.Connected = true then
begin
client.Sendln('locator','1');
end;
end;
procedure TGZRemote.FormCreate(Sender: TObject);
begin
SetupData();
memo1.Lines.Add('Created by Bounty-Hunter for Ragezone Community');
Acc.Username := edit4.Text;
Acc.Password := edit5.Text;
edit1.Text := IP;
edit2.Text := Port;
edit3.Text := Password;
connect.Enabled := false;
end;
procedure TGZRemote.SaveSetttingClick(Sender: TObject);
begin
try
Data := TiniFile.Create(GetCurrentDir +'\Config.ini');
Data.WriteString('CONFIG','IP',edit1.Text);
Data.WriteString('CONFIG','PORT',edit2.Text);
Data.WriteString('CONFIG','PASSWORD',edit3.Text);
finally
Data.Free;
end;
end;
procedure TGZRemote.StartClick(Sender: TObject);
begin
if Client.Connected = false then
begin
Client.RemoteHost := edit1.Text;
Client.RemotePort := edit2.Text;
Client.Active := true;
connect.Enabled := true;
//Client.Sendln(edit3.Text,'PASSPACKET'); Not Needed
Connect.Show;
end
else if Client.Connected = true then
begin
Client.Disconnect;
Client.RemoteHost := edit1.Text;
Client.RemotePort := edit2.Text;
Client.Active := true;
connect.Enabled := true;
//Client.Sendln(edit3.Text,'PASSPACKET'); Not Needed
Connect.Show;
timer1.Enabled := true;
end;
end;
procedure TGZRemote.Timer1Timer(Sender: TObject);
var
News :string;
begin
//////////////////////////////////////////////////////////
if Client.Connected = true then
begin
// sending the login packet or whatever u wana call it
Client.Sendln(Acc.Username,'Username');
Client.Sendln(Acc.Password,'Password');
// now check and recive if we managed to login
if client.Receiveln('FAIL') = 'error' then
begin
memo1.Lines.Add('You have failed to login you noob');
Client.Disconnect;
end
else if client.Receiveln('FAIL') = 'pass' then
begin
Acc.Access := Client.Receiveln('ACCESS');
if Acc.Access = '1' then
begin
Acc.Rank := 'Owner';
end
else if Acc.Access = '2' then
begin
Acc.Rank := 'Admin';
end
else if Acc.Access = '3' then
begin
Acc.Rank := 'Developer';
end;
memo1.Lines.Add('Successfuly logged in');
memo1.Lines.Add('Your Rank is ' + Acc.Rank);
// recieve the news since we logged in
News := Client.Receiveln('NEWSPACKET');
memo1.Lines.Add(News);
end;
end;
//////////////////////////////////////////////////////////
end;
end.
Features:
*Account login, username and password
*MatchServer Start
*MatchAgent Start
*Locator Start
planning on to add more features into the future
if you would like a feature to be added, please reply on forums :P
If you find any bugs please report to me immediately
Credits :
Bounty-Hunter - For Creating the program
onemorejosh - gave me help during the early phase (before i started on this program)
Re: [Release] Source files for GunZ Remote ^ ^
Good job :) TIKACHU APPROVES OF YOU!!!
Re: [Release] Source files for GunZ Remote ^ ^
Re: [Release] Source files for GunZ Remote ^ ^
Quote:
Originally Posted by
onemorejosh
good job :) tikachu approves of you!!!
tikachu i chose you !!!!!!
Re: [Release] Source files for GunZ Remote ^ ^
Re: [Release] Source files for GunZ Remote ^ ^
Nice job, but you really should organize your code - I like to have everything tabbed in and etc.
Either way, I'm not sure how many people use Delphi in the Gunz world, so this may have limited use.
Re: [Release] Source files for GunZ Remote ^ ^
If you can code in delphi, then adding functions should be a breeze :)
i was doing all this as a practice for networking in XV3, im going to continue work on XV3 in 3 weeks time, hopefully in this time i can learn a lot and put my knowledge into good use !
Re: [Release] Source files for GunZ Remote ^ ^
I'm not talking about what you can do with it, I'm saying that the amount of people who use Delphi on this forum is low.
Anyway, have fun with XV3.
Re: [Release] Source files for GunZ Remote ^ ^
Quote:
Originally Posted by
Aristrum
Nice job, but you really should organize your code - I like to have everything tabbed in and etc.
Either way, I'm not sure how many people use Delphi in the Gunz world, so this may have limited use.
I tried, in the server i commented mose of the code so you can get an understanding.
i even labeled the entire login packet area, so you can make your own custom login or whatever :P
Note: there are some errors in the program, i deliberately left them there so you guys can fix (really easy to fix, *hint* look at Account.readstring, i forgot to free it from memory so you have to add Account.free; )
Re: [Release] Source files for GunZ Remote ^ ^
It's not that its not written well, I just like to have everything tabbed out and etc, I'm just vain.
Anyway, not exactly related, but do you have an MSN: I wanted to show you how to use ZChatOutput in gunz from Delphi.
Re: [Release] Source files for GunZ Remote ^ ^
Re: [Release] Source files for GunZ Remote ^ ^
Nice one; that's REALLY practical.
Re: [Release] Source files for GunZ Remote ^ ^
i thought him how to do that! :O
Re: [Release] Source files for GunZ Remote ^ ^
Quote:
Originally Posted by
adriann
i thought him how to do that! :o
-.___________-
...
Re: [Release] Source files for GunZ Remote ^ ^
Quote:
Originally Posted by
Adriann
i thought him how to do that! :O
LOOOOOOOOL.
You thought him how to do that? Lol..
No you didn't.