• 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!

I cant add triggers

kret

K R E T O W N A G E
Joined
Apr 4, 2008
Messages
947
Reaction score
6
Location
PяOLAND
Hello Xd i have problem ... when i create character i get 11 club fighting for example and i logout skills doesnt save :[ i log in again and i got 10 club fighting

i read here i must import triggers so i try :
Code:
DELIMITER |

CREATE TRIGGER `ondelete_accounts`
BEFORE DELETE
ON `accounts`
FOR EACH ROW
BEGIN
    DELETE FROM `bans` WHERE `account` = OLD.`id`;
END|

CREATE TRIGGER `ondelete_guilds`
BEFORE DELETE
ON `guilds`
FOR EACH ROW
BEGIN
    UPDATE `players` SET `guildnick` = '', `rank_id` = 0 WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = OLD.`id`);
END|

CREATE TRIGGER `ondelete_players`
BEFORE DELETE
ON `players`
FOR EACH ROW
BEGIN
    DELETE FROM `bans` WHERE `type` = 2 AND `player` = OLD.`id`;
    UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`;
END|

CREATE TRIGGER `oncreate_guilds`
AFTER INSERT
ON `guilds`
FOR EACH ROW
BEGIN
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('the Leader', 3, NEW.`id`);
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Vice-Leader', 2, NEW.`id`);
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Member', 1, NEW.`id`);
END|

CREATE TRIGGER `oncreate_players`
AFTER INSERT
ON `players`
FOR EACH ROW
BEGIN
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 0, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 1, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 2, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 3, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 4, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 5, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 6, 10);
END|

DELIMITER ;
type this and i have error
Code:
#1235 - This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
i have XAMPP 1.6.6a

when i try
Code:
CREATE TRIGGER `ondelete_accounts`
BEFORE DELETE
ON `accounts`
FOR EACH ROW
BEGIN
    DELETE FROM `bans` WHERE `account` = OLD.`id`;
END|
i have error
Code:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
please help me ;( i need fast help people want play on my otserv and cant XD (New players only) with old players its all OK
 
Last edited:
Maaan.... take it easy, Ronaldino is here xd, so here you go:

Go to phpmyadmin and create a database named theforgottenserver
later paste you database Ex: forgottenserver.sql
in C:/xampp/mysql/bin

later go to start>run and type cmd and click on ok

with the cmd window open type
cd C:\xampp\mysql\bin

later with cmd open,type in
mysql -u root theforgottenserver -p < forgottenserver.sql

it should ask for your password of the database, you type in your password and press enter and ready!

K, THX, BYE :)
 
hmm im stupid i know but
Go to phpmyadmin and create a database named theforgottenserver
later paste you database Ex: forgottenserver.sql
i must create NEW database ? or export my db to file ?


Code:
C:\xampp\mysql\bin>mysql -u root siup -p < siup.sql
Enter password: *********
ERROR 1062 (23000) at line 63: Duplicate entry '2876989' for key 1
w t f ?

and whats now?
 
Last edited:
HEY!

Import this instead of yours one:

DROP TRIGGER IF EXISTS `ondelete_accounts`;
DROP TRIGGER IF EXISTS `oncreate_players`;

DELIMITER |
CREATE TRIGGER `ondelete_accounts`
BEFORE DELETE
ON `accounts`
FOR EACH ROW
BEGIN
DELETE FROM `bans` WHERE `type` != 1 AND `type` != 2 AND `value` = OLD.`id`;
END|

CREATE TRIGGER `ondelete_players`
BEFORE DELETE
ON `players`
FOR EACH ROW
BEGIN
DELETE FROM `bans` WHERE `type` = 2 AND `value` = OLD.`id`;
UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`;
END|
DELIMITER ;

Save it for example in file named "triggers.sql" and paste it in C:/xampp/mysql/bin. Now start - > cmd and with the cmd window open type:
cd C:\xampp\mysql\bin

later with cmd open,type in
mysql -u root NAME_OF_YOUR_DB_HERE -p < trigger.sql

Thats all baby :p
 
C:\xampp\mysql\bin>mysql -u root siup -p < trigger.sql
Enter password: *********
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the ma
nual that corresponds to your MySQL server version for the right syntax to use n
ear '' at line 6
:(( omg :/


Hey i try import this from cmd
DROP TRIGGER IF EXISTS `oncreate_players`;
DROP TRIGGER IF EXISTS `oncreate_guilds`;
DROP TRIGGER IF EXISTS `ondelete_players`;
DROP TRIGGER IF EXISTS `ondelete_guilds`;
DROP TRIGGER IF EXISTS `ondelete_accounts`;

DELIMITER |

CREATE TRIGGER `ondelete_accounts`
BEFORE DELETE
ON `accounts`
FOR EACH ROW
BEGIN
DELETE FROM `bans` WHERE `account` = OLD.`id`;
END|

CREATE TRIGGER `ondelete_guilds`
BEFORE DELETE
ON `guilds`
FOR EACH ROW
BEGIN
UPDATE `players` SET `guildnick` = '', `rank_id` = 0 WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = OLD.`id`);
END|

CREATE TRIGGER `ondelete_players`
BEFORE DELETE
ON `players`
FOR EACH ROW
BEGIN
DELETE FROM `bans` WHERE `type` = 2 AND `player` = OLD.`id`;
UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`;
END|

CREATE TRIGGER `oncreate_guilds`
AFTER INSERT
ON `guilds`
FOR EACH ROW
BEGIN
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('the Leader', 3, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Vice-Leader', 2, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Member', 1, NEW.`id`);
END|

CREATE TRIGGER `oncreate_players`
AFTER INSERT
ON `players`
FOR EACH ROW
BEGIN
INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 0, 10);
INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 1, 10);
INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 2, 10);
INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 3, 10);
INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 4, 10);
INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 5, 10);
INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 6, 10);
END|

DELIMITER ;
and i dont have any error so i make it good ? so i must now import siup.sql from c;\xampp\mysql\bin in phpMyAdmin ;D? \\\ sry but im newbie
 
Last edited:
i need now import this DB in Phpmyadmin ?

edit;1

where i must put shit from this thread http://otland.net/showpost.php?p=79732&postcount=1 xDD?? because i got spam of errors in console ^^ with BANS :/


EDIT:2
ok i got it but
1. Database cleanup error: Unknown table 'bans_backup'
(If error(s) is/are about missing tables, ignore it.)
2. Table backup created.
3. Table created.
4. Bans copying error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1, , 0, , 'Unjustified player killing.', , )' at line 4

EDIT3

i make it but i have errors now too
mysql_real_query(): SELECT `id` FROM `bans` WHERE `account` = 1050614 AND `type`
= 5 AND `active` = 1: MYSQL ERROR: Unknown column 'account' in 'where clause'
mysql_store_result(): SELECT `id` FROM `bans` WHERE `account` = 1050614 AND `typ
e` = 5 AND `active` = 1: MYSQL ERROR: Unknown column 'account' in 'where clause'
 
Last edited:
Back
Top