Jump to content

Ryokem

Members
  • Posts

    205
  • Joined

  • Last visited

Posts posted by Ryokem

  1. Oh god, tons of useless if() and switch() statements that slow down everything /panic

    Example:

    switch(select("Sunday:Monday:Tuesday:Wednesday:Thursday:Friday:Saturday")) {
    case 1: set $KoEStartDay[.KoE],0; break;
    case 2: set $KoEStartDay[.KoE],1; break;
    case 3: set $KoEStartDay[.KoE],2; break;
    case 4: set $KoEStartDay[.KoE],3; break;
    case 5: set $KoEStartDay[.KoE],4; break;
    case 6: set $KoEStartDay[.KoE],5; break;
    case 7: set $KoEStartDay[.KoE],6; break;
    }
    

    Can easily scripted like...

    set .@s, select("Sunday:Monday:Tuesday:Wednesday:Thursday:Friday:Saturday") - 1;
    set $KoEStartDay[.KoE], .@s;

    ,

    or even

    set $KoEStartDay[.KoE], select("Sunday:Monday:Tuesday:Wednesday:Thursday:Friday:Saturday") - 1;

    /ok

    Well, try to replace:

    query_sql "UPDATE guild SET guild_points=guild_points +1 WHERE guild_id="+ getcharid(2);

    With:

    if ( playerattached() )
    query_sql "UPDATE guild SET guild_points=guild_points +1 WHERE guild_id=" + getcharid(2);

    The problem actually stands here:

    OnMinute00:
    set .KoE,0;
    StartLoop:
    if(gettime(4)==$KoEEndDay[.KoE]&&gettime(3)==$KoEEndTime[.KoE]) { goto KoEActualEnd;

    As you can see, he's calling the KoEActualEnd label from an OnMinute event label, so into a script that has NO rid attached.

    Checking that label...

    KoEActualEnd:
    disablenpc "Emperium Hill#1";
    if($KoEStatus==0) { end; }
    set $KoEStatus,0;
    if($GvGPvP==0) { gvgoff "vmorocc"; } else { pvpoff "vmorocc"; }
    if(getmapusers("vmorocc")>0) { MapRespawnGuildID "vmorocc",$KOEGUILD,7; }
    killmonsterall "vmorocc",0;
    set .@name$,GetGuildMaster($KOEGUILD);
    if($KOEGUILD!=0) { Announce "The King of Emperium Hill has ended! The King Of Emperium Hill is the ["+GetGuildName($KOEGUILD)+"] guild.",bc_all|bc_WoE; } else { Announce "The King of Emperium Hill has ended! No guild has proven themselves King Of Emperium Hill!",bc_all|bc_WoE; }
    query_sql "UPDATE guild SET guild_points=guild_points +1 WHERE guild_id="+ getcharid(2);
    end;
    

    You can easily notice that there is no commands that attach a RID to the script, and a getcharid() is called, commands that NEEDS a RID attached to work.

    Key-kun's solution actually solve the problem, but I don't really know if it makes the script work as it should (didn't read all the other things, too lazy to read a script that would need 1/5 lines to work the same :P)

  2. @Annie:

    Try never to use continue; script function. It's odd and pretty bad. I believe it works exactly as in C or C++, and that command was used to refresh the heap scrolling it from start to end, just to say "let the script continue", and that is actually pretty useless, it just helps to slow down the compiler.

    not that a friend of mine was even Fired from his ex agency for using it into a serial script... odd but true D:

    @Key:

    Is really rA system so bad that never implemented an enumeration? ._.

    Well, I could expect it from something it doesn't even have floats xD

  3. This gives .item_amount of .item_id each new day they log in. If you want to manage offline players too, you need to use some sql queries, but I don't really like that way to get free items if not playing :P

    OnPCLoginEvent:
    if( (obbDay == gettime(5)) && (obbMonth == gettime(6)) )
    end;
    
    set obbMonth, gettime(6);
    set obbDay, gettime(5);
    getitem .item_id, .item_amount;
    dispbottom "You have been rewarded with " + .item_amount + " " + getitemname(.item_id);
    end;
    
    OnInit:
    set .item_id, <obb id>;
    set .item_amount, <amount>;
    }

  4. Just add all possible bet-combinantion into different arrays, means the "red", "black", "close-to-0", "column 1-2-3", "even", "odd" and so on.

    Then, make an array that store every single bet of each player, and a parallel two other arrays which store the name of the player who did that bet and the bet amount.

    Then, for every bet, check if the corrispondent array contains the winning number, if so, reward the player.

    Delete all arrays in the end, and start back again.

  5. Npc variables are not a waste of "server resources" at all. The while() loop is a waste when it does nothing, that's for sure, but i was just editing the script depending on what he needed trying to leave his script untouched if possible. I just gave a brief explanation on how to do it in a general case, not on how to optimize a full script.

  6. Of course it talks the random messages.

    Disable the npc means that players CANNOT interact with it in any way, but all the other script triggers (event labels) still works.

    As the npctalk and the npcwalkto are called through the event label OnInit, it will keep doing it.

    You will have to set a variable to record if the npc is disabled or not.

    OnSun0000:
    OnTue0000:
    enablenpc strnpcinfo(0);
    .is_enable = 1;
    end;
    
    OnMon0000:
    OnWed0000:
    disblenpc strnpcinfo(0);
    .is_enable = 0;
     end; 

    while (1) {
    sleep .@interval * 1000;
    if( .is_enable ) {
    	getmapxy .@map$, .@x, .@y, 1;
    	while ( checkcell( .@map$, .@npc_x = .@x + rand( -.@step, .@step ), .@npc_y = .@y + rand( -.@step, .@step ), cell_chknopass ) );
    	npcwalkto .@npc_x, .@npc_y;  npctalk callfunc( "F_RandMes", 2,
    		"Heloo!!!", // 1
    		"Goodbye~!" // 2
        );
    }
    }

  7. prontera,97,153,5	script	Clemy	703,{  
    
    mes "If you can speak with me, I'm enabled!!!";
    close;
    
    
    //I've used On<weekdays><hour><minute>: event label.
    //Weekdays are Sun,Mon,Tue,Wed,Thu,Fri,Sat.
    
    //Days you want to ENABLE the NPC (NPC will last enabled until next disable)
    OnSun0000:
    OnTue0000:
    enablenpc strnpcinfo(0);
    end;
    
    //Days you want to DISABLE the NPC (NPC will last disabled until next enable)
    OnMon0000:
    OnWed0000:
    disblenpc strnpcinfo(0);
    end;
    
    OnInit:
    .@interval = 5;
    .@step = 5;
    while (1) {
    	sleep .@interval * 1000;
    	getmapxy .@map$, .@x, .@y, 1;
    	while ( checkcell( .@map$, .@npc_x = .@x + rand( -.@step, .@step ), .@npc_y = .@y + rand( -.@step, .@step ), cell_chknopass ) );
    	npcwalkto .@npc_x, .@npc_y;
    	npctalk callfunc( "F_RandMes", 2,
    		"Heloo!!!", // 1
    		"Goodbye~!" // 2
    	);		
    }
    }

  8. whoaa too many of them. btw thanks a lot for the announcer.. 2 thumps up =) i'll try each of them /no1

    OnMinute00:
    OnMinute30:
    if( .rand )
    	.index = rand(getarraysize(.announce$));
    else
    	.index = (.index+1) % getarraysize(.announce$);
    announce .announce$[.index], 0;
    end;
    
    
    OnInit:
    setarray .announce$,
    	"Sentence 1",
    	"Sentence 2",
    	"Sentence 3",
    	// Add as many as you wish
    	"Sentence N";
    
    .rand = 1; //Set 1 if you want random sentence each time, 0 if you want to announce it consecutively.
    end;

    have parse line problem in line 29.....

    There's not even Line 29 O.o Tell me what line and which error.

  9. set .Announcements$[0],"GameMasters will never ask for your account information.",
    "Broadcast Two",
    "Broadcast Three"; //etc..
    set .colour$[0],"0xFF0000",//red
    "0x00FF00", //Green
    "0x0000FF"; //blue
    

    Those are multiple values settings, so you must use Setarray ;)

  10. OnMinute00:
    OnMinute30:
    if( .rand )
    	.index = rand(getarraysize(.announce$));
    else
        .index = (.index+1) % getarraysize(.announce$);
    announce .announce$[.index], 0;
    end;
    
    
    OnInit:
    setarray .announce$,
    	"Sentence 1",
    	"Sentence 2",
    	"Sentence 3",
    	// Add as many as you wish
    	"Sentence N";
    
    .rand = 1; //Set 1 if you want random sentence each time, 0 if you want to announce it consecutively.
    end;

  11. I just tested -- enablenpc works from a disabled npc!

    lol it works

    I think it was fixed in 2010 or something ... so yeah disablenpc doesn't work like this 3 years ago, but now can

    Disablenpc just let users not to be able to run it, but you can still call his script with Event Labels or other NPC functions. So of course you can enable itself if he's disabled ;)

  12. Try to check the wiki page about the Guildchangegm command, there's a fully example about how to do it: Guildchangegm

    About he 2 conditions, just add an if statement for every of them:

    • 1m per Change Guild Leader

    if( Zeny < 1000000 ) {
       mes "not Enough Zeny";
       close;
    }
    
    //Paying...
    set Zeny, Zeny - 1000000;

    • Cannot change Guild Leader during WOE

    if( agitcheck() ) {
       mes "You can't change the GM while WoE is active! Come back later.";
       close;
    }

  13. Hello and thank you for all your help.

    The NPC now counts down, but only 60 and downwards. If there's longer than 60 seconds left, it'll just keep looking 60 seconds each minute.

    Yeah, you have to put some brackets.

    dispbottom "Please wait for "+ .@m +" min(s) "+ ( (.@s) ? .@s +" seconds" : "");

    Hmm, i never would have though of using ' set ' in an ( if ) statement.. didn't think the system could proccess that lol. *Keeps an eye on you* I'm looking forward to seeing other things you'll do lol.

    Do not forget that all commands are monitored by a source function, and regardless from what they do, they always have some values as return, most of them are booleans (true, false), another good part is integers or float/double (not in e/rAthena case as those kind of variables are not really implemented).

  14. maybe (saying maybe cause I really don't know about that) when you invoke the getexp command, it just takes the already multiplied exp from the monsterinfo, and then multiply back again due to the quest_exp_rate, that's why it increases this much. You can try to do some tests setting (for example) 1 as poring's base exp, and checking what kind of moltiplications the server compute.

    EDIT:

    hahaha!

    EDIT: Damn, 3 people at once XD
    EDIT: <3 u Annie xD
  15. Note that 'getexp' is now subject to the 'quest_exp_rate' config option, which

    adjusts the gained value. If you want to bypass this, use the 'set' method.

    Getexp

    Maybe you can try with the set method...

    set BaseExp, BaseExp + getmonsterinfo(killedrid,3);
    set JobExp, JobExp + getmonsterinfo(killedrid,4);

    EDIT: <3 u Annie xD

  16. I'm sure you can read the source file ... no need me to explain ...

    somehow I feel like you love to attack my post because I have no programming background :ani_swt3:

    Nah, I don't have any purpose on "attacking" you or your posts. Do you think I really have any interest about showing my abilities this way? I would have way better things to do xD. Just I feel that you are pretty nice a cooperative girl, and your help is good for a nice community, so matching with you and the others is (in my opinion) always a good way for both sides (so me as well) to improve their knowledges or to learn something new. Also 'cause even if my knowledges about Programming are quite good, rAthena is still a new world for me, and facing people who knows it can help me to understand the whole rA background system. So don't feel like I'm attacking anyone xD *pokes Annie and hugs her kindly* :P

×
×
  • Create New...