Register for your free account! | Forgot your password?

Go Back   elitepvpers › Popular Games › Metin2 › Metin2 Private Server › Metin2 PServer Guides & Strategies
You last visited: Today at 21:20

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release SQL] Change startmap coords and map

Discussion on [Release SQL] Change startmap coords and map within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #16
 
Mashkin's Avatar
 
elite*gold: 44
Join Date: May 2010
Posts: 2,053
Received Thanks: 1,747
Quote:
Originally Posted by MAXIMAXCRAK View Post
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 ;
Mashkin is offline  
Old   #17
 
elite*gold: 0
Join Date: Jan 2009
Posts: 11
Received Thanks: 11
Quote:
Originally Posted by M@shkin View Post
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 ;
I'ts good, I'm new in sql sorry xddd

Thx for improve this code, Really may be better.
MAXIMAXCRAK is offline  
Old   #18
 
Mashkin's Avatar
 
elite*gold: 44
Join Date: May 2010
Posts: 2,053
Received Thanks: 1,747
Quote:
Originally Posted by MAXIMAXCRAK View Post
I'ts good, I'm new in sql sorry xddd

Thx for improve this code, Really may be better.
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.
Mashkin is offline  
Old   #19
 
elite*gold: 0
Join Date: Sep 2009
Posts: 8
Received Thanks: 1
Quote:
Originally Posted by M@shkin View Post
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'
asdstyle is offline  
Old   #20
 
Sphinx²'s Avatar
 
elite*gold: 1918
Join Date: Feb 2008
Posts: 1,368
Received Thanks: 1,287
Quote:
Originally Posted by asdstyle View Post
i using u code but this problem can you help ?
1054 - Unknown column 'map_index' in 'NEW'
I think you use the wrong table.
Sphinx² is offline  
Old   #21
 
nagger12's Avatar
 
elite*gold: 0
Join Date: Oct 2010
Posts: 880
Received Thanks: 409
Thanks hat geklappt
nagger12 is offline  
Old   #22
 
elite*gold: 0
Join Date: May 2009
Posts: 44
Received Thanks: 2
Can someone please tell me if that works?

Im trying but everytime i login to an account and i want to go ingame, i just get logged out.

If someone know how to put that working, please give me an explanation.

Thank you
masterdj39 is offline  
Old   #23
 
Mijago's Avatar
 
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,598
Quote:
Originally Posted by .Nagato View Post
Hallo,

Hierfür muss man nichtmal SQL können.
Englisch sollte ausreichen, wobei das auch wieder so eine Sache sein kann. oó
Really nice!
Ich sags anders - Für SQL muss man nur Englisch können
Mijago is offline  
Old   #24
 
elite*gold: 0
Join Date: May 2009
Posts: 44
Received Thanks: 2
Someone had done that without any problems?
masterdj39 is offline  
Reply


Similar Threads Similar Threads
[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....



All times are GMT +2. The time now is 21:22.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.