Page 1 of 1

Triggers.sql

Posted: Sun Jun 21, 2015 3:18 pm
by Drinkie
I imagine you guys are sick of hearing about this issue so my apologies but whenever i try to execute triggers.sql all i get is this message

[Err] 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 'SET NAMES 'utf8'' at line 1
[Err] SET NAMES 'utf8';
[Msg] Finished - Unsuccessfully

I have searched for this issue on here but i haven't found any results relating to this any help would be welcome also have i asked about this issue before or not? my memory seems to be getting worse these days old age perhaps :P

Edit: I forgot but in case it's needed here's what's in said file when i open it up in notepad



SET NAMES 'utf8';

DELIMITER $$

DROP TRIGGER IF EXISTS auction_house_buy $$
CREATE TRIGGER auction_house_buy
BEFORE UPDATE ON auction_house
FOR EACH ROW
BEGIN
IF OLD.seller != 0 AND NEW.sale != 0 THEN INSERT INTO delivery_box VALUES (NEW.seller, NEW.seller_name, 1, 0, 0xFFFF, NEW.itemid, NEW.sale, NULL, 0, 'AH-Jeuno', 0, 0); END IF;
END $$

DROP TRIGGER IF EXISTS delivery_box_insert $$
CREATE TRIGGER delivery_box_insert
BEFORE INSERT ON delivery_box
FOR EACH ROW
BEGIN
SET @slot := 0;
SELECT MAX(slot) INTO @slot FROM delivery_box WHERE box = NEW.box AND charid = NEW.charid;
IF NEW.box = 1 THEN
IF @slot IS NULL OR @slot < 8 THEN SET NEW.slot := 8; ELSE SET NEW.slot := @slot + 1; END IF;
END IF;
END $$


DROP TRIGGER IF EXISTS account_delete $$
CREATE TRIGGER account_delete
BEFORE DELETE ON accounts
FOR EACH ROW
BEGIN
DELETE FROM `accounts_banned` WHERE `accid` = OLD.id;
DELETE FROM `chars` WHERE `accid` = OLD.id;
END $$

DROP TRIGGER IF EXISTS session_delete $$
CREATE TRIGGER session_delete
BEFORE DELETE ON accounts_sessions
FOR EACH ROW
BEGIN
UPDATE `char_stats` SET zoning = 0 WHERE `charid` = OLD.charid;
END $$

DROP TRIGGER IF EXISTS char_delete $$
CREATE TRIGGER char_delete
BEFORE DELETE ON chars
FOR EACH ROW
BEGIN
DELETE FROM `char_effects` WHERE `charid` = OLD.charid;
DELETE FROM `char_equip` WHERE `charid` = OLD.charid;
DELETE FROM `char_exp` WHERE `charid` = OLD.charid;
DELETE FROM `char_inventory` WHERE `charid` = OLD.charid;
DELETE FROM `char_jobs` WHERE `charid` = OLD.charid;
DELETE FROM `char_look` WHERE `charid` = OLD.charid;
DELETE FROM `char_pet` WHERE `charid` = OLD.charid;
DELETE FROM `char_points` WHERE `charid` = OLD.charid;
DELETE FROM `char_profile` WHERE `charid` = OLD.charid;
DELETE FROM `char_skills` WHERE `charid` = OLD.charid;
DELETE FROM `char_stats` WHERE `charid` = OLD.charid;
DELETE FROM `char_storage` WHERE `charid` = OLD.charid;
DELETE FROM `char_vars` WHERE `charid` = OLD.charid;
DELETE FROM `char_weapon_skill_points` WHERE `charid` = OLD.charid;
DELETE FROM `auction_house` WHERE `seller` = OLD.charid;
DELETE FROM `delivery_box` WHERE `charid` = OLD.charid;
END $$

DROP TRIGGER IF EXISTS char_insert $$
CREATE TRIGGER char_insert
BEFORE INSERT ON chars
FOR EACH ROW
BEGIN
INSERT INTO `char_equip` SET `charid` = NEW.charid;
INSERT INTO `char_exp` SET `charid` = NEW.charid;
INSERT INTO `char_jobs` SET `charid` = NEW.charid;
INSERT INTO `char_pet` SET `charid` = NEW.charid;
INSERT INTO `char_points` SET `charid` = NEW.charid;
INSERT INTO `char_profile` SET `charid` = NEW.charid;
INSERT INTO `char_storage` SET `charid` = NEW.charid;
INSERT INTO `char_inventory` SET `charid` = NEW.charid;
END $$

DROP TRIGGER IF EXISTS char_pos $$
CREATE TRIGGER char_pos
BEFORE UPDATE ON chars
FOR EACH ROW
BEGIN
SET @zoning := 0;
SELECT zoning INTO @zoning FROM char_stats WHERE charid = OLD.charid;
IF @zoning = 1 THEN
SET NEW.pos_x = OLD.pos_x;
SET NEW.pos_y = OLD.pos_y;
SET NEW.pos_z = OLD.pos_z;
SET NEW.pos_rot = OLD.pos_rot;
SET NEW.pos_zone = OLD.pos_zone;
END IF;
END $$

Re: Triggers.sql

