[MOD][WIP] Custom Player Titles v0.3.5

Place for sharing your game modifications for Life is Feudal: Your Own
User avatar
Chessmaster42
 
Posts: 23
Joined: 30 Sep 2014, 22:05

[MOD][WIP] Custom Player Titles v0.3.5

Post by Chessmaster42 » 25 Oct 2014, 23:43

So I've been busy on a number of mods that operate solely within the server SQL database and I have one that is pretty simple that I think some server admins might like.

Nobility Titles
  • King - 1 per server - 100 Authority
  • Duke - 5 per server - 90+ Authority
  • Count - 15 per server - 60+ Authority
  • Baron - 50 per server - 30+ Authority
  • Peasant - Unlimited per server - 0+ Authority
Religious Titles
  • Pope - 1 per server - 100 Piety, 250+ Alignment
  • Cardinal - 10 per server - 100 Piety, 50+ Alignment
Military Titles
  • Commander - 100 Unit and Formation
  • Officer - 90+ Unit and Formation
  • Sergeant - 60+ Unit and Formation

SQL Code

Code: Select all
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (1, 'Game Master Title', 762);

INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (2, 'King Title', 650);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (3, 'Duke Title', 648);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (4, 'Count Title', 646);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (5, 'Baron Title', 642);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (6, 'Peasant Title', 636);

INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (7, 'Recruit Title', 620);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (8, 'Sergant Title', 624);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (9, 'Officer Title', 628);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (10, 'Commander Title', 630);

INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (11, 'Pope Title', 597);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (12, 'Cardinal Title', 596);

CREATE DEFINER=`root`@`localhost` TRIGGER `t_addCharacterTitle_SkillChange` AFTER UPDATE ON `skills` FOR EACH ROW BEGIN
   IF NEW.SkillTypeID = 65 THEN
      IF NEW.LockStatus > 0 THEN
         SET @kingCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 2);
         SET @dukeCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 3);
         SET @countCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 4);
         SET @baronCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 5);
         IF NEW.SkillAmount = 1000000000 AND @kingCount = 0 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 2);
         ELSEIF NEW.SkillAmount > 900000000 AND @dukeCount < 5 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 3);
         ELSEIF NEW.SkillAmount > 600000000 AND @countCount < 15 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 4);
         ELSEIF NEW.SkillAmount > 300000000 AND @baronCount < 50 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 5);
         ELSEIF NEW.SkillAmount > 0 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 6);
         END IF;
      END IF;
      IF NEW.SkillAmount < 1000000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND TitleID = 2;
      END IF;
      IF NEW.SkillAmount < 900000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND TitleID = 3;
      END IF;
      IF NEW.SkillAmount < 600000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND TitleID = 4;
      END IF;
      IF NEW.SkillAmount < 300000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND TitleID = 5;
      END IF;
   END IF;
   IF NEW.SkillTypeID = 54 THEN
      IF NEW.LockStatus > 0 THEN
         SET @popeCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 11);
         SET @cardinalCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 12);
         IF NEW.SkillAmount = 1000000000 THEN
            SET @characterAlignment = (SELECT ch.Alignment FROM `character` ch WHERE ch.ID = NEW.CharacterID);
            IF @characterAlignment = 250000000 AND @popeCount = 0 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 11);
            ELSEIF @characterAlignment > 50000000 AND @cardinalCount < 10 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 12);
            END IF;
         END IF;
      END IF;
      IF NEW.SkillAmount < 1000000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND (TitleID = 11 OR TitleID = 12);
      END IF;
   END IF;
   IF NEW.SkillTypeID = 56 THEN
      IF NEW.LockStatus > 0 THEN
         IF NEW.SkillAmount = 1000000000 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 10);
         ELSEIF NEW.SkillAmount > 900000000 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 9);
         ELSEIF NEW.SkillAmount > 600000000 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 8);
         END IF;
      END IF;
      IF NEW.SkillAmount < 1000000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND TitleID = 10;
      END IF;
      IF NEW.SkillAmount < 900000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND TitleID = 9;
      END IF;
      IF NEW.SkillAmount < 600000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND TitleID = 8;
      END IF;
   END IF;
