Author Topic: LogInSystem v1.5  (Read 36110 times)

0 Members and 1 Guest are viewing this topic.

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
LogInSystem v1.5
« on: December 25, 2008, 05:13:01 pm »
Script Name: LogInSystem
Script Description: Database-driven account manager. Stores individual stats for every registered-player.
Original Author(s): CurryWurst
Core Version:  2.6.5
Compile Test: Passed
License: Creative Commons



::Features::
  • Database-driven account manager: Players are able to create an account in order to save and track their personal stats.
  • Over 15 unique stats: Kills, Deaths, Selfkills, Visits, Time Played, Damage Dealt, Double Kills and much more ...
  • Customizable stats: Modify default stats according to your own ideas, or just create your favorite stats yourself - be creative, it's easy!
  • Implemented ranking system: What rank could you achieve? - Sorts the entire accounts by a certain statistic you defined.
  • Multilingual user interface: Don't speak English? - No worries, choose your preferred language and LogInSystem will adapt to it!
  • Database repair: Auto restores and cleans corrupted user accounts.
  • Backup function: Lost your account? - Check your old account data to help you restore it.
  • MD5 password encryption: Secures important user data like passwords from theft.
  • Subadminlogin: Recruit sub-admins to help you managing your server.


::In-game commands::
/create> create a new account
/login> to log in to an existing account
/logout> to log out of your existing account
/delete> delete an existing account
/change <password>> change your account password
/stats [accountname]> to view your/others profile & stats
/rankings [number]> list all players in highest ranking order
/help> to see all commands listed above


::Installation::
1. Download the ZIP archive from here
2. Extract the content of the ZIP to your dedicated server root
3. Move the folder LogInSystem to your ./scripts/ directory
(4.) Set your directory permissions of loginsystem_data to 755 if you run the script on linux
5. Have a look at the config file and modify it according to your wishes
6. Start your server ...
7. Enjoy! :D


::Usage of Backup System::
It's particularly important that you know how to deal with the
backup function properly, in order to avoid possible data loss.
Hence, have a brief look at the following table:

PeriodExampleResult
neverBackupFreq=No backup will ever be created
dailyBackFreq=dailyNew backup will be created once a day
weeklyBackupFreq=weekly Friday  Every Friday all user accounts will be saved
monthlyBackupFreq=monthly 01On the first day of every month a new backup will be created

Note: If you intend to create a new backup weekly keep in mind
that weekdays have to be written in the language of the OS
which the server runs on.


::Subadminlogin::
Sub-admin rights will be automatically granted to appropriate accounts when the
player logs in.

You can add a new sub-admin while you're logged in as sub-admin by
typing: /subadmin <accountname>


::Customizing Your own Stats::
1. Overview:
First of all make yourself familiar with the following
pascal type:

type TStatistic = record
       Alias: string;
       IsVisible: boolean;
       Checksum: string;
       SValue: string;
       IgnoreBots: boolean;
       ShowSession: boolean;
     end;

It may look like this, for example:

[MyStat]
1
\d+
0
1
true

2. Summary:
AliasStatistic name
IsVisibleIs stat visible for user?
ChecksumDepending on whether your stat typifies an integer or string value create an appropriate checksum
SValueDefault value, used by account creation process
IgnoreBotsRegulates the influence of bots on gameplay stats
ShowSessionIs stat session displayed?

The checksum is based on regular expressions (abbr.: regex),
a guide can be found here.

Note: If you have understood my instructions so far go on reading.
If not, leave me a message with your question(s) below.

3. Implementation:
  a) Think about a suitable statistic name (alias)
  b) Open /loginsystem_data/localization/language.txt and append your statistic name at the end of each language passage
  c) Open /loginsystem_data/stats/costum.txt and create an entirely new section for your stat according to step 1.

4. Getting Started:
Your statistic is now ready to be used in the script,
here we go ...
   
Choose an event at which the statistic will be updated, for instance:
Code: [Select]
OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
end;
When you have picked an event, update the stat by utilizing one of the following
functions:
_UpdateColumn()> updates a stat representing an integer value by increasing its old value by a new value
_SetColumn()> updates a stat representing a string value by replacing its old value with a new one

