• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Code for guild war/Help

Softman

New Member
Joined
May 25, 2020
Messages
38
Reaction score
1
Guild war < have Error in mysql
When i use /war invite,


mysql_real_query(): INSERT INTO guild_wars (guild_id, enemy_id, begin, end, frags, payment) VALUES (2, 3, 1590884298, 0, 100, 0); - MYSQL ERROR: Cannot add or update a child row: a foreign key constraint fails (otserv.guild_wars, CONSTRAINT guild1_ibfk_1 FOREIGN KEY (guild1) REFERENCES guilds (id) ON DELETE CASCADE) (1452)
[31/5/2020 2:18:18] > Broadcasted message: "Tanzo has invited Watch Os to war till 100 frags.".
 
Solution
Not sure what begin column related to but I think you are supposed to insert this query, I only replied because you PMed few times and I am not so good with sql queries.
SQL:
ALTER TABLE `guild_wars` ADD `begin` varchar(255)
Your problem is your version of the script uses guild_id and enemy_id

The code you've added from... here? uses guild1 and guild2

You need to pick one style and make all your code use it consistently.
 
LOL was guild war working
but when i change my vps i deleted all code
al i need code for guild war
was working but ineed code onlyUntitled.png
 
Last edited:
Delete the constraints
Delete guild1 and guild2 columns.
And new constraint, using guild_id and enemy_id instead.
Change any code that uses guild1 to use guild_id
Change any code that uses guild2 to use enemy_id


Thats it. If you don't know how to do at step, 10 seconds in google will fix you up.
 
lol cant deleted

#1025 - Error on rename of '.\otserv\#sql-4a8_1fab' to '.\otserv\guild_wars' (errno: 150)
ALTER TABLE guild_wars DROP guild1
 
what the problem. if you are root sql user and you deleted the constraints first there should be no problem.
 
I rester mysql
mysql_real_query(): DELETE FROM guild_wars WHERE status = 0 AND begin < 1590846929; - MYSQL ERROR: Unknown column 'begin' in 'where clause' (1054)


[1/6/2020 17:7:27] mysql_real_query(): INSERT INTO guild_wars (guild_id, enemy_id, begin, end, frags, payment) VALUES (1, 2, 1591024047, 0, 100, 0); - MYSQL ERROR: Unknown column 'begin' in 'field list' (1054)
[1/6/2020 17:7:27] > Broadcasted message: "xdd has invited xddd to war till 100 frags.".
 
Last edited:
wow, yeah, you are missing the begin and payment columns

SQL:
    DROP TABLE IF EXISTS `guild_wars`;

    CREATE TABLE `guild_wars`
    (
        `id`          INT        UNSIGNED NOT NULL AUTO_INCREMENT,
        `guild_id`    SMALLINT   UNSIGNED NOT NULL,
        `enemy_id`    SMALLINT   UNSIGNED NOT NULL,
        `begin`       BIGINT              NOT NULL DEFAULT 0,
        `end`         BIGINT              NOT NULL DEFAULT 0,
        `frags`       INT        UNSIGNED NOT NULL DEFAULT 0,
        `payment`     BIGINT     UNSIGNED NOT NULL DEFAULT 0,
        `guild_kills` INT        UNSIGNED NOT NULL DEFAULT 0,
        `enemy_kills` INT        UNSIGNED NOT NULL DEFAULT 0,
        `status`      TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
        PRIMARY KEY (`id`), KEY `status` (`status`),
        KEY `guild_id` (`guild_id`), KEY `enemy_id` (`enemy_id`),
        FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE CASCADE,
        FOREIGN KEY (`enemy_id`) REFERENCES `guilds`(`id`) ON DELETE CASCADE
    ) ENGINE = InnoDB;

The SQL from my server. You'll probably to change the size types back to match what you are using. (I optimized my schema cuz the original sucked.)
 
Error << >>Error

Lua:
#1005 - Can't create table 'otserv.guild_wars' (errno: 150)
CREATE TABLE `guild_wars` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`guild_id` SMALLINT UNSIGNED NOT NULL ,
`enemy_id` SMALLINT UNSIGNED NOT NULL ,
`begin` BIGINT NOT NULL DEFAULT 0,
`end` BIGINT NOT NULL DEFAULT 0,
`frags` INT UNSIGNED NOT NULL DEFAULT 0,
`payment` BIGINT UNSIGNED NOT NULL DEFAULT 0,
`guild_kills` INT UNSIGNED NOT NULL DEFAULT 0,
`enemy_kills` INT UNSIGNED NOT NULL DEFAULT 0,
`status` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY ( `id` ) ,
KEY `status` ( `status` ) ,
KEY `guild_id` ( `guild_id` ) ,
KEY `enemy_id` ( `enemy_id` ) ,
FOREIGN KEY ( `guild_id` ) REFERENCES `guilds` ( `id` ) ON DELETE CASCADE ,
FOREIGN KEY ( `enemy_id` ) REFERENCES `guilds` ( `id` ) ON DELETE CASCADE
) ENGINE = InnoDB;
 