END

CREATE DEFINER=`root`@`localhost` TRIGGER `t_addCharacterTitle_CharacterChange` BEFORE UPDATE ON `character` FOR EACH ROW BEGIN
   SET @pietyAmount = (SELECT sk.SkillAmount FROM skills sk WHERE sk.CharacterID = NEW.ID AND sk.SkillTypeID = 54);
   IF @pietyAmount = 1000000000 THEN
      SET @popeCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 11);
      SET @cardinalCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 12);
      IF NEW.Alignment > 250000000 AND @popeCount = 0 THEN
         CALL p_addCharacterTitle(NEW.ID, 11);
      ELSEIF @characterAlignment > 50000000 AND @cardinalCount < 10 THEN
         CALL p_addCharacterTitle(NEW.ID, 12);
      END IF;
      IF NEW.Alignment < 250000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 11;
      END IF;
      IF NEW.Alignment < 50000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 12;
      END IF;
   END IF;
END

CREATE DEFINER=`root`@`localhost` PROCEDURE `p_addCharacterTitle`(IN `in_characterID` INT, IN `in_titleID` INT)
   LANGUAGE SQL
   NOT DETERMINISTIC
   MODIFIES SQL DATA
   SQL SECURITY DEFINER
   COMMENT ''
BEGIN
   IF in_characterID > 0 AND in_titleID > 0 THEN
      SET @currentCount = (SELECT COUNT(*) FROM character_titles ct WHERE ct.CharacterID = in_characterID AND ct.TitleID = in_titleID);
      IF @currentCount = 0 THEN
         INSERT IGNORE INTO character_titles (`CharacterID`, `TitleID`) VALUES (in_characterID, in_titleID);
      END IF;
   END IF;
END


This is mostly just a proof-of-concept but it works and provides basic nobility rank titles based on the player's Authority skill value. Much more complex functionality is possible and will be implemented eventually.

Let me know what you guys think and if anyone has any issues with it :)

Change Log

v0.3.5 - Added title delete and better alignment check
v0.3.0 - Added religious and military titles
v0.2.0 - Fixed some major bugs
v0.1.0 - Initial Release
Last edited by Chessmaster42 on 28 Oct 2014, 17:21, edited 4 times in total.

User avatar
Adamld85
 
Posts: 40
Joined: 06 Oct 2014, 00:38

Re: [MOD][WIP] Custom Player Titles v0.3.0

Post by Adamld85 » 26 Oct 2014, 07:06

This is awesome man. Thank you so much for sharing this. Is this meant to be run in a query? I've looked at a few of the mods you have posted and all have errors when I paste them into the SQL Query.
LT.
Image
7Gamers.com.au

User avatar
Atlantis
 
Posts: 114
Joined: 30 Sep 2014, 15:17

Re: [MOD][WIP] Custom Player Titles v0.3.0

Post by Atlantis » 26 Oct 2014, 07:57

I like it, problem is, as soon as you disconnect, you seem to "deselect" your current title. When you reconnect you have to select it again, so a limitation on the server is kind of useless (right now).

But anyway nice sharing, makes things interesting. Is it maybe possible for an admin to control a player's title throught the DB?
Player with Steam_ID XYZ -> Title = 'Pope'?

User avatar
Chessmaster42
 
Posts: 23
Joined: 30 Sep 2014, 22:05

Re: [MOD][WIP] Custom Player Titles v0.3.0

Post by Chessmaster42 » 26 Oct 2014, 10:27

Atlantis wrote:...
But anyway nice sharing, makes things interesting. Is it maybe possible for an admin to control a player's title throught the DB?
Player with Steam_ID XYZ -> Title = 'Pope'?