Code: [Select]
function _UpdateColumn(Row, Column, Increase: integer): string;
var
  pos: integer;
  data: string;
begin
  if (_RowExists(Row)) then
  begin
    pos:= _getColumnInfo(Row, Column);
    if (pos > 0) then
    begin
      data:= GetPiece(Database[Row], #9, Column);
      if (RegExpMatch('^-?\d+$', data)) then
      begin
        result:= IntToStr(StrToInt(data) + Increase);
        Delete(Database[Row], pos, length(data));
        Insert(result, Database[Row], pos);
      end;
    end;
  end else
  begin
    OnErrorOccur('_UpdateColumn(): row does not exist', true);
  end;
end;

function _SetColumn(Row, Column: integer; Value: string): boolean;
var
  pos: integer;
  data: string;
begin
  if (_RowExists(Row)) then
  begin
    pos:= _getColumnInfo(Row, Column);
    if (pos > 0) then
    begin
      data:= GetPiece(Database[Row], #9, Column);
      Delete(Database[Row], pos, length(data));
      Insert(Value, Database[Row], pos);
      result:= true;
    end;
  end else
  begin
    OnErrorOccur('_SetColumn(): row does not exist', true);
  end;
end;

I don't think it's plain to see how both functions work.
Therefore, in case you're dealing with them, I listed a few points
about the arguments...

Row: Defines the account which will be updated. For both functions the account number (Account[ID]) needs to be passed on.
Column: Statistic element which will be changed. For both functions it's necessary to pass on the statistic number.

Increase: Value the statistic will be increased by.
Value: String the statistic value will be replaced with.

Here's an overview of the statistic numbers:
Code: [Select]
_______________________________
|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 \\\\\.:: Statistics ::.\\\\\\\\\\
 /////////////////////////////////
|// - 0  - Nickname           ///
|// - 1  - Password          ///
|// - 2  - Language         ///
|// - 3  - Server Rights   ///
|// - 4  - Last Used IP   ///
|// - 5  - Last Login    ///
|// - 6  - Visits       ///
|// - 7  - Time Played ///
|== - 8  - Kills       (O)
|\\ - 9  - Deaths      \\\
|\\ - 10 - Selfkills    \\\
|\\ - 11 - Flag Captures \\\
|\\ - 12 - Flag Returns   \\\
|\\ - 13 - Scores          \\\
|\\ - 14 - Damage Dealt     \\\
|\\ - 15 - Double Kills      \\\
|\\ - 16 - Rank               \\\
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 //////.:: Statistics ::./////////
|////////////////////////////////

5. Final stage:
To sum it up, you can realize a statistic implementation by
putting all things together:

Code: [Select]
OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
  _UpdateKey(Account[Killer], 17, 1);
  Inc(Session[Killer][11], 1);
end;

Note: By the way don't forget to update the session data
of the stat by increasing its integer value.

Perhaps it looks difficult to create your own stat, when you view this
guide your first time, but practice makes perfect ;)

On that note, have fun creating your own stats!



::Future intentions::
  • a widely varying offer of achievements
  • more stats encouraging people to play together as team
  • support for more languages - visit the official language topic
  • function to show stats on the web
  • toplist feature
  • support for optional formula all accounts can be ordered by


::Credits to::
- KeYDoN for inspiring me to start programming soldat scripts and for his helpful support
- Indi for giving me a lot of inspiration for new ideas
- EnEsCe for his amazing script core & scripting manual
- xmRipper for translating LogInSystem into Turkish, as well as for his server support
- DorkeyDear for creating the script 'Number of Visits' - the foundation for LogInSystem
- " & danmer - for their function MD5()
- Avarax for his function FillWith()
- Gizdfor his code Double, Triple, Multi... Kills
- homerofgods for his fancy statistic ideas :p
- all translators , which helped me to internationalize this script :)



By the way ....
Happy Soldat 1.6.0rc1! [retard]