You are hitting foreign key constraints, probably because I use different sizes... I said you'd have to change that code.

Bash:
mysqldump -u root --no-data your_ot_db > dump-schema.sql

The upload this file that contains just your schema somewhere I can see it.
 
wow, yeah, you are missing the begin and payment columns

SQL:
    DROP TABLE IF EXISTS `guild_wars`;

    CREATE TABLE `guild_wars`
    (
        `id`          INT        UNSIGNED NOT NULL AUTO_INCREMENT,
        `guild_id`    SMALLINT   UNSIGNED NOT NULL,
        `enemy_id`    SMALLINT   UNSIGNED NOT NULL,
        `begin`       BIGINT              NOT NULL DEFAULT 0,
        `end`         BIGINT              NOT NULL DEFAULT 0,
        `frags`       INT        UNSIGNED NOT NULL DEFAULT 0,
        `payment`     BIGINT     UNSIGNED NOT NULL DEFAULT 0,
        `guild_kills` INT        UNSIGNED NOT NULL DEFAULT 0,
        `enemy_kills` INT        UNSIGNED NOT NULL DEFAULT 0,
        `status`      TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
        PRIMARY KEY (`id`), KEY `status` (`status`),
        KEY `guild_id` (`guild_id`), KEY `enemy_id` (`enemy_id`),
        FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE CASCADE,
        FOREIGN KEY (`enemy_id`) REFERENCES `guilds`(`id`) ON DELETE CASCADE
    ) ENGINE = InnoDB;

The SQL from my server. You'll probably to change the size types back to match what you are using. (I optimized my schema cuz the original sucked.)
IS no working....
CREATE TABLE guild_wars (
id int(11) NOT NULL,
guild1 int(11) NOT NULL DEFAULT '0',
guild2 int(11) NOT NULL DEFAULT '0',
name1 varchar(255) NOT NULL,
name2 varchar(255) NOT NULL,
status tinyint(2) NOT NULL DEFAULT '0',
started bigint(15) NOT NULL DEFAULT '0',
ended bigint(15) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
< IS working in mysql . I need all code for done < Do you can give me code
 
Last edited:
< IS working in mysql . I need all code for done < Do you can give me code

I gave you instructions. I can't make the table creation query match your database without your schemata. Give me your database schema, with the mysqldump command I give you, and I will adapt the query. That --no-data flag means its just the schema.
 
Lua:
CREATE TABLE guild_wars (
id int(11) NOT NULL,
guild1 int(11) NOT NULL DEFAULT '0',
guild2 int(11) NOT NULL DEFAULT '0',
name1 varchar(255) NOT NULL,
name2 varchar(255) NOT NULL,
status tinyint(2) NOT NULL DEFAULT '0',
started bigint(15) NOT NULL DEFAULT '0',
ended bigint(15) NOT NULL DEFAULT '0
This is Work in mysql-- but i need code .Untitled.png
 
I told him how to fix one of the issues in another thread but doesn't listen.
Just wants something to copy and paste as he doesn't know what he's doing.
 
last code IS error in mysql



#1005 - Can't create table 'otserv.guild_wars' (errno: 150)
Lua:
 CREATE TABLE `guild_wars`
    (
        `id`          INT        UNSIGNED NOT NULL AUTO_INCREMENT,
        `guild_id`    SMALLINT   UNSIGNED NOT NULL,
        `enemy_id`    SMALLINT   UNSIGNED NOT NULL,
        `begin`       BIGINT              NOT NULL DEFAULT 0,
        `end`         BIGINT              NOT NULL DEFAULT 0,
        `frags`       INT        UNSIGNED NOT NULL DEFAULT 0,
        `payment`     BIGINT     UNSIGNED NOT NULL DEFAULT 0,
        `guild_kills` INT        UNSIGNED NOT NULL DEFAULT 0,
        `enemy_kills` INT        UNSIGNED NOT NULL DEFAULT 0,
        `status`      TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
        PRIMARY KEY (`id`), KEY `status` (`status`),
        KEY `guild_id` (`guild_id`), KEY `enemy_id` (`enemy_id`),
        FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE CASCADE,
        FOREIGN KEY (`enemy_id`) REFERENCES `guilds`(`id`) ON DELETE CASCADE
    ) ENGINE = InnoDB;
 

Attachments

Last edited:
#1005 - Can't create table 'otserv.guild_wars' (errno: 150)

If you ran it and it was successful... then your problem should be solved. There is no reason to run it more than once if it worked the first time.

I told him how to fix one of the issues in another thread but doesn't listen.
Just wants something to copy and paste as he doesn't know what he's doing.
Yeah, I'm pretty sure I'm done here.
 
Back
Top