Jump to content
  • 0
Sign in to follow this  
MikZ

Monster query

Question

Hello!

Please help me with this script, im new in sql query.
what i wanted to do is to summon different monster per level in devil square.
like 

level 1 :
 

        set .monsterset, query_sql("SELECT id, iname, hp FROM `mob_db` where LV <= 30 and LV >= 50 and hp < 500000 and MEXP = 0 and not iName='Treasure Chest' ORDER BY RAND() LIMIT 100", .monsterid, .monstername$, .monsterhp);
        for (set .@x,0; .@x<getmapusers("ordeal_1-1"); set .@x, .@x+1){
				set .monstercount,15;
                for (set .@y,0; .@y<.monstercount; set .@y, .@y+1 ) {
						set .monster, rand(0,.monsterset-1);
                        monster "ordeal_1-1",149,149,"[DS] "+.monstername$[.monster],.monsterid[.monster],.monstercount,strnpcinfo(0)+"::OnDevilDead";         
                        set .mob, .mob+.monstercount;
                }
        }

Level 2:
 

        set .monsterset, query_sql("SELECT id, iname, hp FROM `mob_db` where LV <= 51 and LV >= 70 and hp < 500000 and MEXP = 0 and not iName='Treasure Chest' ORDER BY RAND() LIMIT 100", .monsterid, .monstername$, .monsterhp);
        for (set .@x,0; .@x<getmapusers("ordeal_1-1"); set .@x, .@x+1){
				set .monstercount,15;
                for (set .@y,0; .@y<.monstercount; set .@y, .@y+1 ) {
						set .monster, rand(0,.monsterset-1);
                        monster "ordeal_1-1",149,149,"[DS] "+.monstername$[.monster],.monsterid[.monster],.monstercount,strnpcinfo(0)+"::OnDevilDead";         
                        set .mob, .mob+.monstercount;
                }
        }


Somehow I get error. debug 

 

: DB error - Can't create/write to file '\tmp\#sql_2180_0.MYI' (Errcode: 2)
[Debug]: at Hercules\src\map\script.c:15851 - SELECT id, iname, hp FROM `mob_db` where LV <= 30 and LV >= 50 and hp < 500000 and MEXP = 0 and not iName='Treasure Chest' ORDER BY RAND() LIMIT 100
[Debug]: Source (NPC): MVP Grave at prontera (170,181)
 
Please help me fix this. thank you!

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hey, try it.

 

 

 

 

        // Level 1
        set .monsterset, query_sql "SELECT `ID`, `iName` FROM `mob_db` WHERE `LV` >= '30' AND `LV` <= '50' AND `HP` < '500000' AND `MEXP` = '0' AND NOT `iName` = 'Treasure Chest' ORDER BY rand() LIMIT 100", .monsterid, .monstername$;
 
        for(set .@x, 0; .@x < getmapusers("ordeal_1-1"); set .@x, .@x + 1)
        {
            set .monstercount, 15;
 
            for(set .@y, 0; .@y < .monstercount; set .@y, .@y + 1)
            {
                set .monster, rand(0, .monsterset - 1);
 
                monster "ordeal_1-1", 149, 149, "[DS] " + .monstername$[.monster], .monsterid[.monster], .monstercount, strnpcinfo(0) + "::OnDevilDead";
                set .mob, .mob + .monstercount;
            }
        }
 
 
        // Level 2
        set .monsterset, query_sql "SELECT `ID`, `iName` FROM `mob_db` WHERE `LV` >= '51' AND `LV` <= '70' AND `HP` < '500000' AND `MEXP` = '0' AND NOT `iName` = 'Treasure Chest' ORDER BY rand() LIMIT 100", .monsterid, .monstername$;
 
        for(set .@x, 0; .@x < getmapusers("ordeal_1-1"); set .@x, .@x + 1)
        {
            set .monstercount, 15;
 
            for(set .@y, 0; .@y < .monstercount; set .@y, .@y + 1)
            {
                set .monster, rand(0, .monsterset - 1);
 
                monster "ordeal_1-1", 149, 149, "[DS] " + .monstername$[.monster], .monsterid[.monster], .monstercount, strnpcinfo(0) + "::OnDevilDead";
                set .mob, .mob + .monstercount;
            }
        }

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.