EnEsCe server customers please download this script.
« Last Edit: July 27, 2013, 08:14:11 am by CurryWurst »
Soldat Global Account System: #soldat.sgas @ quakenet

Offline Mr

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 166
Re: LogInSystem
« Reply #1 on: December 25, 2008, 05:45:15 pm »
Nice release! Keep it up, awaiting the top-list feature :)

SQLite support for the Soldatserver would be something awesome... EnEsCe? :D

Offline homerofgods

  • Soldat Beta Team
  • Rainbow Warrior
  • ******
  • Posts: 2029
  • We can do better!
Re: LogInSystem
« Reply #2 on: December 25, 2008, 06:02:33 pm »
You didn't have to include me to credits  :P  good work, really nice.
If soldat will have an official stats for soldat, this should really help that too.
merry Xmas!
will deffenetly try it out
« Last Edit: December 25, 2008, 06:05:31 pm by homerofgods »

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: LogInSystem
« Reply #3 on: December 25, 2008, 07:25:38 pm »
Hurrrraaa! Good job! Just by the looks of the topic I can just tell that its shiny :P

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: LogInSystem
« Reply #4 on: December 26, 2008, 04:24:29 am »
Nice work but..this and all other scripts miss a basic element. "Ranks": "me" comparing to "everyone else", 2000 players ranked I am number 28 of 2000 (just an example) ;)

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: LogInSystem
« Reply #5 on: December 26, 2008, 05:07:16 am »
Good work :) I add this my Server :D Oo Love it^^

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: LogInSystem
« Reply #6 on: December 26, 2008, 05:33:42 am »
First of all, I'm really happy about the fact that you like my script :)
It's a great incentive for me to keep this script up.

@Mr:
The top-list feature is already coded, but still to buggy to publish

@homerofgods:
Just because of your creative ideas, btw one of your idea is implemented :D

@Leo:
Huh, have a look at line 1088 in the code - WriteConsole(i, 'Your Ranking: ' + IntToStr(Rank) + '. out of ' + IntToStr(Accounts), $23DBDB);  :P

@y0uRd34th :
Thank you. Perhaps I could create list with all supported servers.
Leave me your server name, ip and port  [pigtail]
« Last Edit: December 26, 2008, 05:45:13 am by Markus Quär »
Soldat Global Account System: #soldat.sgas @ quakenet

Offline Tycho

  • Major(1)
  • Posts: 5
Re: LogInSystem
« Reply #7 on: December 29, 2008, 09:15:13 pm »
Hey, i really like the idea of this script.

Is it possible to use it with multiple soldat servers?
I tried to run the login-system folder at one place and distribute it via symlink to the testservers...

Are there any problems when person 1 is registering on server 1 and person 2 does the registration at the same time on server 2?

I would like the login system to check new players against the database, so if the user isn't registered after 30 seconds he is kicked.

Tycho
« Last Edit: December 29, 2008, 09:57:57 pm by Tycho »

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: LogInSystem
« Reply #8 on: December 30, 2008, 05:45:33 pm »
Is it possible to use it with multiple soldat servers?

Hmm I don't think this would work. But I thought about your question and I have the following idea:

I'm going to create a statistic calling LoggedIn, which specifies whether a user is logged in or not. This statistic will be updated and saved in the database when a user logs out or logs in. Hence, you can make use of symlink to synchronize the database between multiple servers and check whether a user is already registered, as well as whether he is logged in or not. This update procedure will avoid certain database conflicts you mentioned above and allows you to share one database with multiple server ;)
Soldat Global Account System: #soldat.sgas @ quakenet

Offline Tycho

  • Major(1)
  • Posts: 5
Re: LogInSystem
« Reply #9 on: December 31, 2008, 06:39:22 am »
sounds good.

we have 8 publics right now, and i dont want the gamer to register on every server seperatly :D

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: LogInSystem
« Reply #10 on: December 31, 2008, 08:56:50 am »
I would like the login system to check new players against the database, so if the user isn't registered after 30 seconds he is kicked.

Open your config.ini and set the value of the key PrivatFunction to true ;)

