Discussion on [Release SQL] Change startmap coords and map within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.
Really this it's a good system, only uploads map_index=0 where is insert any date, no update, for this reason the speed of DB musn't be delayed (excuse for my english)
Your procedure "proceso()" checks all rows for "map_index=0" on every update. Since map_index isn't (by default) an index or a primary key, this can take very long.
I would suggest to pass the id of the updated player to the procedure. The procedure then can process just the right row without reading all rows.
Code:
DELIMITER $$
DROP TRIGGER IF EXISTS espera $$
CREATE TRIGGER espera
AFTER UPDATE ON player_index
FOR EACH ROW
begin
IF NEW.map_index = 0 THEN
CALL proceso(NEW.id, NEW.account_id);
END IF;
end $$
DELIMITER ;
Code:
delimiter $$
DROP PROCEDURE IF EXISTS `proceso` $$
CREATE PROCEDURE `proceso`(p_id INT, a_id INT)
begin
declare p_empire integer;
SELECT empire INTO p_empire FROM player_index WHERE id = a_id LIMIT 1;
IF p_empire = 1 THEN
UPDATE player SET x=1111, y=1111, map_index=1 where id = p_id;
ELSEIF p_empire = 2 THEN
UPDATE player SET x=2222, y=2222, map_index=2 where id = p_id;
ELSEIF p_empire = 3 THEN
UPDATE player SET x=3333, y=3333, map_index=3 WHERE id = p_id;
END IF;
end $$
delimiter ;
Your procedure "proceso()" checks all rows for "map_index=0" on every update. Since map_index isn't (by default) an index or a primary key, this can take very long.
I would suggest to pass the id of the updated player to the procedure. The procedure then can process just the right row without reading all rows.
Code:
DELIMITER $$
DROP TRIGGER IF EXISTS espera $$
CREATE TRIGGER espera
AFTER UPDATE ON player_index
FOR EACH ROW
begin
IF NEW.map_index = 0 THEN
CALL proceso(NEW.id, NEW.account_id);
END IF;
end $$
DELIMITER ;
Code:
delimiter $$
DROP PROCEDURE IF EXISTS `proceso` $$
CREATE PROCEDURE `proceso`(p_id INT, a_id INT)
begin
declare p_empire integer;
SELECT empire INTO p_empire FROM player_index WHERE id = a_id LIMIT 1;
IF p_empire = 1 THEN
UPDATE player SET x=1111, y=1111, map_index=1 where id = p_id;
ELSEIF p_empire = 2 THEN
UPDATE player SET x=2222, y=2222, map_index=2 where id = p_id;
ELSEIF p_empire = 3 THEN
UPDATE player SET x=3333, y=3333, map_index=3 WHERE id = p_id;
END IF;
end $$
delimiter ;
Well, I' m no SQL veteran.
My thoughts were not specific to SQL but simply logical.
You should always think about what your code/script/query does exactly and ask yourself how you could improve it.
You'll come to the clue, that - on an update to a specific row - you already know the row you are going to modify with your procedure.
So you should try to use the given information instead of searching for it again.
BTW: I had to read through about six MySQL documentation pages to write the code I posted above.
Well, I' m no SQL veteran.
My thoughts were not specific to SQL but simply logical.
You should always think about what your code/script/query does exactly and ask yourself how you could improve it.
You'll come to the clue, that - on an update to a specific row - you already know the row you are going to modify with your procedure.
So you should try to use the given information instead of searching for it again.
BTW: I had to read through about six MySQL documentation pages to write the code I posted above.
i using u code but this problem can you help ?
1054 - Unknown column 'map_index' in 'NEW'
[Release] Alte Startmap von iMetin 03/26/2011 - Metin2 PServer Guides & Strategies - 14 Replies Release sie mal, weil ich sie eh nicht mehr brauche.
Viel Spaß damit.
Screens hab ich grad keine da.
Video hab ich da darf ich aber nicht posten, da da die iMetin Homepage UrL zu sehen ist.
iMer
[FRAGE]Startmap!? 02/02/2011 - Metin2 Private Server - 10 Replies Wo stellt man es ein?
Auf welcher map der neu erstellte
Account/Chara als erstet steht?
also ich wills um stellen das nnicht mehr map 1 des jeweiligen reiches
die start map ist sondern
eine neutrale map
kann da wer helfen?^^
Frage: Startmap ändern 12/19/2010 - Metin2 Private Server - 0 Replies Guten Abend Com,
Ich habe eine Frage: Wie kann man die Startmap ändern, sprich man wählt das Rote Reich aus und man landet auf einer anderen Map als im Roten Reich.
Würde mich über Antworten freuen,
Mfg,
°WhiT3°
[Release] SBot Coords Database 10/29/2010 - SRO Coding Corner - 10 Replies Hello forum,
This is my first major project, I got the idea from SBot AC professional but decided to make one for the people that don't want to pay for it. So idea credit goes to theoneofgod :)
SBot Coords Database
http://img202.imageshack.us/img202/5734/previewit .jpg
:
-Grab coords directly off of the selected SBot and puts it in the database along with desired name. Note:
Screen Coords <--> Map Coords using autoit 04/21/2009 - CO2 Programming - 1 Replies Someone might like this.
I provide an example of how to convert screen coords into map coords and visa versa. So that if your using autoit or some other mouse clicking macro tool, then you can get it to accurately get the mouse coordinates to click to move to a map-coordinate location.
This method works by using autoit to look at the current player coordinates (_MemoryRead()), and performing some clicks on the screen to take map coordinate samples for mouse clicks in different locations....