Posted: Sun Jun 21, 2015 4:15 pm
by Skrakle
I myself was never able to successfully import triggers using mysql's importer or phpmyadmin.

Here are simple steps:

#1) Install Navicat if you haven't already, demo has a 30-day trial.

#2) Create/truncate database

#3) Import ALL sql files except for triggers.sql
OR if you don't want to import them one by one, you can do this:
In the sql folder, create a text file like combine_all.txt and input the following:

Code: Select all

@echo off
ren triggers.sql triggers.sql.bak
copy /b *.sql !ALL.sql
ren triggers.sql.bak triggers.sql
pause
save it and rename it for combine_all.bat and execute it. (if you don't see file extensions, you'll need to enable them in folder options)


#4) Open up navicat and import all sql files except for triggers.sql OR !ALL.sql

#5) Now import triggers.sql

This should work.

Re: Triggers.sql

Posted: Sun Jun 21, 2015 4:42 pm
by Drinkie
I actually did use Navicat to import the .sql files since i was following the guide on this page

https://wiki.dspt.info/index.php?title= ... the_Server

Aside from that one file and Visual Studio not installing because i don't have I.E 10 and Windows 8 installed everything so far is working

Re: Triggers.sql

Posted: Sun Jun 21, 2015 4:55 pm
by Desufire

Code: Select all

 @ECHO OFF REM ============================================================================= REM ============================================================================= REM ====== ========= REM ====== THis script will drop the DB specificed, then create the DB ========= REM ====== specified, and then load all .sql tables from its run dir to ========= REM ====== the the DB. ========= REM ====== ========= REM ====== File needs to be run from within the \dsp\sql folder (same ========= REM ====== folder with all the .sql files. Please edit as needed. By ========= REM ====== default it WILL DROP the standard dspdb DB, loosing all ========= REM ====== accounts and characters. If this is not desired, then update ========= REM ====== the file to load the new DB into a new DB name. ========= REM ====== ========= REM ====== Update -p with MySQL password. If you password is 'foo', ========= REM ====== then change '-pMYSQLPASS' to '-pfoo' (3 places). ========= REM ====== ========= REM ====== If you want to use a different database name, change 'dspdb' ========= REM ====== with a database name of your choosing. ========= REM ====== ========= REM ============================================================================= REM ============================================================================= REM ====== ========= REM ====== by Thrydwolf 9/8/2012 ========= REM ====== Updated with status by bluekirby0 3/30/2012 ========= REM ====== Updated by Thrydwolf 9/18/2012 ========= REM ====== ========= REM ============================================================================= REM ============================================================================= ECHO Creating Database dspdb mysqladmin -h localhost -u root -pMYSQLPASS DROP dspdb ECHO Creating Database dspdb mysqladmin -h localhost -u root -pMYSQLPASS CREATE dspdb ECHO Loading dspdb tables into the database cd c:\darkstar\sql FOR %%X IN (*.sql) DO ECHO Importing %%X & "c:\program files\mysql\mysql server 5.6\bin\mysql" dspdb -h localhost -u root -pMYSQLPASS < %%X ECHO Finished!


Use this for the first import instead of Navicat. Also, you want Visual Studio. Seriously. Find a way to get it installed.

EDIT: Don't copy and paste the code above. Find it on the dsp wiki. My phone doesn't like copy and paste and the above code is a mess, but you can see what you need.

Re: Triggers.sql

Posted: Mon Jun 22, 2015 2:40 am
by Drinkie
I've managed to get SP1 installed so i'm currently downloading Visual Studio 2013 and what would the general name for the code be? just so i can search for it

Re: Triggers.sql

Posted: Mon Jun 22, 2015 11:40 pm
by Desufire
Drinkie wrote:I've managed to get SP1 installed so i'm currently downloading Visual Studio 2013 and what would the general name for the code be? just so i can search for it
Go here: https://wiki.dspt.info/index.php/Building_the_Server and scroll down to "Setting up the Database."

Under that, you'll see "Using a bat script."

The script beginning with @ECHO OFF is an importing script. It does the same thing as executing sql's via Navicat does. Use the script during your first initial setup. Afterwards, use the second script provided under the same category when you perform updates. The reasons are stated in the wiki guide, but in short; the first script imports all sql's while the 2nd imports all, but the account/character sql's. This means, if you have players on your server and you use the first script after an update, you've just erased everyone's account and character information. Using the 2nd script prevents that from happening.

Re: Triggers.sql

Posted: Tue Jun 23, 2015 12:19 am
by Drinkie
I knew i forgot to say something but once i installed SP1 and Visual Studio it started working and just to check is there no way to alter the amount of Blue Magic Points required to equip blue magic and have the game in a window?

Re: Triggers.sql

Posted: Tue Jun 23, 2015 7:47 am
by Desufire
Drinkie wrote:I knew i forgot to say something but once i installed SP1 and Visual Studio it started working and just to check is there no way to alter the amount of Blue Magic Points required to equip blue magic and have the game in a window?
Blue Magic Points might be in the src files. Not sure because I've never looked, so you'll have to wait for someone else to answer that.

Running the game in window mode is from the settings. Read the "Configuring your client" wiki/guide for details.