Jump to content
  • 0

Message board that displays an Item owner ( server wide )


Question

Posted

Good Day,

 Can someone assist me in creating this scripts. Basically I want to create a message board in prontera that will display the names of owners of a specific item/items . The scan will show ALL owner online or offline . 

Outline :

NPC > list of specific items > list of owners

It's somewhat related to this but a player doesn’t need to input anything , when he/she clicks the npc he will be shown the list of the items and when clicked will show current owners.

https://rathena.org/board/topic/78972-check-character-if-he-has-the-item/

Kind Regards

6 answers to this question

Recommended Posts

  • 0
Posted (edited)

heck, they use *query_sql, which is not thread-safe
better use *addrid

prontera,155,185,5	script	ksdfhksdjf	1_F_MARIA,{
	mes "input item ID";
	next;
	input .id, 0, 65535;
	if ( !.id ) close;
	if ( getitemname(.id) == "null" ) {
		mes "item ID doens't exist";
		close;
	}
	donpcevent strnpcinfo(0) +"::OnGetAID";
	copyarray .@name$, .name$, .c;
	.@c = .c;
	copyarray .@cname$, .cname$, .cc;
	.@cc = .cc;
	copyarray .@sname$, .sname$, .sc;
	.@sc = .sc;
	copyarray .@gname$, .gname$, .gc;
	.@gc = .gc;
	while (true) {
		switch( select( "Inventory", "Cart", "Storate", "Guild Storage" ) ) {
		case 1:
			mes "Inventory";
			for ( .@i = 0; .@i < .@c; ++.@i )
				mes (.@i +1) +". "+ .@name$[.@i];
			break;
		case 2:
			mes "Cart";
			for ( .@i = 0; .@i < .@cc; ++.@i )
				mes (.@i +1) +". "+ .@cname$[.@i];
			break;
		case 3:
			mes "Storage";
			for ( .@i = 0; .@i < .@sc; ++.@i )
				mes (.@i +1) +". "+ .@sname$[.@i];
			break;
		case 4:
			mes "Guild Storage";
			for ( .@i = 0; .@i < .@gc; ++.@i )
				mes (.@i +1) +". "+ .@gname$[.@i];
			break;
		}
		next;
	}
	end;
OnGetAID:
	.c = .cc = .sc = .gc = 0;
	addrid 0;
	if ( countitem(.id) ) .name$[.c++] = strcharinfo(0);
	if ( cartcountitem(.id) ) .cname$[.cc++] = strcharinfo(0);
	if ( storagecountitem(.id) ) .sname$[.sc++] = strcharinfo(0);
	if ( guildstoragecountitem(.id) ) .gname$[.gc++] = strcharinfo(0);
	end;
}

EDIT for below : LOL forgot to reset the variables /heh

Edited by AnnieRuru
  • 0
Posted

Hi @AnnieRuru thank you for this .I'm trying to change this that instead of inputting the item ID. There will be a define 10 item ID that will be look up. Those items will be just in inventory as it will be character bounded so no need for the switch selection.

Also I tested this and it do show the result but it doesn't clear the result after the player stop talking with the npc. It saves it like a history .

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

I tested this and it do show the result but it doesn't clear the result after the player stop talking with the npc. It saves it like a history .

HAHAHA /heh
sometimes I do get this silly mistakes

 

prontera,155,185,5	script	ksdfhksdjf	1_F_MARIA,{
	mes "select an item ID";
	next;
	.id = .itemid[ select( .menu$ ) -1 ];
	donpcevent strnpcinfo(0) +"::OnGetAID";
	mes "These are the players having";
	mes "^0000FF"+ getitemname(.id) +"^000000 in their inventory.";
	for ( .@i = 0; .@i < .c; ++.@i )
		mes (.@i +1) +". "+ .name$[.@i];
	close;
OnGetAID:
	.c = 0;
	addrid 0;
	if ( countitem(.id) )
		.name$[.c++] = strcharinfo(0);
	end;
OnInit:
	setarray .itemid,
		501, 502, 503, 504, 505; // add more item here to show
	.@size = getarraysize(.itemid);
	for ( .@i = 0; .@i < .@size; ++.@i )
		.menu$ += getitemname(.itemid[.@i]) +":";
	end;
}

 


 

On 6/1/2018 at 9:58 AM, kamirie said:

The scan will show ALL owner online or offline 

omg ... I guess have to use query_sql after all ...

prontera,155,185,5	script	ksdfhksdjf	1_F_MARIA,{
	mes "select an item ID";
	next;
	.id = .itemid[ select( .menu$ ) -1 ];
	.@id = .id;
	donpcevent strnpcinfo(0) +"::OnGetAID";
	mes "These are ^009900Online^000000 players having";
	mes "^0000FF"+ getitemname(.@id) +"^000000 in their inventory.";
	for ( .@i = 0; .@i < .c; ++.@i )
		mes (.@i +1) +". "+ .name$[.@i];
	next;
	mes "These are ^FF0000Offline^000000 players having";
	mes "^0000FF"+ getitemname(.@id) +"^000000 in their inventory.";
	.@nb = query_sql( "select name from inventory left join `char` on inventory.char_id = `char`.char_id where `char`.online = 0 and inventory.nameid = "+ .@id, .@name$ );
	for ( .@i = 0; .@i < .@nb; ++.@i )
		mes (.@i +1) +". "+ .@name$[.@i];
	close;
OnGetAID:
	.c = 0;
	addrid 0;
	if ( countitem(.id) )
		.name$[.c++] = strcharinfo(0);
	end;
OnInit:
	setarray .itemid,
		501, 502, 503, 504, 505; // add more item here to show
	.@size = getarraysize(.itemid);
	for ( .@i = 0; .@i < .@size; ++.@i )
		.menu$ += getitemname(.itemid[.@i]) +":";
	end;
}

 

Edited by AnnieRuru
  • 0
Posted (edited)
19 hours ago, kamirie said:

A follow up question.Do you think this will be a resource hog since it's querying ?

then how about I ask back ...
do you think *announce with bc_all flag will lag your server ?

if your answer is no, then *addrid also doesn't lag your server
both does the same thing with manipulate data to all players

*query_sql should be very fast, and if you index the `nameid` field, yeah it will return result faster

 

EDIT: some time later

select name from inventory left join `char` on inventory.char_id = `char`.char_id where nameid = 501 and online = 0;
select name from ( select char_id from inventory where nameid = 501 ) as aaa left join ( select char_id, name from `char` where online = 0 ) as bbb on aaa.char_id = bbb.char_id;
select char_id as cid, ( select name from `char` where char_id = cid ) from inventory where nameid = 501;

well all 3 commands should return same result ... just testing
I think ... since the `char_id` field has been indexed in both tables, table JOIN should works fine I guess

Edited by AnnieRuru
  • Upvote 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...