Yeah, that's totally possible to have titles tied to specific steam accounts but I'd prefer to only tie to characters not the full account. And modifying the characters titles is very easy to do on the SQL DB side of things if you know what you're doing.

User avatar
Somerlot
 
Posts: 50
Joined: 26 Sep 2014, 01:27

Re: [MOD][WIP] Custom Player Titles v0.3.0

Post by Somerlot » 27 Oct 2014, 05:07

Nice work! Wish my knowledge of SQL didnt end with basic Access stuff. This game has pretty good mod'ing potential.
Image

User avatar
Chessmaster42
 
Posts: 23
Joined: 30 Sep 2014, 22:05

Re: [MOD][WIP] Custom Player Titles v0.3.0

Post by Chessmaster42 » 28 Oct 2014, 17:04

Updated to v0.3.5

  • Added functionality to remove titles when requirements are no longer met
  • Added support to properly check alignment changes for religious titles
  • Fixed bug with duplicate title entries

User avatar
SirWinston
Alpha Tester
 
Posts: 460
Joined: 10 Mar 2014, 17:00
Location: France

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by SirWinston » 31 Oct 2014, 21:43

The problem with this is that eventually everyone will be a noble which defeats the purpose.
Spoiler

User avatar
Chessmaster42
 
Posts: 23
Joined: 30 Sep 2014, 22:05

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Chessmaster42 » 31 Oct 2014, 23:44

Winston wrote:The problem with this is that eventually everyone will be a noble which defeats the purpose.


The next big update will have more complex calculations that include claimed buildings among other things. My hope it to have it so that, for example, in order to be king you have to have claim to a large keep or something like that. And for the other titles have claim to the other "home" type buildings. I'm also considering looking at the total number of characters on the server so that a server that only has 10 characters can't have more than 1 Count or something.

I'm open to any ideas you might have to improve this. Most of it is completely arbitrary.

User avatar
SirWinston
Alpha Tester
 
Posts: 460
Joined: 10 Mar 2014, 17:00
Location: France

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by SirWinston » 02 Nov 2014, 15:29

Chessmaster42 wrote: I'm also considering looking at the total number of characters on the server so that a server that only has 10 characters can't have more than 1 Count or something.


I like this, we did the same on our server but it's a completely out of game rule. Would be awesome to be able to enforce it with game mechanics.
Spoiler


MasterChief
True Believer
 
Posts: 55
Joined: 04 Oct 2014, 11:11

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by MasterChief » 23 Nov 2014, 10:13

i like this mod, are any updates here ?


Vendaar
 
Posts: 2
Joined: 08 Dec 2014, 02:18

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Vendaar » 08 Dec 2014, 02:19

