Jump to content

Rebel

Members
  • Content Count

    148
  • Joined

  • Last visited

  • Days Won

    7

Reputation Activity

  1. Upvote
    Rebel reacted to Dastgir in [Release] ExtendedBG for Hercules (with eAmod BG modes)   
    Fixed @ https://github.com/dastgirp/eBG/commit/aaa190f69b12d7ed0941c5b9ea1645d21c3c4256
    It was due to https://github.com/dastgirp/eBG/commit/098e13bb00e0ea2250b591e15f57bd89b1c67784, where I swapped some numbers too.
  2. Upvote
    Rebel got a reaction from Dastgir in [Release] ExtendedBG for Hercules (with eAmod BG modes)   
    How to? Client : 2013 - 08 - 07

  3. Upvote
    Rebel reacted to Dastgir in Char server crash   
    Execute this:
    SELECT g.guild_id, g.char_id, c.char_id, c.last_login FROM guild_members g LEFT JOIN `char` c ON c.char_id = g.char_id;
    There might be some guild for which char_id is not found in char table.
    You would get guild Id where 3rd and 4th column might be NULL, 2nd column is the char id that does not exist in char table (deleted or something?)
  4. Upvote
    Rebel reacted to Dastgir in [Release] ExtendedBG for Hercules (with eAmod BG modes)   
    Repository Link: https://github.com/dastgirp/eBG (Please read README.md for installation steps)
     
    Leave Comments/Suggestions if you find something.
    NOTE:
     There might be some(/many) debug messages left in map-server which will be cleaned up. I will add battle.conf soon (you have to add it yourself for now or edit the plugin) The plugin might be a big mess to read/understand (I did many experiments over the year) There might be some bugs Thanks to @Rebel and @Myriad for testing and providing initial feedback
  5. Upvote
    Rebel reacted to Rytech in Star gladiator miracle of sun, moon and stars issue   
    There's a packet called ZC_MAPPROPERTY_R2 that has a bit field and one of the bit entry's is called SUNMOONSTAR_MIRACLE. That could be related to why the message appears. I don't think this will affect if miracle will work or not since its just a way for the client to know and tell you if your on a map where miracle is not allowed to activate. Server side will still activate it by chance unless a map flag is set to disable it. Don't know if Hercules has support for that flag yet.

    Note To Devs: A bit old topic but im bumping so we can check into this to make sure it works properly. If no map flag support for this exists yet, maybe set the bit to a fixed setting to make the message not appear until one is supported.
  6. Upvote
    Rebel reacted to Dastgir in [Release] ExtendedBG for Hercules (with eAmod BG modes)   
    Hello Hercules Community,
     
    Let me explain it first.
    It is ExtendedBG, which tends to contain all eAmodBG modes and extra modes(as and when coded).
    Some Previews:
    http://imgur.com/a/2SSVR
    Ohh, and the last thing I forgot to tell,
    Its 100% Plugin and Script, no Source Edits ..
     
    Special Thanks To:
    jaBote co-founded this project(and really thanks to him , that he motivated me at start at provided some functions and idea of how the base should be, and what we should do it to give flavor of Hercules in it).
     
    Repository Link: https://github.com/dastgirp/eBG (Please read README.md for installation steps)
     
    Leave Comments/Suggestions if you find something.
    NOTE:
     There might be some(/many) debug messages left in map-server which will be cleaned up. I will add battle.conf soon (you have to add it yourself for now or edit the plugin) The plugin might be a big mess to read/understand (I did many experiments over the year) There might be some bugs Thanks to @Rebel and @Myriad for testing and providing initial feedback
    Contact me on Discord: @Dastgir#1460 if there's some urgent issue or else open the issue in github. keep this topic for support.
     
    Want to encourage me??

     
  7. Upvote
    Rebel reacted to bWolfie in check_resist() script command   
    Description: Adds the check_resist() script command to your script engine.
    With this command, you can retrieve elemental resistances for a character.
    check_resist(<type>{, <account id>}) e.g. check_resist(Ele_Water); check_resist(Ele_Wind, getcharid(CHAR_ID_ACCOUNT)); https://github.com/bWolfie/HPM-Plugins/blob/master/src/plugins/check_resist.c
  8. Upvote
    Rebel reacted to Truly in Truly - Free Full Map Collection   
    Hey there everyone, long time no see!
     
      So it's been a very long time since I have been on these boards and I do miss it all. Feeling a little nostalgia looking through all of these, I decided to release them all to the public, completely free. Going in no particular order after the first few, they are just my favorites. I hope you guys love them as I have.
     
    Sanctum
    Main town oriented map. My absolute favorite and latest work (When I was mapping). The idea I had for this was a chunck of a mountain broke off and landed here, subsequently creating a waterfall from atop and surrounding the town. Giving it protection and a perfect center for life. I never got around to finishing the outside of the map, I don't even know what I thought for the surroundings, perhaps just trees.
     
    Sanctum In
    And here is the inside map for Sanctum. The first picture is the general area where various NPC's can be placed. The second picture is where I planned to use a script to automatically place anyone who wished to vend in the one walkable/edited Gat. It would cycle through and remove those vending for a prolonged period of time and also anyone not vending at all.
     
    Guild Base
    This map was designed for the top guilds or just those who hold castles to have a domain of their own. The first picture is just a hangout spot for anyone in the guild. The second picture is for any combat/training/monster summoning to be done. The third picture is for the guild master where special NPC's can be placed as the server owners desire.
     
    Novice Starter Grounds
     
    PvP Valkyrie
    A little small for a PvP map but I enjoyed making it and like how it turned out.
     
    Trinity
    The first main town I made some time back around 2010. Don't judge me on some of the rookie mistakes I made with lighting and such haha. The following Trinity ___ maps are connected via a warp on the edges of the map.
     
    Trinity In
     
    Trinity Courtyard
    Before the Sanctum maps, this was my favorite creation. I just liked the feel of this one.
     
    Trinity Vending
    Similar to the Sanctum In vending idea, I wanted to limit vending to only those tiles with the colored objects on it.
     
    Trinity Port
     
    Anexus
    A simple instance based map with a boss at the end. Another one of my earlier works.
     
    Works
    The beginnings of my templates map. I would urge any current mapper to use this technique to create unique model compilations and copy it over to the map in progress. I have used this to create a forest that looks completely customized in a matter of minutes.
     
      Well there they are, open to any and all. I hope to hear your feedback on these!
     
      
     
     
     
    Thanks,
    Truly ~
     
  9. Upvote
    Rebel reacted to bWolfie in Hercules Battlegrounds   
    No offence to the creator Smoke, as he did a great effort putting this all together, but there are outstanding issues which make it not possible to use in a production server.
    Being curious, just did some more testing with it, and the guild system (I believe that's what causes it) actually creates this issue where sometimes the sword cursor doesn't appear (need to refresh to get it to show, seems random chance it actually appears), meaning your players would need to have /ns activated all the time to play. 
    So please, any future posters - unless you know how to edit the plugin (and therefore source code) itself, don't download it.
    And nobody request support as nobody is going to help you.
  10. Upvote
    Rebel got a reaction from MikZ in Warper NPC for Pre-Re (Bug)   
    function Pick { .@warp_block = @warp_block; @warp_block = 0; .@select = select(@menu$); if (getarg(0) == "") { .@i = .@select; .@map$ = getarg(.@i); } else { .@i = .@select-getarg(1,0); .@map$ = getarg(0)+((.@i<10)?"0":"")+.@i; } if (.@warp_block & (1<<.@select)) { message strcharinfo(PC_NAME),"This map is not enabled in "+(RENEWAL?"":"Pre-")+"Renewal."; + close; end; } .@x = @c[.@i*2]; .@y = @c[.@i*2+1]; deletearray @c[0],getarraysize(@c); Go(.@map$,.@x,.@y); } function Restrict { if ((getarg(0) == "RE" && !RENEWAL) || (getarg(0) == "Pre-RE" && RENEWAL)) { if (getarg(1,0)) { @warp_block = 0; for (.@i = 1; .@i < getargcount(); .@i++) @warp_block = @warp_block | (1<<getarg(.@i)); } else { message strcharinfo(PC_NAME),"This map is not enabled in "+(RENEWAL?"":"Pre-")+"Renewal."; + close; end; } } return; } try this.. just added close after message ....
  11. Upvote
    Rebel got a reaction from Begin in @pk on/off   
    Try this.
    pk.patch
  12. Upvote
    Rebel got a reaction from Begin in @pk on/off   
    Working naman yung sakin. Make sure inaapply mo yung patch na bago.
  13. Upvote
    Rebel reacted to Rytech in Experience Table Generator   
    Does anyone know where I can get a quality working experience table generator? Ive looked all over on the internet but couldn't find one.
  14. Upvote
    Rebel got a reaction from Kuroyama in Lord Knight [SL Modification]   
    Find in skill.c
    int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) insert after
    int index[MAX_SKILL_ITEM_REQUIRE]; this
    struct status_change *sc = &sd->sc; find in skill.c
    if( require.weapon && !pc_check_weapontype(sd,require.weapon) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); return 0; } change to
    if( require.weapon && !(pc_check_weapontype(sd,require.weapon) || (skill_id == LK_PARRYING && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_KNIGHT && sd->weapontype == W_1HSWORD))) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); return 0; } Find again in skill.c
    if( require.weapon && !pc_check_weapontype(sd,require.weapon) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); return 0; } change to
    if( require.weapon && !(pc_check_weapontype(sd,require.weapon) || (skill_id == LK_PARRYING && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_KNIGHT && sd->weapontype == W_1HSWORD))) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); return 0; } recompile.
  15. Upvote
    Rebel got a reaction from hendra814 in Lord Knight [SL Modification]   
    Find in skill.c
    int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) insert after
    int index[MAX_SKILL_ITEM_REQUIRE]; this
    struct status_change *sc = &sd->sc; find in skill.c
    if( require.weapon && !pc_check_weapontype(sd,require.weapon) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); return 0; } change to
    if( require.weapon && !(pc_check_weapontype(sd,require.weapon) || (skill_id == LK_PARRYING && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_KNIGHT && sd->weapontype == W_1HSWORD))) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); return 0; } Find again in skill.c
    if( require.weapon && !pc_check_weapontype(sd,require.weapon) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); return 0; } change to
    if( require.weapon && !(pc_check_weapontype(sd,require.weapon) || (skill_id == LK_PARRYING && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_KNIGHT && sd->weapontype == W_1HSWORD))) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); return 0; } recompile.
  16. Upvote
    Rebel reacted to 4144 in Guild bound items can disappear   
    please stop spamming
  17. Upvote
    Rebel reacted to AnnieRuru in Custom Enchant System   
    @Rebel
    prontera,146,185,6 script Costume Enchanter 4_M_SCIENCE,{ disable_items; .@header$ = "[^0000FF Costume Enchanter ^000000]"; mes .@header$; if (Zeny < 500000) { mes "I am in charge of Enchanting Costume Headgears. Simply put, I've been studying ways to power-up headgears."; next; mes .@header$; mes "If by any chance, you would want to enchant your headgears, bring me 500,000 zeny and the armor you want to enchant and you are all set to go."; close; } mes "I'm an engineer that specializes in Enchanting Armors."; next; mes .@header$; mes "Enchanting may seem simple, but it's far more complicated than it looks.\n"; mes "If you're interested in my service, let me know."; next; switch( select( "~ ^0000FFEnchant Headgear ^000000", "~ Information", "~ Maybe next time." ) ) { case 1: break; case 2: mes .@header$; mes "To be update"; close; case 3: mes .@header$; mes "Please come back when you have any interest in enchanting your headgear."; close; } setarray .@items[0],19504,19505,19506; // Red_Tailed_Ribbon; .@failrate = 1; // 1% fail rate (for testing) .@menu$ = ""; .@size = getarraysize(.@items); for ( .@i = 0; .@i < .@size; ++.@i ) .@menu$ += getitemname(.@items[.@i]) +":"; .@itemid = .@items[select(.@menu$)-1]; if (getequipid(EQI_COSTUME_HEAD_TOP) == .@itemid) .@part = EQI_COSTUME_HEAD_TOP; else if (getequipid(EQI_COSTUME_HEAD_MID) == .@itemid) .@part = EQI_COSTUME_HEAD_MID; else if (getequipid(EQI_COSTUME_HEAD_LOW) == .@itemid) .@part = EQI_COSTUME_HEAD_LOW; // else if (getequipid(EQI_HEAD_TOP) == .@itemid) // .@part = EQI_HEAD_TOP; mes .@header$; if ( !getequipisequiped(.@part) ) { mes "Hmm? There's nothing to be enchanted!"; mes "Make sure you are wearing the headgear you want be enchant."; close; } if ( getequipcardid(.@part,1) && getequipcardid(.@part,2) && getequipcardid(.@part,3) ) { mes "There's nothing more I can do with this headgear."; close; } .@refine = getequiprefinerycnt(.@part); for ( .@i = 3; .@i >= 1; --.@i ) if ( !getequipcardid( .@part, .@i ) ) .@slot_num = .@i; for ( .@i = 0; .@i < 4; ++.@i ) .@cardid[.@i] = getequipcardid( .@part,.@i ); mes "Socket enchant will cost you 500,000z. And there will be a random option enchanted."; mes "Of course, there is a chance of breaking your armor."; next; mes .@header$; mes "Do you still want to try an Enchant?"; next; if ( select( "~ Hmm... Let me think it over.", "~ Go ahead.") == 1 ) { mes .@header$; mes "Well, I can't blame you. Safety first, eh?"; mes "Now you have a nice day."; close; } mes .@header$; if (Zeny < 500000) { mes .@header$; mes "Sorry, but you don't have enough zeny."; close; } mes "Quite of an adventurer huh? Well, shall we?"; Zeny -= 500000; delitem2 .@itemid, 1,1, .@refine,0, .@cardid[0],.@cardid[1],.@cardid[2],.@cardid[3]; close2; specialeffect EF_MAPPILLAR, AREA, playerattached(); progressbar "ffff00",1; // is this really needed ? what happen if the player logout/disconnect during this short period ? The item is gone forever !! switch (rand(1,.@failrate)) { // yeah you said its testing, maybe its 1,36 ... or maybe something higher case 1: .@addpart = 4702;break; case 2: .@addpart = 4712;break; case 3: .@addpart = 4722;break; case 4: .@addpart = 4732;break; case 5: .@addpart = 4742;break; case 6: .@addpart = 4752;break; case 7: case 8: .@addpart = 4701;break; case 9: case 10: .@addpart = 4711;break; case 11: case 12: .@addpart = 4721;break; case 13: case 14: .@addpart = 4731;break; case 15: case 16: .@addpart = 4741;break; case 17: case 18: .@addpart = 4751;break; case 19: case 20: case 21: .@addpart = 4700;break; case 22: case 23: case 24: .@addpart = 4710;break; case 25: case 26: case 27: .@addpart = 4720;break; case 28: case 29: case 30: .@addpart = 4730;break; case 31: case 32: case 33: .@addpart = 4740;break; case 34: case 35: case 36: .@addpart = 4750;break; default: specialeffect(EF_PHARMACY_FAIL, AREA, playerattached()); mes .@header$; mes "Well that's too bad."; mes "The requested equipment has failed to enchant."; close; } mes .@header$; mes "Ha! There you go, your brand new enchanted equipment!"; if ( .@slot_num == 1 ) { getitem2 .@itemid, 1, 1, .@refine, 0, .@cardid[0], .@addpart, .@cardid[2], .@cardid[3]; equip2 .@itemid, .@refine, 0, .@cardid[0], .@addpart, .@cardid[2], .@cardid[3]; } else if ( .@slot_num == 2 ) { getitem2 .@itemid, 1, 1, .@refine, 0, .@cardid[0], .@cardid[1], .@addpart, .@cardid[3]; equip2 .@itemid, .@refine, 0, .@cardid[0], .@cardid[1], .@addpart, .@cardid[3]; } else if ( .@slot_num == 3 ) { getitem2 .@itemid, 1, 1, .@refine, 0, .@cardid[0], .@cardid[1], .@cardid[2], .@addpart; equip2 .@itemid, .@refine, 0, .@cardid[0], .@cardid[1], .@cardid[2], .@addpart; } close; }  
  18. Upvote
    Rebel reacted to Rytech in r850 - Star Emperor And Soul Reaper Added / Tags And ID's Updated   
    =General
    *Added all the latest tags and ID's for jobs, skills, status, and NPC's.
     
    =Database
    *Added place holders for many new skills.
     
    =Jobs
    *Star Emperor
    *Soul Reaper
    *Baby Star Emperor
    *Baby Soul Reaper
    +Added support for these jobs.
    +Note: These jobs are fully playable. However, none of the new skills that comes
    -with them are in the skill trees. This will be added in a future update.
    -Everything else for them works.
    +Note 2: Client support for these jobs will come at a later time once stable.
  19. Upvote
    Rebel reacted to AnnieRuru in Russian Roulette   
    Download: 1.1
    script
    just join the event and then AFK there and wait for the luck ...
    the last one who has enough patience ... or you are just god damn lucky ... might win this event

     
  20. Upvote
    Rebel reacted to bWolfie in [Guide] Mapcache Generation 2018   
    As of Release v2018.03.13, the method to generate mapcache for Hercules has changed. A lot of people. myself included, were confused as to how it works. In this thread, I will do my best to explain the new way to generate your cache. This guide is intended to help people using the old system, not to aid new people (i.e. never generated mapcache before), so if you are new, some of it may seem like alien talk.
    Old (your source predates [is older than] Feb 18, 2018)
    In the old system, there were two ways to generate mapcache
    You could run the mapcache executable in Hercules root folder. Or use a program such as WeeMapCache to edit in your required mapcache. These two methods would generate or alter your required mapcache located in db/[pre-re or re]/map_cache.dat. However, they are no longer supported.
    New (your source is using Release v2018.03.13 or newer)
    The new system involves the use of the new 'mapcache' plugin to generate files. Some quick points:
    db/[pre-re or re]/map_cache.dat has been dropped (no longer supported). In its place are individual .mcache files for every map located in maps/[pre-re or re]/ Mapcache executable has been removed. Replaced with the mapcache plugin (src/plugins/mapcache.c). How to generate the mapcache?
    Same as before, check conf/map/maps.conf and db/map_index.txt have all the maps you want to cache. Your maps need to exist somewhere in your repository! There are two ways for the plugin to find them:
    a. Place all your maps, including resnametable.txt, inside the data folder of your Hercules repo. I.e. Hercules/data/prontera.gat/gnd/gnd/rsw (note: I forget if all three files are needed).
    b. OR Configure your conf/grf-files.txt to tell it where to find your GRF(s) which contains your maps. Build the mapcache plugin. On linux, this can be done by running the following command:
    make plugin.mapcache
    If using MSVC, compile as you would any other plugin. Execute plugin. This can be done using the following command:
    ./map-server --load-plugin mapcache [param]
    In windows, just remove the './' and run the commands in your command prompt. The params:
    The first thing you should do is run
    ./map-server --load-plugin mapcache --help
    A list of usable parameters will appear. Here are the ones you need to know for mapcache:
    [Info]:   --convert-old-mapcache         Converts an old db/pre-re/map_cache.dat file to the new format. [Mapcache] [Info]:   --rebuild-mapcache             Rebuilds the entire mapcache folder (maps/pre-re/), using db/map_index.txt as index. [Mapcache] [Info]:   --map <name>                   Rebuilds an individual map's cache into maps/pre-re/ (usage: --map <map_name_without_extension>). [Mapcache] [Info]:   --fix-md5                      Updates the checksum for the files in maps/pre-re/, using db/map_index.txt as index (see PR #1981). [Mapcache] ./map-server --load-plugin mapcache --convert-old-mapcache
    Rebuild all the .mcache files using your old db/[pre-re or re]map_cache.dat file.
    NOTE: You should only run this command when you have an old map_cache.dat file you need to convert.
    ./map-server --load-plugin mapcache --rebuild-mapcache
    Rebuild all the .mcache files using your map files specified in step 2 of generation.
    NOTE: You should only run this command in special circumstances. This erases ALL the existing mapcache and rebuilds it with whatever files you provide it. If you don't have the required files, the build will fail and you will be left with missing mapcache files, meaning you won't be able to access those particular maps.
    ./map-server --load-plugin mapcache --map <name>
    Rebuild the .mcache file for the map name you specify. E.g. if you replace <name> with prontera, the maps/[pre-re or re]/prontera.mcache file will be rebuilt.
    NOTE: This is the best command to run, as it only caches a single map at a time.
    ./map-server --load-plugin mapcache --fix-md5
    I don't know what checksum is for.
    The End
    Feel free to ask for help here. I'll try to answer questions re: mapcache if possible. And if you think anything needs correcting or added, let me know.
    Hope this helps!
  21. Upvote
    Rebel reacted to Christian [epicRO] in Russian Roulette - NPC Managed Event, SQL Table required   
    Just try to replace "rodex_sendmail" with

     
    attachrid(.@accountid); Zeny = Zeny + $RRZENYPOT; announce "Event Manager: This is your reward. You've won "+$RRZENYPOT+" zeny. Gz.",bc_self,0x00FF00; detachrid();  
  22. Upvote
    Rebel got a reaction from MikZ in SKILL_DB MAXCOUNT   
    db/pre-re/skill_db.conf
    db/re/skill_db.conf
    SkillInstances: Skill instances (int, defaults to 0) (can be grouped by Levels) Notes: max amount of skill instances to place on the ground when player_land_skill_limit/monster_land_skill_limit is enabled. For skills that attack using a path, this is the path length to be used.  
  23. Upvote
    Rebel reacted to AnnieRuru in Advance SQL commands   
    6. How to show the current rank of the player
    Question : This is the part of the script, output as below
    .@nb = query_sql("SELECT `name`, `kills` FROM `pvpladder` ORDER BY `kills` DESC LIMIT 5", .@name$, .@kills); for ( .@i = 0; .@i < .@nb; .@i++ ) mes "No."+(.@i+1)+" ["+ .@name$[.@i] +"] ~ "+ .@kills[.@i] +" kills"; No.1 [Alice] ~ 19 kills No.2 [Emily] ~ 11 kills No.3 [Irene] ~ 11 kills No.4 [Brittany] ~ 8 kills No.5 [Fiona] ~ 7 kills  2nd place and 3rd place has the same amount of kills, how do I make both of them display as 2nd place like this ?
    No.1 [Alice] ~ 19 kills No.2 [Emily] ~ 11 kills No.2 [Irene] ~ 11 kills No.4 [Brittany] ~ 8 kills No.5 [Fiona] ~ 7 kills  
    Answer :
    Method no.1: Convert the table into InnoDB will return the result faster. Allow to use OFFSET
    .@nb = query_sql("SELECT `name`, `kills`, FIND_IN_SET(`kills`, (SELECT GROUP_CONCAT(`kills` ORDER BY `kills` DESC) FROM `pvpladder`)) FROM `pvpladder` ORDER BY `kills` DESC LIMIT 5", .@name$, .@kills, .@rank); for ( .@i = 0; .@i < .@nb; ++.@i ) mes "No."+ .@rank[.@i] +" ["+ .@name$[.@i] +"] ~ "+ .@kills[.@i] +" kills"; Method no.2: This method return result faster than method 1 in huge table. Not allow to use OFFSET
    .@query$ = "SELECT `name`, IF(@d=t.`kills`, @r, @r:=@i), @d:=t.`kills`, @i:=@i+1 "; .@query$ += "FROM `pvpladder` t, (SELECT @d:=0, @r:=0, @i:=1)q "; .@query$ += "ORDER BY `kills` DESC LIMIT 5"; .@nb = query_sql(.@query$, .@name$, .@rank, .@kills, .@dummy); for ( .@i = 0; .@i < .@nb; ++.@i ) mes "No."+ .@rank[.@i] +" ["+ .@name$[.@i] +"] ~ "+ .@kills[.@i] +" kills"; .
    .
    Question : How do I show the current ranking of the player ?
    mes "Your kills -> "+ .@kills; mes "Your rank -> "+ .@rank; Answer :
    query_sql "SELECT `kills`, 1+(SELECT COUNT(1) FROM `pvpladder` t1 WHERE t1.`kills` > t2.`kills`) FROM `pvpladder` t2 WHERE `char_id` = "+ getcharid(0), .@kills, .@rank; Remember to index the `kills` field
     
    Reference : https://dba.stackexchange.com/questions/13703/get-the-rank-of-a-user-in-a-score-table
    .
     
  24. Upvote
    Rebel reacted to AnnieRuru in Advance SQL commands   
    5. How to do IF-ELSE in SQL query ?
    Question : I have a PVP ladder script that runs on Points system. Each kill plus 1 point and each death minus 1 point.
    The problem is, this query will make the points go into negative value if the player is being kill repeatedly
    query_sql "UPDATE `pvp_points` SET `points` = `points` - 1 WHERE `char_id` = "+ getcharid(0); How do I make the points stop at 0 if the player is already at 0 points ?
     
    Answer :
    query_sql "UPDATE `pvp_points` SET `points` = IF(`points` = 0, 0, `points` - 1) WHERE `char_id` = "+ getcharid(0); query_sql "UPDATE `pvp_points` SET `points` = (CASE WHEN `points` = 0 THEN 0 ELSE `points` - 1 END) WHERE `char_id` = "+ getcharid(0);  
    Explanations:
    similar to hercules script language,
    if (<condition>) <execute true condition>; else <execute false condition>; in SQL language
    IF(<condition>, <execute true condition>, <execute false condition>) CASE WHEN <condition> THEN <execute true condition> ELSE <execute false condition> END  
    Reference : https://www.w3schools.com/sql/func_mysql_if.asp
    https://stackoverflow.com/questions/63447/how-do-i-perform-an-if-then-in-an-sql-select
    5a. How to update multiple rows on different conditions in a single query
    This query will update multiple rows on different condition
    UPDATE `pvpladder` SET `points` = CASE WHEN `char_id` = 150000 THEN `points` +1 WHEN `char_id` = 150001 THEN `points` -1 END WHERE `char_id` IN (150000,150001); Reference : https://stackoverflow.com/questions/20255138/sql-update-multiple-records-in-one-query
  25. Upvote
    Rebel reacted to AnnieRuru in Advance SQL commands   
    3. Choose a table type, MyISAM or InnoDB ?
    https://stackoverflow.com/questions/20148/myisam-versus-innodb
    Before MySQL 5.5,
    MyISAM is mostly use for read-heavy + table locking storage engine = such as pvp ladder ( always select ... order by kill desc )
    InnoDB is mostly use for write-heavy + row locking storage engine = such as quest script ( select ... from char_id ... only 1 row is retrieve )
    After MySQL 5.6, (currently is 8.0)
    just stick to InnoDB
    there is only 1 reason MyISAM is better than InnoDB
    - MyISAM use smaller disk usage than InnoDB
    let's take a look at our MyISAM to InnoDB converter
    https://github.com/HerculesWS/Hercules/blob/stable/sql-files/tools/convert_engine_innodb.sql
    This converter is useful if you are using MySQL 5.6 or above
    There are 4 tables that are commented out
    the reason is simple, these 4 tables only read once and forgotten when server is live
    since MyISAM is good at reading (SELECT) + smaller disk usage, its no use to convert these 4 tables into InnoDB
    3a How to index a table properly
    http://mysql.rjweb.org/doc.php/index_cookbook_mysql
    http://www.dbta.com/Columns/DBA-Corner/Top-10-Steps-to-Building-Useful-Database-Indexes-100498.aspx
    a simple thumb of rule, anything that is SELECT .... WHERE `field` = .....
    that `field` has to be index
    let's take a look at this PVP Ladder script that use Kill/Death ratio
    CREATE TABLE `pvpladder` ( `char_id` INT(11), `name` VARCHAR(23), `kills` INT(11), `death` INT(11), PRIMARY KEY (`char_id`), KEY (`kills`, `death`) ) ENGINE = InnoDB; prontera,155,186,6 script PVP Ladder 1_F_MARIA,{ .@nb = query_sql( "SELECT `name`, `kills`/(`death`+1) FROM `pvpladder` WHERE `kills` > 0 ORDER BY `kills`/(`death`+1) DESC LIMIT 10", .@name$, .@ratio$ ); if ( !.@nb ) { mes "no entry"; close; } mes "Current Ranking :"; for ( .@i = 0; .@i < .@nb; ++.@i ) mes "No."+(.@i +1)+" ["+ .@name$[.@i] +"] "+ .@ratio$[.@i] +" kill"; close; OnPCKillEvent: if ( killedrid == getcharid(3) ) { // killing self should only increase death count. EG: Grand-cross query_sql "INSERT INTO `pvpladder` VALUES ( "+ getcharid(0) +", '"+ escape_sql( strcharinfo(0) )+"', 0,1 ) ON DUPLICATE KEY UPDATE `death` = `death` +1"; end; } query_sql "INSERT INTO `pvpladder` VALUES ( "+ getcharid(0) +", '"+ escape_sql( strcharinfo(0) )+"', 1,0 ) ON DUPLICATE KEY UPDATE `kills` = `kills` +1"; attachrid killedrid; query_sql "INSERT INTO `pvpladder` VALUES ( "+ getcharid(0) +", '"+ escape_sql( strcharinfo(0) )+"', 0,1 ) ON DUPLICATE KEY UPDATE `death` = `death` +1"; end; } This kind of query -> ORDER BY kills/death, needs to index them together like this
    KEY (`kills`, `death`) 3b. Why you shouldn't use `char_reg_num_db` table
    blame Euphy for spreading this technique
    There are 2 reasons why you shouldn't even touch all these variable tables
    Reason no.1 This table is sorely meant for server usage
    Once these data is loaded, it is process internally, and only save character data according to this configuration
    Reason no.2 The `value` field is not index !
    This line has ORDER BY `value`, try recheck our main.sql file
    CREATE TABLE IF NOT EXISTS `acc_reg_num_db` ( `account_id` INT(11) UNSIGNED NOT NULL DEFAULT '0', `key` VARCHAR(32) BINARY NOT NULL DEFAULT '', `index` INT(11) UNSIGNED NOT NULL DEFAULT '0', `value` INT(11) NOT NULL DEFAULT '0', PRIMARY KEY (`account_id`,`key`,`index`), KEY `account_id` (`account_id`) ) ENGINE=MyISAM; SQL will search through every single line in the `value` field if that column isn't index
    Of course you can ... do ALTER table to add KEY to the `value` field
    but this table has already optimized in that way for server usage
    the more field you index into the table, the more disk usage space it use
    Conclusion : If you want to make a custom script, then make a custom table. Leave these table alone !
×
×
  • Create New...

Important Information

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