Jump to content
  • 0

Message board that displays an Item owner ( server wide )


kamirie

Question


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

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

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

Thanks @AnnieRuru just what I needed. A follow up question.Do you think this will be a resource hog since it's querying ?

Edited by kamirie
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

Thank you

Link to comment
Share on other sites

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.

×
×
  • Create New...