I got this error :(

/* SQL Fehler (1064) in Anweisung #13: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE DEFINER=`root`@`localhost` TRIGGER `t_addCharacterTitle_CharacterChange` ' at line 29 */
/* Affected rows: 0 Gefundene Zeilen: 0 Warnungen: 0 Dauer von 0 of 71 queries: 0,000 sec. */

User avatar
GruFF
Zealous Believer
 
Posts: 111
Joined: 20 Sep 2014, 02:06

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by GruFF » 10 Dec 2014, 21:09

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (1, 'Game M' at line 1
[Err] INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (1, 'Game Master Title', 762) etc....


Lequeb
 
Posts: 5
Joined: 04 Dec 2014, 10:17

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Lequeb » 16 Dec 2014, 17:52

Yup same error here.

Definitly not working at all.

Thanks for effort.


Zengetzu
 
Posts: 10
Joined: 13 Sep 2014, 14:51

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Zengetzu » 06 Jan 2015, 15:22

All right so im new to the modding idea and need help/questions on this.
I have heidisql and have already changed claim times and alt char alignments but I cant see where the titles are nothing shows up in the data.
Also where would i enter that code to change the titles. ideally I would just like to give titles to players steam IDs.
I seen someone comment but i dont understand it.
I have also looked for guides for this but not much there.

thank you

ok so i have been looking at the code and think i can change it so that the players will have titles based solely on their alignment.
that way i can go in and change their alignment to whatever.
I know this is totally round about but im still new to this also where do i add the code just to "query" and send batch in one go?
just not sure where to do that at or if it matters.
I did do that before when i was setting up my dedicated server


Balax
 
Posts: 40
Joined: 30 Sep 2014, 11:03
Location: Norway

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Balax » 06 Jan 2015, 21:20

I have given this some thought, and this might be a solution.
I have not tried this myself, so as always make the necessary backups.

Open the files on your server with "FileZilla" or similar program.
Under "data" you will find CM_MESSAGES.XML.

Open that file and check out line Line 490 - 670 which
describes all the different titles. Then minimize it for now.

In heidsSql, find "titles" at the bottom.
Under data, add line. There are three rows, "ID", "NAME" and "TitleMessageID"

Now, all the titles you want to put in will have an unique number from 1 going up.

So "ID" is 1, 2, 3, 4, 5 and so on.

"NAME" is your description of the title, for example king.

"TitleMessageID" from CM_MESSAGES.XML is the ID-line where you find the title you want,
in this example 650 which is the number for King.

So it would look like this:

ID Name TitleMessageID
1 King 650
2 Queen 651
3 Officer 628

Now find the table called Character_titles.

Add line, ID is same as above, 1,2,3,4 and so on.
Fill in #ID of the character in question, which you find under SQL-table "Character".
The third thing is the title you made above.

So for character 3 it should look like this if he is to be the king:

ID CharacterID TitleID
1 3 1

and so on and so on.

I want to make clear again that I have NOT tested this out.
This is merely a suggestion of something you can try.
All you do is your own responsibility.

BTW, I do not know what this will do to the title you choose yourself under the "Person" window in-game. But someone daring might find out. It might appear above it, or as an option in the pull-down menu. Time will tell.

Good luck!


Zengetzu
 
Posts: 10
Joined: 13 Sep 2014, 14:51

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Zengetzu » 07 Jan 2015, 04:11

ok so the way i see it, i can just change the title names in the cm_messages and then it should show up different in game. Or so i think but when i open my cm_messages.xml file from both my dedicated server and my blackbox server it just shows alittle bit not titles and the blackbox server says

"This page contains the following errors:

error on line 69 at column 17: xmlParseCharRef: invalid xmlChar value 7
Below is a rendering of the page up to the first error."

the last thing that it shows is "You have succesfully tamed the %1"

So my question is if i can get the cm_message to work can i change for example the title of grandmaster cook = chief or pope = monk and it will reflect in game when a charater should show grandmaster x it will instead show what i want.


Balax
 
Posts: 40
Joined: 30 Sep 2014, 11:03
Location: Norway

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Balax » 07 Jan 2015, 08:52

Zengetzu wrote:ok so the way i see it, i can just change the title names in the cm_messages and then it should show up different in game.


In theory, yes. If both server and client have the same changes in the same files.

Zengetzu wrote: Or so i think but when i open my cm_messages.xml file from both my dedicated server and my blackbox server it just shows alittle bit not titles and the blackbox server says

"This page contains the following errors:

error on line 69 at column 17: xmlParseCharRef: invalid xmlChar value 7
Below is a rendering of the page up to the first error."

the last thing that it shows is "You have succesfully tamed the %1"

I dont know why this happens. Have you any other mods or changes in your game that you have downloaded or similar, or are your files vanilla?

Zengetzu wrote: So my question is if i can get the cm_message to work can i change for example the title of grandmaster cook = chief or pope = monk and it will reflect in game when a charater should show grandmaster x it will instead show what i want.


This might be the case, yes. However if I can give any practical advice at this point it would be to change only one thing at a time and then check for success/failure. One thing at a time until you are sure of how it works.

Good luck!


Zengetzu
 
Posts: 10
Joined: 13 Sep 2014, 14:51

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Zengetzu » 07 Jan 2015, 15:22

Ok so first question how does one change the client side info for someone other than myself? thats what i understand from it

I also figured out how to edit my cm_messages i changed pope to monk and a few others as a test but nothing has changed in game.

i only edited the cm_message.xml file and nothing in heidisql but i have a feeling im going to have to do that. I am thinking that either the client side doesnt allow it or something in the patch.sql override it like in the claim times.

I have figured out most of the code for the heidisql. Guessing it gets rid of all other titles except those u add. I dont mind this but would like to avoid it if i can.

If i do use that code where do i add it? under "titles" or "charater titles"? and i simple plug it in through the "query" right

Thanks


Zengetzu
 
Posts: 10
Joined: 13 Sep 2014, 14:51

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Zengetzu » 07 Jan 2015, 17:08

ok so i tried change the titles in cm_message in both server side and client side files. The result is

Image

Only problem is that I only can see the title and no one else can. Guessing that means they need to change the files as well in order to see it. This just means i need to get almost 70 players to change their client side game files which i do not see happening.

Ah i just put two and two together and understand the code he used (650) is king thats already in the game thats why it will show on everyones game. Looks like the only way/easiest way to change titles is through sqlcode. Still dont know where to add the code at in heidisql


Zengetzu
 
Posts: 10
Joined: 13 Sep 2014, 14:51

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Zengetzu » 07 Jan 2015, 20:53

Ok so I changed the code post on this page to reflect what I am wanting. Others are free to try it out. I have not and I was wondering if anyone wants to look to see if its functional.
It is based on the GM changing players alignment to give them titles so if a server elects a king the GM can make the alignment of the king 900 which will give him the title king. Same code used for the pope and cardinal that was posted.
Code: Select all
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (1, 'Game Master Title', 762);

INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (2, 'King Title', 650);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (3, 'Duke Title', 648);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (4, 'Count Title', 646);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (5, 'Baron Title', 642);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (6, 'Knight Title', 626);

INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (7, 'Peasant Title', 636);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (8, 'Sergant Title', 624);

INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (9, 'Crusader Title', 655);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (10, 'Royal Knight Title', 653);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (11, 'Pope Title', 597);
INSERT IGNORE INTO titles (`ID`, `Name`, `TitleMessageID`) VALUES (12, 'Cardinal Title', 596);

CREATE DEFINER=`root`@`localhost` TRIGGER `t_addCharacterTitle_SkillChange` AFTER UPDATE ON `skills` FOR EACH ROW BEGIN
   IF NEW.SkillTypeID = 65 THEN
      IF NEW.LockStatus > 0 THEN
         SET @kingCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 2);
         SET @dukeCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 3);
         SET @countCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 4);
         SET @baronCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 5);
         SET @KnightCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 6);
         IF NEW.SkillAmount = 1000000000 THEN
            SET @characterAlignment = (SELECT ch.Alignment FROM `character` ch WHERE ch.ID = NEW.CharacterID);
            IF @characterAlignment = 900000000 AND @KingCount = 0 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 2);
            ELSEIF @characterAlignment > 800000000 AND @DukeCount < 10 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 3);
            ELSEIF @characterAlignment > 700000000 AND @CountCount < 10 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 4);
            ELSEIF @characterAlignment > 600000000 AND @BaronCount < 10 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 5);
            ELSEIF @characterAlignment > 500000000 AND @KnightCount < 10 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 6);
            END IF;
         END IF;
      END IF;
   IF NEW.SkillAmount < 1000000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND (TitleID = 2 OR TitleID = 3);
      END IF;
   END IF;IF NEW.SkillTypeID = 65 THEN
      IF NEW.LockStatus > 0 THEN
         SET @kingCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 2);
         SET @dukeCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 3);
         SET @countCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 4);
         SET @baronCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 5);
         SET @KnightCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 6);
         IF NEW.SkillAmount = 1000000000 AND @kingCount = 0 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 2);
         ELSEIF NEW.SkillAmount > 1000000000 AND @dukeCount < 5 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 3);
         ELSEIF NEW.SkillAmount > 1000000000 AND @countCount < 15 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 4);
         ELSEIF NEW.SkillAmount > 1000000000 AND @baronCount < 50 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 5);
         ELSEIF NEW.SkillAmount > 1000000000 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 6);
         END IF;
   END IF;
   IF NEW.SkillTypeID = 54 THEN
      IF NEW.LockStatus > 0 THEN
         SET @CrusaderCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 9);
         SET @Royal KnightCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 10);
         SET @popeCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 11);
         SET @cardinalCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 12);
         IF NEW.SkillAmount = 1000000000 THEN
            SET @characterAlignment = (SELECT ch.Alignment FROM `character` ch WHERE ch.ID = NEW.CharacterID);
            IF @characterAlignment = 900000000 AND @popeCount = 0 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 11);
            ELSEIF @characterAlignment > 800000000 AND @cardinalCount < 10 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 12);
            ELSEIF @characterAlignment > 500000000 AND @Royal KnightCount < 10 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 10);
            ELSEIF @characterAlignment > 100000000 AND @CrusdaerCount < 10 THEN
               CALL p_addCharacterTitle(NEW.CharacterID, 9);
            END IF;
         END IF;
      END IF;
      IF NEW.SkillAmount < 1000000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND (TitleID = 11 OR TitleID = 12);
      END IF;
   END IF;
   IF NEW.SkillTypeID = 31 THEN
      IF NEW.LockStatus > 0 THEN
         IF NEW.SkillAmount = 1000000000 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 8);
         ELSEIF NEW.SkillAmount > 900000000 THEN
            CALL p_addCharacterTitle(NEW.CharacterID, 7);
         END IF;
      END IF;
      IF NEW.SkillAmount < 1000000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.CharacterID AND TitleID = 8;
      END IF;
   END IF;
