Alignment Setting at every restart

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

Lecner
 
Posts: 3
Joined: 08 Jun 2015, 15:04

Alignment Setting at every restart

Post by Lecner » 11 Sep 2015, 00:45

Hi everyone!

I just can't find the script that sets a characters alignment to a value of your choice at every server restart.
If anyone has it, could he be so awesome and post it here plis or let me know where I can find the damn script??

Thanks!!!


RudgerWolvram
 
Posts: 37
Joined: 01 Jan 2015, 22:27

Re: Alignment Setting at every restart

Post by RudgerWolvram » 11 Sep 2015, 07:16

I did this in 3 parts, mainly because we have more than just alignment setting at restart.

First, i'm assuming that you have your own restart "system", either a bat file, firedaemon, what have you.

First, set up the alignment as a procedure (just to keep things clean)
The below set's the alignment to 100. In Heidi, right click and create a procedure, place this code in it's body.
Code: Select all
BEGIN
   UPDATE `character` set alignment = 1000000;
END


Save the proc.

Then, create a .sql file in something like a scripts directory somewhere. You can use this .sql file for other things as well if you need things to happen at restart.
In the .sql file place the following:

Code: Select all
CALL p_SetAlignment();


In this case, I named the procedure from the earlier step p_SetAlignment.

Then, as part of your restart bat or firedaemon. Add the following (NOTE: this is in .bat format)
Code: Select all
set bin=C:\Path\To\MariaDB 5.5\bin
"%bin%/mysql" --user=root --password=whatever DBName < C:\Path\To\SQLFile.sql


This will run that custom .sql file on the server where DBName is the name you gave the database for your LiF server.

This isn't the only way to do it, but it's the way that works best for us as I have more procedures being called in the .sql file and I only have to add 1 line in the restart portion to get the job done.


Stone_y
 
Posts: 10
Joined: 18 Jun 2016, 04:44

Re: Alignment Setting at every restart

Post by Stone_y » 14 Oct 2016, 16:02

What if you don't have your own restart system? I'm working with a very vanilla server. I just figured out how to run a tree script by adding it to the bottom of the dump.sql file and replacing the file on the server. That's about it.

I'd love to basically eliminate alignment from the server because let's face it. The alignment system sucks if you want to PvP at all.

User avatar
Dragodor
Zealous Believer
 
Posts: 327
Joined: 20 May 2015, 13:08

Re: Alignment Setting at every restart

Post by Dragodor » 24 Mar 2017, 16:59

Is there any mod which will do that?


Neverlamer7
 
Posts: 49
Joined: 04 Aug 2017, 07:23

Re: Alignment Setting at every restart

Post by Neverlamer7 » 03 Jul 2018, 10:28

Dragodor wrote:Is there any mod which will do that?


up

User avatar
Nyuton
Mod Developer
 
Posts: 51
Joined: 01 Feb 2017, 10:51
Location: Berlin

Re: Alignment Setting at every restart

Post by Nyuton » 03 Jul 2018, 16:20

You can simply add this to the end of your main.cs file:

Code: Select all
dbi.Update("UPDATE `character` SET Alignment = 1000000");
My Blog | Custom Maps & Tools for LiF:YO server owners on FeudalTools


Neverlamer7
 
Posts: 49
Joined: 04 Aug 2017, 07:23

Re: Alignment Setting at every restart

Post by Neverlamer7 » 05 Jul 2018, 11:41

Nyuton wrote:You can simply add this to the end of your main.cs file:

Code: Select all
dbi.Update("UPDATE `character` SET Alignment = 1000000");


:Bravo:

User avatar
Arzin
Beta Tester
 
Posts: 33
Joined: 01 Oct 2015, 15:18

Re: Alignment Setting at every restart

Post by Arzin » 05 Jul 2018, 14:08

Or just add event in sql to trigger alignmen update every hour:

Code: Select all
CREATE EVENT Alignment_update
ON SCHEDULE EVERY HOUR
DO
UPDATE `character`
SET alignment = + 1000000;


Neverlamer7
 
Posts: 49
Joined: 04 Aug 2017, 07:23

Re: Alignment Setting at every restart

Post by Neverlamer7 » 06 Jul 2018, 13:06

Ok pros, lets say i need to give fixed amount of karma every hour to those who online, cuz my friend programmer failed to build church with such mechanic. How i can do this by event?

CREATE EVENT Alignment_update
ON SCHEDULE EVERY HOUR
DO
UPDATE `character`
SET alignment +1000000;

How the function must be seen to work only for online players?
Last edited by Neverlamer7 on 09 Jul 2018, 10:56, edited 1 time in total.

User avatar
Arzin
Beta Tester
 
Posts: 33
Joined: 01 Oct 2015, 15:18

Re: Alignment Setting at every restart

Post by Arzin » 07 Jul 2018, 20:09

For now, there is no way to know who is online and who is not.
ofc if you use https://nyuton.net/ livemap then as they have db update on who is online and who is not it might be possible.

User avatar
Nyuton
Mod Developer
 
Posts: 51
Joined: 01 Feb 2017, 10:51
Location: Berlin

Re: Alignment Setting at every restart

Post by Nyuton » 07 Jul 2018, 22:04

You can't really do this through database event, since alignment changes in DB have no effect on online players. At least not reliably.

It's pretty simple to do it with few lines of TorqueScript though:

Code: Select all
$AlignmentUpdateDelta = 5;
$AlignmentUpdateMinutes = 60;

function PlayerList::customAlignmentUpdate( %this ) {
   foreach(%player in %this) %player.changeAlignment($AlignmentUpdateDelta);
   %this.schedule($AlignmentUpdateMinutes * 60000, customAlignmentUpdate);
}

PlayerList.customAlignmentUpdate();


Change the first two variables to define the amount of karma rewarded and the time in minutes between the updates.

If you are using TTmod, you could as well utilize the player enter callback function to attach a scheduler for each player. So it would increase their alignment based on how long they've been online instead of giving everyone karma at the same time and ignoring their time spent online.

Cheers
My Blog | Custom Maps & Tools for LiF:YO server owners on FeudalTools


Neverlamer7
 
Posts: 49
Joined: 04 Aug 2017, 07:23

Re: Alignment Setting at every restart

Post by Neverlamer7 » 09 Jul 2018, 10:54

Great, is it need to be created on server/scripts/server folder or elsewhere? If yes is it compiled from .cs automatically to .dso as server stars?

User avatar
Nyuton
Mod Developer
 
Posts: 51
Joined: 01 Feb 2017, 10:51
Location: Berlin

Re: Alignment Setting at every restart

Post by Nyuton » 09 Jul 2018, 12:11

You can either add it to main.cs or create a separate .cs file and load it trough exec() function like other mods. Up to you. No need to compile anything.
My Blog | Custom Maps & Tools for LiF:YO server owners on FeudalTools


Neverlamer7
 
Posts: 49
Joined: 04 Aug 2017, 07:23

Re: Alignment Setting at every restart

Post by Neverlamer7 » 09 Jul 2018, 20:17

puted into server/scripts/karma.cs, added: exec("scripts/karma.cs"); to main.cs, tested, works fine, no annoying messages on screens upper left corner, like after daily praying, just karma. Very usefull thing and no need to relog. :beer:

Return to Game mods