Jump to content

Kavaline

Members
  • Posts

    18
  • Joined

  • Last visited

Posts posted by Kavaline

  1. Guys, how I can pass/access 2 or more values to var1~4 of sc_start? Something with this logic (SC_CUSTOM alread declared and functional, codes in right functions)

    short eff_array[] = {SC_CURSE, SC_STUN};
    clif->skill_nodamage(src, bl, skill_id, skill_lv,
        sc_start2(src, bl, SC_CUSTOM, 100, 2000, eff_array, skill->get_time(skill_id, skill_lv)));
    int i;
    for (i = 0; i <= sizeof(sc->data[SC_CUSTOM]->val2); i++) {
        if (sc->data[SC_CUSTOM]->val2[i] == type) return 0; //error here, with 'i'
    }

     

  2. 19 minutes ago, Start_ said:

    Item UID is only on equipable items (maybe).

    Look at inventory table

    image.png.ee103e1d90862a02b9d65994ebe1ad81.png

    This is useful, thanks. I need know if have any debug message that shows their GID, like in an error, or something like this, for non-equipable items. When an Apple is generated, for example, the game had to know exactly what the Apple was generated, I think. Or if have any other way to attach a variable to an unique Item.

  3. Hi, have any way to attach variables to a specific item (not all Apples, but only a specific Apple)? I tried search how to get the GID of an item, but didn't found a way, and saw no one method for an item hold a variable or attach a variable for a specific item. Only way that I found is the card slots, but I can't use with crafted items that already use the slots, like Alchemist potions, and another scripts that use this, like Sign/Bound NPC.

    Someone know how I can do it?

  4. How I can get an item GID, or a similar unique variable? For healing item, or equipment, or misc item, anyone?

     

    And, is possible to change a script of an only one item? For example, all Apples recover 16~22 HP, but make only one Apple recover 7~10% SP without change all Apples or creating a new Apple?

    (Before anyone ask, I want the item GID for other purpose. Thinking about the item GID gave me this question, but I need the item GID to solve other problem).

  5. Hi, I need help for a script that break the players equipped weapon (not delete the player weapon, but breaks that return the weapon with broken status). I tried "delequip" with "getitem2", but how I get the slotted cards? And in case of BS/WS crafted weapons and signed weapons, have problem?

     

    And, have any way to do it better than:

    get weapon id;
    get refine;
    get card 1;
    get card 2;
    get card 3;
    get card 4;
    delequip;
    getitem2(weapon id, 1, 1, refine, 1, 0, card 1~4);

    Some item script, function, effect, etc, that I can use to do it better/easier?

  6. Thanks for the answers ?

    52 minutes ago, Tokei said:

    Heya,

    Don't use timers that run scripts on players (you should avoid using the addtimer command entirely). The reason for that is you're attempting to run two scripts at once, and the script engine doesn't support that very well. Set the timer as a local variable instead:

    
    	mes "type anything in 5 seconds";
    	.@limit = gettimetick(0) + 5000;
    	input(.@text);
    	clear();
    	
    	if (gettimetick(0) >= .@limit) {
    		mes "time over";
    		close;
    	}
    	
    	mes "you did it";
    	close;

     

    Works perfectly for what I want, because more than one player will activate the NPC. Thanks for the tip ?

  7. Hi, I want a script that gives the player 5 seconds to type a word, with 'input'. But when the time runs out, the script runs normally, and after, read the event label of the time out.

    Here is what I tried:

    	mes "type anything in 5 seconds";
    	addtimer(5000, strnpcinfo(NPC_NAME_UNIQUE)+"::On5secs");
    	input(.@text);
    	deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::On5secs");
    	next;
    	mes "you did it";
    	close;
    
    On5secs:
    	mes "time over";
    	close;

    Maybe is impossible for the 'timer' force close the 'input', but at least, I want a way that after the 'input', run the time out label if the time out, without run the lines above of the script. How I can do it?

  8. I have a string var with the item name stored (a Jellopy, for example). How I get the ID of the Jellopy by their name, via NPC script?

    I need do this in this way, because the name that I get is dynamic, based on a long list of items.

    I want something like "getitemname(<item id>)", but moke like "getitemid(<item name>)", or a way to get it, without using "searchitem(<array name>, "<item name>")".

  9. @Start_

    Not full working, same problem: after use one charge (the 5/5 charge), the NPC aways says "Next Charge in 10 seconds.", but now, the charge recover after the right time ?

    And, after the second use, he shows the right recharge time. I think that first use when in full charge dont update the .cont. But my idea is: in full charge, start the npctimer, that in this state, give the .count the right countdown time, and after one second, in the OnTimer, update for the player. But looks like he don't update using the 5/5 charge, to tell the player the right time, only after talking again, he update right, and I can't find why.

    @edit

    The most important is the timer count rightly, the time left message is for help me in debug, so, don't need fix this, because I will remove this showing message. Thanks for the help, the working code is that I need, and is functional.

    But, you can explain me why my timer dont start, but start with your edit? I want understand better what I did wrong, and don't repeat the same mistake.

     

    On 2/18/2020 at 4:04 PM, Start_ said:
    
    -	script	TestScript::QuickTest	4_F_03,{
    	mes "What you want?";
    	next;
    	switch(select("Use Charge", "See Charge", "Exit")) {
    	case 1:
    		if (.n_now > 0){
    			.n_now--;
    			if (.n_now < .n_max) {
    				setnpctimer 0;
    				initnpctimer;
    				npctalk "Starting recharges.";
    			}
    			getitem 512, 1;
    			.cont = .delay;
    			mes "Current C.: "+.n_now+"/"+.n_max;
    			mes "Next Charge in "+((.cont)/1000)+"s.";
    		}
    		else{
    			mes "No Charges.";
    		}
    		close;
    	case 2:
    		mes "Delay per C.: "+.delay/1000+"s";
    		mes "Current C.: "+.n_now+"/"+.n_max;
    		mes "Next Charge in "+((.cont)/1000)+"s.";
    		close;
    	}
    	close;
    
    OnTimer4000:
    	.n_now++;
    	.cont = .delay;
    	npctalk "Current C.: "+.n_now+"/"+.n_max;
    	stopnpctimer;
    	setnpctimer 0;
    	if (.n_now >= .n_max)
    	end;
    	initnpctimer;
    	npctalk "Next Charge in "+((.cont)/1000)+"s.";
    	end;
    	
    OnInit:
    	.n_max = 5;		//max charges
    	.n_now = 5;		//actual charge
    	.delay = 4*1000;//time to recover 1 charge
    	.cont = 0;		//actual time left to recharge
    	end;
    }
    
    prontera,164,170,4	duplicate(QuickTest)	Test Quick#prt	4_F_03

    Tested.

    Awesome, much better than what I tried!

  10. Hi, I write a script that a NPC have X charges (common for all players), and the players can spent a charge.

    After this, the NPC starts a timer (common for all players) to recharge, until their limit of X charges.

    Here is:

    -	script	TestScript::QuickTest	4_F_03,{
    	mes "[Quick Test]";
    	mes "What you want?";
    	next;
    	switch(select("Use Charge", "See Charge", "Exit")) {
    	case 1:
    		if (.n_now > 0){
    			mes "[Quick Test]";
    			if (.n_now == .n_max) {
    				setnpctimer 0;
    				initnpctimer;
                    mes "Starting recharges.";
    			}
    			.n_now -= 1;
    			getitem 512, 1;
    			mes "Done. Current Charges: "+.n_now+"/"+.n_max+".";
    		}
    		else{
    			mes "[Quick Test]";
    			mes "No Charges.";
    		}
    		close;
    	case 2:
    		mes "[Quick Test]";
    		mes "Next Charge in "+((.cont)/1000)+" seconds.";
    		close;
    	}
    	close;
    
    OnInit:
    	set .n_max, 5;		//max charges
    	set .n_now, 5;		//actual charge
    	set .delay, 10*1000;//time to recover 1 charge
    	set .cont, 0;		//actual time left to recharge
    	end;
    	
    OnTimer1000:
    	if (.cont <= 0) {
    		.cont = .delay;
    	}
    	else{
    		.cont -= 1000;
    		stopnpctimer;
    		setnpctimer 0;
    		if (.cont <= 0) {
    			.n_now++;
    			if (.n_now == .n_max) end;
    			.cont = .delay;
    		}
    		initnpctimer;
    	}
    	end;
    }
    
    prontera,164,170,4	duplicate(QuickTest)	Test Quick#prt	4_F_03

    But I can't make the timer work; the NPC aways says "Next Charge in 10 seconds.", and the charges don't recover.

    I will appreciate if someone tell me were is the error, or another easier solution better than npctimer (I use 'OnTimer1000' because others NPCs will have different .delay's, so, I can use the same scope, and the 'addtimer' is attached to the player).

  11.  

    19 hours ago, Litro Endemic said:

    i don't really see your direction of script but 2 dimensional array is not supported by script engine, use setd, getd or explode, implode

    https://lmgtfy.com/?q=rathena+2d+array

    I'm newbie in programming. I saw this post, but could't figure how to use, I got some errors, and by the time, I expected if another option was easier.

     

    8 hours ago, sader1992 said:
    
    ---------------------------------------
    
    *setd "<variable name>",<value>{,<char_id>};
    
    Works almost identically as set, except the variable name is identified as a string
    and can thus be constructed dynamically.
    
    This command is equivalent to:
    	set getd("variable name"),<value>;
    
    Examples:
    
    	setd ".@var$", "Poporing";
    	mes .@var$; // Displays "Poporing".
    
    	setd ".@" + .@var$ + "123$", "Poporing is cool";
    	mes .@Poporing123$; // Displays "Poporing is cool".
    
    NOTE:
    	'char_id' only works for non-server variables.
    	Player with Character ID 'char_id' must be online.
    
    ---------------------------------------
    
    *getd("<variable name>")
    
    Returns a reference to a variable, the name can be constructed dynamically.
    Refer to 'setd' for usage.
    
    This can also be used to set an array dynamically:
    	setarray getd(".array[0]"), 1, 2, 3, 4, 5;
    
    Examples:
    
    	set getd("$varRefence"), 1;
    	set .@i, getd("$" + "pikachu");
    
    ---------------------------------------

    example:

    
    	setarray .@x,1,2;
    	setarray .@x1,10,20,30,40,50;
    	setarray .@x2,100,200,300,400,500;
    
    	for(.@i=0;.@i<getarraysize(.@x);.@i++){
    		for(.@m=0;.@m<getarraysize(getd(".@x" + .@x[.@i]));.@m++){
    			debugmes "" + getd(".@x" + .@x[.@i] + "[" + .@m + "]");
    		}
    	}

     

    Works like a charm, this example was very helpful. The brackets needs to be in "" too, because of this, I got wrong results.

    Solved question, can close the topic. Ty guys :)

  12. Hi, I need write this kind of script:

    

    setarray .arrayAn[1], 1, 2, 3, 4, 5;
    setarray .arrayA$[1], "a", "b", "c", "d", "e";
    setarray .arrayBn[1], 6, 7, 8, 9, 10, 11;
    setarray .arrayB$[1], "f", "g", "h", "i", "j", "k";
    setarray .arrayCn[1], 12, 13, 14, 15;
    setarray .arrayC$[1], "l", "m", "n", "o";
    
    .@value = rand(1,getarraysize(.arrayAn));
    .resultn[1] = arrayAn[.@value];
    .result$[1] = arrayA$[.@value];
       
    .@value = rand(1,getarraysize(.arrayBn));
    .resultn[2] = arrayBn[.@value];
    .result$[2] = arrayB$[.@value];
         
    .@value = rand(1,getarraysize(.arrayCn));
    .resultn[3] = arrayCn[.@value];
    .result$[3] = arrayC$[.@value];

    Have any way to use matrix or other solution, doing something like this:

    setarray .arrayn[1][1], 1, 2, 3, 4, 5;
    setarray .array$[1][1], "a", "b", "c", "d", "e";
    setarray .arrayn[2][1], 6, 7, 8, 9, 10, 11;
    setarray .array$[2][1], "f", "g", "h", "i", "j", "k";
    setarray .arrayn[3][1], 12, 13, 14, 15;
    setarray .array$[3][1], "l", "m", "n", "o";
    
    for (.@i = 1; .@i <= 3; ++.@i) {
    	.@value = rand(1,getarraysize(.arrayn[.@i]));
    	.resultn[.@i] = arrayn[.@i][.@value];
    	.result$[.@i] = array$[.@i][.@value];
    }

    This is a script with testing values that I'm using to find a solution, my original script will needs 100 loops in this case (and will only use integers, for IDs and numbers, in non logical or consecutive order), and without matrix is really unfair. Have another option that help me?

×
×
  • Create New...