END

CREATE DEFINER=`root`@`localhost` TRIGGER `t_addCharacterTitle_CharacterChange` BEFORE UPDATE ON `character` FOR EACH ROW BEGIN
   SET @pietyAmount = (SELECT sk.SkillAmount FROM skills sk WHERE sk.CharacterID = NEW.ID AND sk.SkillTypeID = 54);
   IF @pietyAmount = 1000000000 THEN
      SET @CrusaderCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 9);
      SET @Royal KnightCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 10);
      SET @popeCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 11);
      SET @cardinalCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 12);
      IF NEW.Alignment > 900000000 AND @popeCount = 0 THEN
         CALL p_addCharacterTitle(NEW.ID, 11);
      ELSEIF @characterAlignment > 800000000 AND @cardinalCount < 10 THEN
         CALL p_addCharacterTitle(NEW.ID, 12);
      END IF;
      IF NEW.Alignment < 500000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 10;
      END IF;
      IF NEW.Alignment < 100000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 9;
      END IF;
   END IF;
END

CREATE DEFINER=`root`@`localhost` TRIGGER `t_addCharacterTitle_CharacterChange` BEFORE UPDATE ON `character` FOR EACH ROW BEGIN
   SET @AuthorityAmount = (SELECT sk.SkillAmount FROM skills sk WHERE sk.CharacterID = NEW.ID AND sk.SkillTypeID = 65);
   IF @AuthorityAmount = 1000000000 THEN
      SET @KingCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 2);
      SET @DukeCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 3);
      SET @CountCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 4);
      SET @BaronCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 5);
      SET @KnightCount = (SELECT COUNT(*) FROM character_titles WHERE TitleID = 6);
      IF NEW.Alignment > 900000000 AND @KingCount = 0 THEN
         CALL p_addCharacterTitle(NEW.ID, 2);
      ELSEIF @characterAlignment > 800000000 AND @DukeCount < 10 THEN
         CALL p_addCharacterTitle(NEW.ID, 3);
      ELSEIF @characterAlignment > 700000000 AND @CountCount < 10 THEN
         CALL p_addCharacterTitle(NEW.ID, 4);
      ELSEIF @characterAlignment > 600000000 AND @BaronCount < 10 THEN
         CALL p_addCharacterTitle(NEW.ID, 5);
      ELSEIF @characterAlignment > 500000000 AND @KnightCount < 10 THEN
         CALL p_addCharacterTitle(NEW.ID, 6);
      END IF;
      IF NEW.Alignment < 900000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 2;
      END IF;
      IF NEW.Alignment < 800000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 3;
      END IF;
      IF NEW.Alignment < 700000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 4;
      END IF;
      IF NEW.Alignment < 600000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 5;
      END IF;
      IF NEW.Alignment < 500000000 THEN
         DELETE FROM character_titles WHERE CharacterID = NEW.ID AND TitleID = 6;
      END IF;
   END IF;
