Jump to content

Ryokem

Members
  • Posts

    205
  • Joined

  • Last visited

Posts posted by Ryokem

  1. I honestly don't really like how that script is written.

    In the MvPRank function, you are trying to build up a script-based ranking without facing position swaps or referals.

    If it is of just 1 variable, I'd just run a query_sql command to get the ranking positions, there should be an example of exactly what you need in the script_commands.txt file, under the query_sql command explanation.

    About the variable being resetted, I honestly didn't find anything that actually resets it. Try to check if you have some other scripts that may use the same variable.

  2. Add a restriction list as NPC-array in a OnInit event label:

     

    OnInit:
        setarray .restrictedMaps$[0],"prontera","your_map",[...];

     

    Add a check at the very beginning of your script after the NPCKillEvent label call:

     

    OnNPCKillEvent:
     
        for( .@i=0; .@i<getarraysize(.restrictedMap$); .@i++ )
            if(strcharinfo(3) == .restrictedMaps$[.@i])
                end;
     
        if($@CPc && (getgmlevel() < $@CPgm0)) {
        //[...]
    • Upvote 1
  3. prontera,147,171,3    script    IRO Freebies Giver    509,{
    
    mes "[^000088 Freebies Giver ^000000]";
    mes "Hello "+strcharinfo(0)+", Welcome To Infinite-RO.";
    mes "I'm the freebies giver.";
    mes "I only give 1 freebies per account and can be use by this character only.";
    next;
    mes "[^000088 Freebies Giver ^000000]";
     
    if(#freebies) {
        mes "You already have your freebies.";
        close;
    }
     
    if (select ("Please Bless me:I Change my mind") == 2) {
        Mes "Come back for my Blessing";
        Mes "Thank you";
        close;
    }
     
    else {
        set #freebies, 1;
        getitem2 2357,1,1,7,0,0,0,0,0; // +7 valkarmor
        getitem2 2524,1,1,7,0,0,0,0,0; // +7 valkmant
        getitem2 2421,1,1,7,0,0,0,0,0; // +7 valksh
        getitem2 2102,1,1,7,0,0,0,0,0; // +7 Guard[1]
        getitem2 2115,1,1,7,0,0,0,0,0; // +7 Shoes[1]
        getitem 4174, 2;
        getitem 4302, 2;
        getitem 4142, 3;       
     
        mes "[^000088 Freebies Giver ^000000]";
        mes "Enjoy your Gifts.";
        close;
     }
    end; //Should never happen
                
    OnInit:
    waitingroom "WELCOME",0;
    end;
    }
  4. I'm not really updated about Athena, but you can try to remove the "E.G" part in every variable check call.

    if( #quest_done ) {
     
    set #quest_done, 1;

     

    Also, your freebies, even if divided by "Strengh, Dexterity and Intellect Type", give all the same items (you may need to check thi :P

  5. ..in C not in script npc, and it's about script npc here ;)

    My bad about that then, but Kenpachi said it correctly:

     

     

    In that case *Athena has a bug. ^^

    BTW; That's not just in C but in every other language I know.

    These are standards which everybody should follow them.

  6. You try to set the veriable player_point to the result of player_point++. The result is, that player_point still holds the same value.

    You mean the variable player_point stay the same ?

    player_point -> 0

    set player_point, player_point++; -> 0 ?

    Coz that's not true :P

     

    Actually, he is correct speaking about the instance scope.

    But you are correct as well, because the variable check is located in another scope.

     

    a = 1;
    b = a++;
    //b stores 1, not 2.
     
    a = 1;
    b = ++a;
    //b stores 2

    That's what Kenpachi means. During the execution command, a "var++" command is executed after the scope of the command it is located. Practically, as it is the same variable you are using, it makes no difference but to set an unneeded command; otherwise, if you work with more than 1 variable, it may land out in weird errors.

    set a, a++;
    //Is equal to:
    set a, a;
    a++;

     

     

     

    Hi,

    i try to make a script where a player var get every time +1. For some reason it dont work. Here is my script:

    payon,111,110,5	script	Crazy Man	757,{
    
    set player_point, player_point==0;
    
    OnHit:
    if (player_point==5)						
    { getitem 999,1;							 
    }
    else{
    set player_point, player_point++;
    mes ""+player_point+"";
    goto L_change;
    }
    L_change:
    
    mes "....";
    end;
    
    												}
    
    

    It's really long I don't script for Ragnarok Online, so I don't really know if OnHit actually is a viable On-label event or not, what it does or if you recall it through a onevent command.

    Just remember that each time you click on the NPC, you get your variable resetted. So, to trigger the getitem thing, you need to activate the "OnHit" label 5 times without clicking on the NPC.

    Also, the L_change label is pretty much useless 'cause you jump in there in any case.

     

    payon,111,110,5    script    Crazy Man    757,{
    
    set player_point, player_point==0; //I don't know if you need a reset here... but well...
    
    OnHit:
        player_point++;
        if( player_point == 5 )                        
            getitem 999,1;                             
        dispbottom "...";
        end;
    }
  7. I was wondering if there was any script command that would check if a player has a costume item equipped?

    What do you mean by "costume"?

    If you mean cloth-changing, such as Santa Suit or other custom suits, refer to Checkoption.

    If you mean to check if there is an item equipped on a certain slot, refer to Getequipid.

    Tip: getequipid() is a function that needs a certain argument to work. You can find the list of possible arguments in the wiki page I linked above.

    Tip2: to check if the slot is empty (nothing is equipped), just check if the function returns -1 or not.

    if( getequipid(2) == -1 ) { mes "You are not wearing an Armor!!"; }

    input low_head; 

    About the input command, try not to use permanent player-attached variables to store your input, but just set them as Scope.

    input .@low_head;
    // OR, if you need to attach it to a player
    input @low_head;

  8. set .@taid,getcharid(3,.@tmp$);
    if(!.@taid){
    mes "Char is offline or not exist";
    close;
    }
    set .@said,getcharid(3);
    attachrid(.@taid);

    You can optimize this part just by using attachrid. A little bit more tricky, but helps saving heap and lowers the C-O

    (credits to you)

    input .@tmp$;
    
    set .@MyID, getcharid(3);
    if( !attachrid(getcharid(3,.@tmp$)) ) {
       mes "Char is offline or not exist";
       close;
    }
    
    set .@value, ABCDEFG;
    attachrid(.@MyID);
    mes .@tmp$ + "'s ABCDEFG variable has value: " + .@value;

  9. The area is based on where the npc is located.

    prontera,100,150,0    script    Summoner    -1,2,2,{
    
    OnTouch:

    the "2,2" after -1 script means that you're gonna trigger the OnTouch even label when a player walks into a 5x5 square centred at prontera 100 150.

    So basically, X: 98~102, Y: 148~152. Changing the "2,2", will increase/decrease the area.

    1,1 -> 3x3 area around where the npc is located.

    2,2 -> 5x5

    3,3 -> 7x7

    And so on.

    OnTouch:
    
       //Prevent to summon if a monster is already summoned or before 30 minutes
       if( .isSummoned )
           end;
    
       .isSummoned = 1;
       getmapxy .map$, .@x, .@y, 0;
       monster .map$, .@x, .@y, "Summoned Monster", 1952, 1, strnpcinfo(0) + "::OnMonsterDead";
       initnpctimer;
       end;
    
    //10 minutes...
    OnTimer600000:
       killmonster .map$, strnpcinfo(0) + "::OnMonsterDead";
       end;
    
    //Reopening the event after 30 minutes
    OnTimer1800000:
       stopnpctimer;
       .isSummoned = 0;
       end;

    Note that the part of not being able to summon in 30 minutes can be easily done with gettimetick() as well, but as I started a timer for killing it, I prefered to keep using that timer.

  10. else { announce strcharinfo(0)+" pwned "+rid2name(killedrid)+"'s head", ((.Broadcast)?bc_all:bc_map), .KColor$; }

    This should work, why replacing it? bc_map already sent the broadcast to the map the atteched character is...

    EDIT:

    ok sry, I was wrong ( got tricked by Ryokem post )

    2.

    set .Broadcast, 0; //Where do you want to broadcast? (0:bc_all|1:bc_map)

    set this to 1

    you can forget about mapannounce, because its already in the setting ( I failed to noticed it earlier )

    How I could know he had this sort of script lol? he asked for how to announcing in 1 map only :P

  11. Also, assuming you want to use setd/getd for other reason, lemme explain how to do it properly, 'cause the way you did is wrong.

    setd / getd dynamically recall the name of a variable. This means that the variable name must be the argument of those functions.

    Example:

    Here you have an array of N elements, and you want to set all N elements to 1;

    (Don't answer with "there are more efficient methods to do this", I know there are, I'm just showing how setd/getd works).

    set .@array[0], 1;
    set .@array[1], 1;
    //[...]
    set .@array[N], 1;

    Let's use setd

    for( .@i = 0; .@i < N; .@i++ )
       setd ".@array[" + .@i + "]", 1;

    The same thing goes for getd.

    if you want to recall index 9 of .SummonType array, all the array name and index is the "variable name", so must be everything inside getd argument.

    "+getd("SummonType")+[.@i]+"

    set .@i, 9;
    mes "Your array has value: " + getd(".SummonType[" + .@i + "]") + " in index 9.";

    It's obvious that not only munbers can be built into setd/getd function, but also the variable names themselves.

    set $@pikachu, 2;
    
    //The same as...
    
    set .@temp$, "@pika";
    setd "$" + .@temp$ + "chu", 2;

    Hope it helped :)

  12. I can hardly believe I am being taught to use ELSE... /...

    that was for educational purpose .... ok we are complicating this topic

    'Cause you will 100% fall in that case if it jumps to that else.

    I like an explanation to this ...

    What's so hard to understand?

    set .@rand, rand( 20+50+60 ) ;

    Will randomize a number from 0 to (20+50+60)-1. Are you fine with this?

    else if ( .@rand < 20+50+60 )

    .@rand is OBVIOUSLY < (20+50+60) because its range goes from

    Will randomize a number from 0 to (20+50+60)-1.

    So you are just using server memory to check something obvious.

    Then, just use else, instead of else if, as there no need to check the obvious.

    Is this really so difficult to understand? O.o

  13. yeah its lower , that's why I use < and not using <=

    how about you post up your script so let's compare our methods

    I meant like this

    -	script	asdf	-1,{
    Onasdf:
    set .@rand, rand( 20+50+60 );
    if ( .@rand < 20 ) {
    	getitem "gold_coin", 2;
    	announce strcharinfo(0) +" has earn gold coin x2", bc_all;
    }
    else if ( .@rand < 20+50 ) {
    	getitem "poring_coin", 5;
    	announce strcharinfo(0) +" has earn poring coin x5", bc_all;
    }
    //else if ( .@rand < 20+50+60 ) { //Your version.
    else {
    	set zeny, zeny + 50000000;
    	announce strcharinfo(0) +" has earn zeny 50,000,000", bc_all;
    }
    }

    'Cause you will 100% fall in that case if it jumps to that else.

    So no need to do the if (.@rand < 20+50+60 ) check :)

  14. I was trying to do this years ago.

    However it's not optimized and query_sql will really simplify and speed up everything, that's a sample of what I planned years ago (also, when my scripting abilities were not great.)

    First, I was saving all the players IDs into an array each time they log in, and deleting them each time they log out.

    OnPCLoginEvent:
    set .PeopleOnline[getarraysize(.PeopleOnline)], getcharid(0);
    //...
    
    OnPCLogoutEvent:
    set .@tmp$, strcharinfo(0);
    for( .@i = 0; .@i < getarraysize(.PeopleOnline$); .@i++ )
       if( .@tmp$ == PeopleOnline$[.@i] ) {
        deletearray PeopleOnline$[.@i], 1;
        break; //Useless to keep the for loop
       }
    

    Second, I looped all the online players to check whoever was in that map.

    then, I save players into a temporary array

    //Save my AID
    set .@myAid, getcharid(3);
    
    for( for( .@i = 0; .@i < getarraysize(.PeopleOnline$); .@i++ ) {
       attachrid(getcharid(3,.PeopleOnline$[.@i])); //Actually it shouldn't be necessary an online check for obvious reason.
       if( strcharinfo(3) == "Your_map" )
        set .@array$[getarraysize(.@array)], .PeopleOnline$[.@i];
    }
    
    //Attaching back my RID
    attachrid(.@myAid); //There, maybe a check should be added.

    So, you now have .@array$ array that has stored the names of who is in "Your_map" map.

    So you can choose one randomly...

    set .@randomPlayer$, .@array$[rand(getarraysize(.@array$))];
    dispbottom "You randomly selected " + .@randomPlayer$;

    • Upvote 1
  15. .... are you asking to be spoon feed ?

    set .@rand, rand( 20+50+60 );
    // [...]
    else if ( .@rand < 20+50+60 ) {
    //Do stuff
    }

    What's the point of this? .@rand goes from 0 to (20+50+60)-1, it's obvious that its lower than (20+50+60) xD You added an useless check.

    Just like this will be enough ;)

    set .@rand, rand( 20+50+60 );
    // [...]
    else {
    //Do stuff
    }

  16. @Ryoken

    hMDyk.png

    inside post#1 or.... script release section

    Yeah LOL, I noticed it too late, just right after posting the message.

    Updated Post#20 anyway :3

    EDIT:

    Thanks for the eval KeyWorld. Overall was it a fun script? I will refine it and continue to improve it. It was pointed out that the game was impossible to make fun because it was a dialog based game, so I went away from that and made it use cutins. That wasn't all that bad compared to the hundreds of cutins for my multiplayer texas holdem script I made!

    Yeah, the idea itself is pretty nice, just you have to work out about how to structure it to optimize your code.

×
×
  • Create New...