Jump to content
  • 0

Conditions for Labels and inside menus


Question

Posted (edited)

Two questions about conditions:


Conditions for labels: Its possible to add a condition to pass to a Label? like, a condition of groupid 1 for OnPCDieEvent to trigger in the player. (I know i can do it inside the label, but i cant make it work otherwise).


Condition inside a menu: IDK how o do it, tried this(i apologize if its stupid xD, i am very new in scripting) :

switch(select("+((countitem(34996) >= 1)"wow you have item 34996")+":"some text")) { }

its supposed to print case 1 only if the player has the item, otherwise it should only print case 2.

Edited by Brizyous

9 answers to this question

Recommended Posts

  • 0
Posted

for the labels , the rathena official labels controled by the src , you can not call it , it would be called automatically , however you can make your own label (see goto or callsub command scripts)

for the Condition i think you are missing something >> see this example and figure it out

mes ((1 != 0)?"true":"false");

 

  • Upvote 1
  • 0
Posted
5 hours ago, Brizyous said:

Two questions about conditions:


Conditions for labels: Its possible to add a condition to pass to a Label? like, a condition of groupid 1 for OnPCDieEvent to trigger in the player. (I know i can do it inside the label, but i cant make it work otherwise).


Condition inside a menu: IDK how o do it, tried this(i apologize if its stupid xD, i am very new in scripting) :


switch(select("+((countitem(34996) >= 1)"wow you have item 34996")+":"some text")) { }

its supposed to print case 1 only if the player has the item, otherwise it should only print case 2.

switch(select( (countitem(34996) >= 1)? "wow you have item 34996":"some text")) { }
  • Upvote 1
  • 0
Posted
6 hours ago, pajodex said:

switch(select( (countitem(34996) >= 1)? "wow you have item 34996":"some text")) { }

Thanks! it worked but the arguments replace each other generating a 1 option menu, what i want is if the players have 4 items, they get a 4 option menu, if they have 2 items, they get 2 options, corresponding to the item they have.
Tried this, but i get errors:
 

switch(select((countitem(34996) >= 1)?"Insertar Ticket Clase C" , (countitem(34995) >= 1)?"Insertar Ticket Clase B" , (countitem(34994) >= 1)?"Insertar Ticket Clase A" , (countitem(34993) >= 1)?"Insertar Ticket Clase S" , "Cancelar")) {

	case 1:
	mes "ticket 1";
	close;
	end;
	case 2:
	mes "ticket 2";
	close;
	end;
	case 3:
	mes "ticket 3";
	close;
	end;
	case 4:
	mes "ticket 4";
	close;
	end;
	case 5:
	close;
	end;

}

 

  • 0
Posted

I already lost count how many times I have been using getinventorylist this month ...

function	script	F_MesItemInfo	{
	.@item = getarg(0);
	.@itemname$ = getitemname(.@item);
	if (.@itemname$ == "null")
		.@itemname$ = "Unknown Item";
	if (PACKETVER >= 20150729)
		return sprintf("<ITEM>%s<INFO>%d</INFO></ITEM>", .@itemname$, .@item);
	else if (PACKETVER >= 20130130)
		return sprintf("<ITEMLINK>%s<INFO>%d</INFO></ITEMLINK>", .@itemname$, .@item);
	else
		return .@itemname$;
}

prontera,155,185,5	script	jdshfjsdfh	1_F_MARIA,{
	getinventorylist;
	for ( .@i = 0; .@i < @inventorylist_count; ++.@i ) {
		if ( inarray(.itemlist, @inventorylist_id[.@i] ) >= 0 ) {
			.@itemid[.@c++] = @inventorylist_id[.@i];
			.@menu$ += getitemname( @inventorylist_id[.@i] ) +":";
		}
	}
	if ( !.@c ) {
		mes "You don't have any ticket on you";
		close;
	}
	.@s = select( .@menu$ ) -1;
	mes "You have selected "+ F_MesItemInfo(.@itemid[.@s]);
	close;
OnInit:
	setarray .itemlist, 909,910,911,912,
		34993,34994,34995,34996;
	end;
}

 

  • Upvote 1
  • 0
Posted (edited)
1 hour ago, AnnieRuru said:

I already lost count how many times I have been using getinventorylist this month ...


function	script	F_MesItemInfo	{
	.@item = getarg(0);
	.@itemname$ = getitemname(.@item);
	if (.@itemname$ == "null")
		.@itemname$ = "Unknown Item";
	if (PACKETVER >= 20150729)
		return sprintf("<ITEM>%s<INFO>%d</INFO></ITEM>", .@itemname$, .@item);
	else if (PACKETVER >= 20130130)
		return sprintf("<ITEMLINK>%s<INFO>%d</INFO></ITEMLINK>", .@itemname$, .@item);
	else
		return .@itemname$;
}

prontera,155,185,5	script	jdshfjsdfh	1_F_MARIA,{
	getinventorylist;
	for ( .@i = 0; .@i < @inventorylist_count; ++.@i ) {
		if ( inarray(.itemlist, @inventorylist_id[.@i] ) >= 0 ) {
			.@itemid[.@c++] = @inventorylist_id[.@i];
			.@menu$ += getitemname( @inventorylist_id[.@i] ) +":";
		}
	}
	if ( !.@c ) {
		mes "You don't have any ticket on you";
		close;
	}
	.@s = select( .@menu$ ) -1;
	mes "You have selected "+ F_MesItemInfo(.@itemid[.@s]);
	close;
OnInit:
	setarray .itemlist, 909,910,911,912,
		34993,34994,34995,34996;
	end;
}

 

Thanks for this magic, but how to have differents effect depending on the selected item? if i simply add countitem if they have 2 items the condition will pass.

Edited by Brizyous
  • 0
Posted
5 hours ago, Brizyous said:

Thanks! it worked but the arguments replace each other generating a 1 option menu, what i want is if the players have 4 items, they get a 4 option menu, if they have 2 items, they get 2 options, corresponding to the item they have.
Tried this, but i get errors:
 


switch(select((countitem(34996) >= 1)?"Insertar Ticket Clase C" , (countitem(34995) >= 1)?"Insertar Ticket Clase B" , (countitem(34994) >= 1)?"Insertar Ticket Clase A" , (countitem(34993) >= 1)?"Insertar Ticket Clase S" , "Cancelar")) {

	case 1:
	mes "ticket 1";
	close;
	end;
	case 2:
	mes "ticket 2";
	close;
	end;
	case 3:
	mes "ticket 3";
	close;
	end;
	case 4:
	mes "ticket 4";
	close;
	end;
	case 5:
	close;
	end;

}

 

switch(select((countitem(34996))?"Insertar Ticket Clase C":"" , (countitem(34995)) ? "Insertar Ticket Clase B":"", (countitem(34994)) ? "Insertar Ticket Clase A":"", (countitem(34993)) ? "Insertar Ticket Clase S":"", "Cancelar"))

 

  • Upvote 1
  • Love 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...