END

CREATE DEFINER=`root`@`localhost` PROCEDURE `p_addCharacterTitle`(IN `in_characterID` INT, IN `in_titleID` INT)
   LANGUAGE SQL
   NOT DETERMINISTIC
   MODIFIES SQL DATA
   SQL SECURITY DEFINER
   COMMENT ''
BEGIN
   IF in_characterID > 0 AND in_titleID > 0 THEN
      SET @currentCount = (SELECT COUNT(*) FROM character_titles ct WHERE ct.CharacterID = in_characterID AND ct.TitleID = in_titleID);
      IF @currentCount = 0 THEN
         INSERT IGNORE INTO character_titles (`CharacterID`, `TitleID`) VALUES (in_characterID, in_titleID);
      END IF;
   END IF;
END



Authority 100 (65)
King alignment 900
Duke alignment 800
Count alignment 700
Baron alignment 600
Knight alignment 500

Piety 100 (54)
Pope alignment 900
Cardinal alignment 800
Royal Knight alignment 500
Crusader alignment 100

Militia (31)
Sergeant militia 90
Peasant militia 0-80


NOTE this code is based on the code given and I left the Count measurements just because I didnt want to delete them.
I also do not know if this will work but I will try it shortly


Ok so I tried the code and got the same error as the other guy and was able to fix/figure it out but then it just gave me another error on another line. This one makes no since. The (if new.lock status) is being rejected and Idk y bc I didn't mess with it. Guess I might just have to try the original code see if it even works.


Ziong18
 
Posts: 107
Joined: 09 Oct 2014, 03:48

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Ziong18 » 16 Jan 2015, 02:46

Any updates on this mod? Anybody got it to work yet?

User avatar
Ghost_swe79
True Believer
 
Posts: 41
Joined: 16 Apr 2015, 12:17
Location: Sweden

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Ghost_swe79 » 14 Oct 2015, 11:33

Anymore new news about this?


Riosja
Zealous Believer
 
Posts: 1
Joined: 10 Jun 2016, 21:30

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Riosja » 10 Jun 2016, 21:32

:Yahoo!: how do i install this mod? Are there any updates?


Gms0012
 
Posts: 166
Joined: 23 Feb 2015, 08:49

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Gms0012 » 11 Jun 2016, 10:17

"install" ???

it is a sql script...!

if you dont know what sql is, you should keep your fingers away from it.
Image


Jmansmann
 
Posts: 1
Joined: 05 Sep 2017, 21:11

Re: [MOD][WIP] Custom Player Titles v0.3.5

Post by Jmansmann » 05 Sep 2017, 21:16

Just a question, is there a way to make the titles set to a specific player with out the requirements we run a RP server and this would be great.

Return to Game mods