we have 8 publics right now, and i dont want the gamer to register on every server seperatly :D

I'll will append this feature when I'm back from England, probably next week monday.
Soldat Global Account System: #soldat.sgas @ quakenet

Offline Tycho

  • Major(1)
  • Posts: 5
Re: LogInSystem
« Reply #11 on: December 31, 2008, 09:38:42 am »
I would like the login system to check new players against the database, so if the user isn't registered after 30 seconds he is kicked.

Open your config.ini and set the value of the key PrivatFunction to true ;)
Ah nice! havent seen that jet :)

we have 8 publics right now, and i dont want the gamer to register on every server seperatly :D
I'll will append this feature when I'm back from England, probably next week monday.
ok, i am looking forward for that :)

Offline CiGaReD

  • Major(1)
  • Posts: 5
Re: LogInSystem
« Reply #12 on: February 02, 2009, 02:35:54 am »
Forgive a few problems have happened to me forgive if my Englishman is not so good but a translator uses already q I am a good Chilean
What happens is q on having put the command/create says that first I must select a language of the following way/language I <number> and put/language 1 which serious Englishman and nothing happens(passes) not which podria to be the problem
Good of before hands thank you for any help

sorry for my inglish XD  :P

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: LogInSystem
« Reply #13 on: February 02, 2009, 12:58:45 pm »
Hope you entered the command in the soldat commandline. If not, try again by opening the commandline with shift + 7 ;)
In case you entered some non-language cmds such as /kill, /stats, /info etc. right after entering /create the menu will start from the beginning.
Soldat Global Account System: #soldat.sgas @ quakenet

Offline CiGaReD

  • Major(1)
  • Posts: 5
Re: LogInSystem
« Reply #14 on: February 02, 2009, 04:13:37 pm »
Hope you entered the command in the soldat commandline. If not, try again by opening the commandline with shift + 7 ;)
In case you entered some non-language cmds such as /kill, /stats, /info etc. right after entering /create the menu will start from the beginning.

I try it to do and in the console of the server this goes out for me when I raise the servant

notice LogInSystem: _CostumStats<>: File "costum.txt2 does not exist
  • [Error] default---> <ActivateServer>: I/O error 103



And on having put this goes out for me in console
  • [Error] default --> <OnPlayerCommand>: TRegExpr<comp>: Invalid [] Range <pos 4>

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: LogInSystem
« Reply #15 on: February 02, 2009, 04:24:32 pm »
Thanks for posting your console message, that really helped me to identify your problem ...

It's plain to see that you forgot to insert the 'login-system' folder.
Download this folder here and extract it to the root of your soldatserver.
Start your server again and enjoy what will happen ;D

If you having still issues drop me some lines ;)


Markus
Soldat Global Account System: #soldat.sgas @ quakenet

Offline CiGaReD

  • Major(1)
  • Posts: 5
Re: LogInSystem
« Reply #16 on: February 02, 2009, 04:37:41 pm »
mmm see http://s1.subirimagenes.com/otros/1926570script.jpg

Nothing happens(passes) and this way this one

Offline CiGaReD

  • Major(1)
  • Posts: 5
Re: LogInSystem
« Reply #17 on: February 02, 2009, 04:40:41 pm »
Forgive decisive(resolved) problem anklebone extracting badly the folder thank you for the help it(he,she) will try to reach adding the Spanish

Offline zop

  • Major
  • *
  • Posts: 81
Re: LogInSystem
« Reply #18 on: February 02, 2009, 07:21:48 pm »
Cool ! Thanks for release.

http://122.116.167.31:23238:23238/galavela/?inc=player&name=%5BTomato+Bird%5D+Cibo[/size=1]

Offline Mittsu

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 617
Re: LogInSystem
« Reply #19 on: March 20, 2009, 03:13:27 am »
im really hoping to have this script on my server, but it just won't work...

server informs me that:
"|> Notice LogInSystem: _CostumStats(): file "costum.txt" does not exist"

while everything seems to be fine:



whats wrong? :/
Realistic-Soldat.net
<+elerok> soldat is dead
<+AThousandD> shit happens