Jump to content

KeyWorld

Members
  • Posts

    379
  • Joined

  • Last visited

  • Days Won

    10

Community Answers

  1. KeyWorld's post in Specialeffect on NPC with Sprite -1? was marked as the answer   
    So if you want:
    A not clickable npc, with position/info never send to the client/bot (so npctalk, effects, ... will fail), use -1. A not clickable npc, with position/info send to client (npctalk, etc. will work), use 139. A clickable npc, use 111.
  2. KeyWorld's post in Fill array and check with IF was marked as the answer   
    Something like this I presume :
    query_sql("SELECT `npc1`, `npc2`, `npc3`, `npc4`, `npc5` FROM `quest_db` WHERE `char_id` = " + getcharid(0), [email protected], [email protected], [email protected], [email protected], [email protected]); for( set [email protected],1; [email protected]<=5; set [email protected], [email protected] + 1 ) {     set [email protected], getd("[email protected]" + [email protected]);     if( [email protected] != 500 && [email protected] != 100 ) {         set [email protected], 1;         break;     } } if( [email protected] ) {     // not ok } else {     // ok }  
  3. KeyWorld's post in Request for checkfacing or checkdirection script commands was marked as the answer   
    Hi,
    You have to add in script.c:
    BUILDIN_FUNC(getchardirection) { TBL_PC *sd; if( script_hasdata(st,2) ) sd = map_nick2sd(script_getstr(st,2)); else sd = script_rid2sd(st); if( sd == NULL ){ script_pushint(st, -1); return 0; } script_pushint(st, sd->ud.dir); return 0; }And:BUILDIN_DEF(getchardirection,"?"),In your script:set [email protected], getchardirection(); if( [email protected] == DIR_NORTHWEST ) { // You can see all DIR_* constantes in db/const.txt mes "Nice !"; }It's also possible to check the direction of another player by adding his name as argument:set [email protected] , getchardirection("PlayerTester");Have fun.
  4. KeyWorld's post in return array from function was marked as the answer   
    1) (Euphy ways):
    function script getEquip { // get all equipped item IDs
    for (set [email protected], 1; [email protected] < 11; set [email protected], [email protected] + 1) {
    if (-1 != getequipid([email protected])) {
    set @items[[email protected]], getequipid([email protected]);
    set [email protected], [email protected] + 1;
    }
    }
    return @items;
    }
    callfunc("getEquip");
    // @items
    2) Your way:function script getEquip { // get all equipped item IDs
    for (set [email protected], 1; [email protected] < 11; set [email protected], [email protected] + 1) {
    if (-1 != getequipid([email protected])) {
    set [email protected][[email protected]], getequipid([email protected]);
    set [email protected], [email protected] + 1;
    }
    }
    return [email protected];
    }
    copyarray [email protected], callfunc("getEquip"), 128;
    3) By reference:function script getEquip { // get all equipped item IDs
    for (set [email protected], 1; [email protected] < 11; set [email protected], [email protected] + 1) {
    if (-1 != getequipid([email protected])) {
    set getelementofarray( getarg(0), [email protected]), getequipid([email protected]);
    set [email protected], [email protected] + 1;
    }
    }
    return @items;
    }
    callfunc("getEquip", [email protected]);
  5. KeyWorld's post in Emistry Multi currency shop x2 was marked as the answer   
    First thing I see, you add item to a shop "Emistry_shop", I guess you forget to update the shop name (should be "Cloud_Machine").
    npcshopadditem "Emistry_Shop",@ItemListscloud[[email protected]],@ItemCostcloud[[email protected]];
  6. KeyWorld's post in help infinity loop was marked as the answer   
    Add a "end;" before "OnHour24:".
  7. KeyWorld's post in Script command definitions was marked as the answer   
    v - value (string, int or reference)
    s - string
    i - int
    r - reference (variable)
    l - label
    ? - optional parameter
    * - as you want optionals parameters
  8. KeyWorld's post in script:set: not a variable [Debug]: Data: label pos=353 was marked as the answer   
    You can't use a label if it has the same name as a constant/player variable.
    So rename the label sn to another name.
  9. KeyWorld's post in About Goto, DoEvent and Functions differences was marked as the answer   
    You got it. All for(), while(), switch(), if, else, internal func(), ... are converted to label + goto/callsub + jump_zero on runtime.
    But for keep the script readable it's better to not write the whole script using the low level statement (except if you have reasons like optimizations)
    doevent, donpcevent are used to run another script instance. It's often used to start action on other script. Example: a script to manage all games in your server:
    mes "Select the event to start"; switch( select("Capture the Flag","Nyan Cat Catcher", "First Man Dying") ) { case 1: donpcevent "ctf::OnStartEvent"; break; ... }
    It's good to know that donpcevent will run the script after yours end (it's not multi-thread), to run it after continue you have to pause the script
    donpcevent "todo::OnLol"; sleep2 1; // execute todo::OnLol before continue. dowtfyouwant;
    And functions/callsub I think you know them, it's used to avoid redundant, have fun with arguments, and return to the main script when finished.
    Good luck for your project
  10. KeyWorld's post in help NPC that reads a skull? was marked as the answer   
    My fault:
    delitem2 7420, 1, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16;
    About the name, you have to reloadscript.
    Here a fix :
    // Damn !? No reloadscript ?! if ( .char_name$ == "" ) { donpcevent strnpcinfo(3) + "::OnInit"; sleep2 1; // Execute OnInit before continue. } mes "I give you an apple if you give me " + .char_name$ . "'s skull !"; next; if ( countitem2( 7420, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16 ) ) { mes "Yeah you have the skull ! I give you an apple"; delitem2 7420, 1, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16; getitem 512, 1; } else { mes "Damn, you don't have it..."; } close; OnInit: set .char_name$, "Anonymous"; query_sql("SELECT `char_id` FROM `char` WHERE `name`='" + escape_sql(.char_name$) + "' LIMIT 1", .cible_cid ); if ( !.cible_cid ) debugmes "[skull Trader] Invalid name specify ?"; end;
  11. KeyWorld's post in Setd and Getd problem was marked as the answer   
    Funny that it doesn't throw an error
    1) Athena script engine doesn't support multi-dimensional array.
    2) You set a string into a int variable.
    Uou have to do something like this:
    prontera,153,169,4 script Donation 123,{ set .npcname$,"Donation"; set .arrayCounter,0; //Items //For Headgears [Category][slot Number][itemID = 0 /ItemAmount = 1] setd "[email protected]_0_0_0", 123 ; //ItemID setd "[email protected]_0_0_1", 124 ; //Amount mes getd("[email protected]_0_0_0"); // 123 mes getd("[email protected]_0_0_1"); // 124 mes getd("[email protected]_0_0_2"); // 0 mes getd("[email protected]_1_0_0"); // 0 close; }
  12. KeyWorld's post in [Help]Split was marked as the answer   
    I think something like this (not tested):
    getitem2 <itemid>, <amount>, 1, 0, 0, 255, 0, <group id> & 0xffff, <group id> >> 16;
    Example:
    // Apple Group 1 getitem2 512, 5, 1, 0, 0, 255, 0, 1 & 0xffff, 1 >> 16; getitem2 512, 3, 1, 0, 0, 255, 0, 1 & 0xffff, 1 >> 16; // should give you (5+3) apple for the group 1 // Apple Group 2 getitem2 512, 4, 1, 0, 0, 255, 0, 2 & 0xffff, 2 >> 16; getitem2 512, 2, 1, 0, 0, 255, 0, 2 & 0xffff, 2 >> 16; // should give you (4+2) apple for the group 2 // Apple Group 3 getitem2 512, 1, 1, 0, 0, 255, 0, 3 & 0xffff, 3 >> 16; getitem2 512, 9, 1, 0, 0, 255, 0, 3 & 0xffff, 3 >> 16; // should give you (1+9) apple for the group 3 // etc.
    There is no clean solution for doing what you want (I think).
×
×
  • Create New...

Important Information

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