[MOD] SQL to limit characters by account

Place for sharing your game modifications for Life is Feudal: Your Own

Allquixotic
 
Posts: 13
Joined: 14 Jan 2015, 22:22

[MOD] SQL to limit characters by account

Post by Allquixotic » 26 Feb 2015, 01:24

For people familiar with SQL, get the code HERE and dig in!

This code introduces a new table in the database and some new functions to allow the admins/GMs of a server to whitelist specific accounts to have more than X number of characters. The intended use case is for GMs to set a baseline character count limit (which can be any number greater than 0), and then allow specific people to make more characters up to an arbitrarily high limit.

To change the number of characters that EVERYONE is allowed to make by default without Admin intervention, change this line (line 16 of the file):

Code: Select all
DECLARE retval INT DEFAULT 1;


change the "1" to the number you want to allow by default. The numbers you set for individual accounts may be lower OR higher than this value.

Setup

The SQL code for the procedure needs to be submitted to your MySQL or MariaDB server (I will refer to this generically as "your SQL server" from here on out, but I am NOT referring to the product Microsoft SQL Server, since that isn't supported by LiF:YO). The in-game console does not accept SQL, so you must execute it on your SQL server.

How you do that will depend on how your server is set up. If you have never connected to your SQL server directly before, you must learn how to do that on your own. I can't tell you how to connect to your SQL server, because it depends on how you installed it, what platform you installed it on, whether it's MySQL or MariaDB, whether you're hosted or running a dedicated server, etc. If you don't know how to do this, consider that a project for you to complete as a pre-requisite before you are able to use this mod.

Once you have access to your SQL server, simply submit the contents of the mod (linked to at the start of the post) to your SQL server as a query. There are literally hundreds of different ways to do this, that range from web interfaces, desktop apps like HeidiSQL, or console commands like mysql.

Example usage

You can call any of the functions or procedures exposed by the mod in your own SQL statements. However, the simplest way is to pass an existing character name to the query to increase the number for a specific account by 1.

Assuming you have the mod installed, you can add 1 to the character limit of the account associated with a given character first name as follows:

Code: Select all
CALL p_incrementCharacterLimitByName('Coorbin');


This SQL code will increase the character limit of the account associated with the character "Coorbin" by 1. To increase it by a small number greater than 1, you can just run the procedure repeatedly. The resultset returned will contain the new limit.

Limitations

1. If the user tries to create a character in excess of their limit, they will receive this cryptic error message:

Image

I don't think we can do anything to make this more user-friendly right now, because the string in the message box is defined on the client side.

2. If the user has more characters than their limit already created before you implement this mod, those characters will not be changed or deleted in any way. You may consider this a good or a bad thing, but just be aware of it. So if someone has 5 or 6 characters already, this will prevent them from making any more, but you will have to (manually) find out who has those characters, and then decide what to do about them.


Remystemple
 
Posts: 80
Joined: 15 Jan 2015, 22:30

Re: [MOD] SQL to limit characters by account

Post by Remystemple » 26 Feb 2015, 04:21

how do i get around the "multiple triggers" error. i have a starter kit script already installed and i think it doesn't like both of them. any ideas? it seems i can use 1 or the other. adding to patch.sql is not an option for me as i have renamed it because it was reverting many changes i had made in the database such as container size.

thanks.


Allquixotic
 
Posts: 13
Joined: 14 Jan 2015, 22:22

Re: [MOD] SQL to limit characters by account

Post by Allquixotic » 01 Mar 2015, 16:16

You can probably copy and paste the body of the conflicting triggers into the same trigger, as long as nothing they do conflicts. This would require a little bit of knowledge of SQL and is dependent upon exactly what other triggers you have.


Chrisraiden
 
Posts: 4
Joined: 07 Dec 2014, 18:54

Re: [MOD] SQL to limit characters by account

Post by Chrisraiden » 06 Mar 2015, 23:24

great work .. thx :-)


Blackdrakon
 
Posts: 20
Joined: 01 Feb 2016, 09:27

Re: [MOD] SQL to limit characters by account

Post by Blackdrakon » 10 Mar 2016, 08:49

I've run this script through the query box in HeidiSQL with the default value of all accounts being 1. But people are still allowed to create more than one character. What could be the issue?


Balbuena82
 
Posts: 10
Joined: 19 Jan 2016, 15:08

Re: [MOD] SQL to limit characters by account

Post by Balbuena82 » 28 Jul 2016, 13:17

add the command and when more than two characters think the code works but error on the panel have created more than two written characters does not appear. any solution


SweetLouHD
 
Posts: 5
Joined: 22 Dec 2015, 03:53

Re: [MOD] SQL to limit characters by account

Post by SweetLouHD » 18 Nov 2017, 20:20

Allquixotic wrote:
Limitations

1. If the user tries to create a character in excess of their limit, they will receive this cryptic error message:

Image

I don't think we can do anything to make this more user-friendly right now, because the string in the message box is defined on the client side.



This can be fixed using BasilMod.

In BasilMod\pack\content.cs uncomment (remove the //) the last line:
Code: Select all
//Send whole directory update to client (directory structure should follow client game dir)
//BasilMod::pack_contentdir("update");


Make an update folder in your Servers main Directory (ie. C:\Server)
Recreate the file structure of the client in this update folder for any of the files you wish to replace on the players client. For this example you would create a "data" folder and put the cm_messages.xml file in there.

Modify that new cm_messages.xml file to edit error 1024 and what ever message you wish the end user to see
Code: Select all
<string id="1024">You are out of available character slots. If you think this is a mistake reach out to a GM in discord. (code=1024) </string>


Japeth70
True Believer
 
Posts: 3
Joined: 04 Feb 2017, 04:18

Re: [MOD] SQL to limit characters by account

Post by Japeth70 » 12 Jan 2018, 17:34

Hello so I'm using HeidiSQL and when i run the mod in the Query box i get the error "SQL Error (1370: alter routine command denied to user 'logitec007'@'%for routine 'mysql.f_getCharatweLimit'" Any idea what i can do to fix this?

Return to Game mods

cron