Author Topic: Unpassworder?  (Read 685 times)

0 Members and 1 Guest are viewing this topic.

Offline Syntix

  • Major(1)
  • Posts: 3
Unpassworder?
« on: April 18, 2009, 09:30:03 pm »
Can someone make a script that unpasswords a server once everyone has left it please?

Offline UPNPAD

  • Major(1)
  • Posts: 36
Re: Unpassworder?
« Reply #1 on: April 18, 2009, 11:16:08 pm »
Sure, I've done something similar in a script I once made.

This is if you want it to revert the password to what is set in the server soldat.ini settings:
Code: [Select]
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var
  Password: string;
begin
  if (NumPlayers <= 1) then
  begin
  Password := ReadINI('soldat.ini','NETWORK','Game_Password','');
    if (Password = '') then
      Command('/password')
    else
      Command('/password ' + Password);
  end;
end;

This does exactly what you asked for:
Code: [Select]
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  if (NumPlayers <= 1) then
    Command('/password');
end;

I'm not sure if they work with 2.6.4, I haven't had a need to download the latest server as of yet, but tell me if you encounter any problems (paste the errors as they are written in the console/logs, I did modify them from what I used in my script in order to make them standalone).

Offline Quantifier

  • Major
  • *
  • Posts: 70
Re: Unpassworder?
« Reply #2 on: April 19, 2009, 10:46:10 am »
Latest server version has global variable Password, you can cache it at the start. Querying soldat.ini file is not 100% reliable.

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Unpassworder?
« Reply #3 on: April 25, 2009, 02:45:03 am »
Plus, upnPAD, because of the global variable Password, it isn't good practice to declare Password as a local variable (although it doesn't seem to cause any errors).
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!