Jump to content

Release: [Script Command] isselling - Discovery if a npc is selling a item by ID


Zell

Recommended Posts


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   261
  • Joined:  04/25/12
  • Last Seen:  

[Script Command] isselling - Discovery if a npc is selling a item by ID


This commands verify if a npc is selling, returning 1 to yes and 0 to no.

Its very useful to black market scripts for players who knows item id and don't want to lost time searching where items are sold.

Obs: Didn't test the sample script, but you can have a idea in how to use.

Sample Script:

prontera,150,150,5	Script	Who's Selling	90,{

	.@n$ = "[Who is Selling]";
	mes .@n$;

	// Its nice to put a delay in this script if you use a lot of stores in one map and in your .npc$ array
    // I'm using 5 seconds in this sample.
	if((gettimetick(2) - whosell_delay) < 5)
    {
    	mes "You have to wait 5 seconds to use me again.";
        close;
    }
                                            
    mes "Tell me the item ID you want to know what npc's is selling it!";
    input .@id; // You can test this sample with 607 ID
                                            
	whosell_delay = gettimetick(2);

    for( .@i = 1; .@i < getarraysize(.npcs$); .@i++)
	{
		.@found = isselling( getcharid(0), .npcs$[.@i], .@id );

		if( .@found )
		{
			next;
			mes "Ha, this item is " + getitemname( .@id ) + ", right?";
            next;
            mes .@n$;
            mes "Who is selling it is " + .npcs$[.@i] + "!";
            close2;
			showevent QTYPE_EVENT,QMARK_YELLOW,getcharid(0),.npcs$[.@i]; // Show in npc a ballon to player
			end;
		}
	}

	next;
	mes .@n$;
	mes "No npc selling it :)";
	end;

	OnInit:
		setarray .npcs$[1],"Store 1","Store 2";
		end;
}

prontera,151,150,5	shop	Store 1	90,607:1000
prontera,152,150,5	shop	Store 2	90,610:1000

 

image.thumb.png.ecf7a84e7fd721c9f0beae6339252850.png

image.png.3e575f0ba8bfa9f058cc91e535fe9c8f.png

 

image.thumb.png.49e88f7bcf3b501559b155f5cdfc2e5a.png

 

image.png.ddc035197a0656f5304c23864531c1e8.png

 

image.png.37037818f72c5851f924444deb9b0b93.png


 

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.02
  • Content Count:  242
  • Reputation:   37
  • Joined:  02/25/18
  • Last Seen:  

Really interesting but I'm not a good coder and I have this error:

Quote

[Error]: script error on npc/custom/utility/isselling.txt line 21
    parse_line: expected ';'
    16 :
    17 :        whosell_delay = gettimetick(2);
    18 :
    19 :     for( .@i = 1; .@i < getarraysize(.npcs$); .@i++)
    20 :        {
*   21 :                .@found = isselling( getcharid(0), .npcs$[.@i]',' .@id );
    22 :
    23 :                if( .@found )
    24 :                {
    25 :                        next;
 

Can you fix it for me please?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   261
  • Joined:  04/25/12
  • Last Seen:  

2 hours ago, CyberDevil said:

Really interesting but I'm not a good coder and I have this error:

Can you fix it for me please?

Hey, I tested and is everything working.

Prob you make the wrong changes. Undo and try again to applay the modifies.

 

image.thumb.png.ecf7a84e7fd721c9f0beae6339252850.png

 

image.png.3e575f0ba8bfa9f058cc91e535fe9c8f.png

 

image.thumb.png.49e88f7bcf3b501559b155f5cdfc2e5a.png

 

image.png.ddc035197a0656f5304c23864531c1e8.png

 

image.png.37037818f72c5851f924444deb9b0b93.png

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.02
  • Content Count:  242
  • Reputation:   37
  • Joined:  02/25/18
  • Last Seen:  

I tried to copy and load your script as you posted it without making any changes and I continue to receive the error that you can see in the attached screenshot.
Can youn attach here the script you use? Maybe there is some problem in the font encoing by copying it from the forum as it has happened to me in the past... let me try!sDBtZM.png.b0be66b7238964f4bf91c6edf0b96cfd.png

 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   261
  • Joined:  04/25/12
  • Last Seen:  

11 minutes ago, CyberDevil said:

I tried to copy and load your script as you posted it without making any changes and I continue to receive the error that you can see in the attached screenshot.
Can youn attach here the script you use? Maybe there is some problem in the font encoing by copying it from the forum as it has happened to me in the past... let me try!sDBtZM.png.b0be66b7238964f4bf91c6edf0b96cfd.png

 

I'm using the same script posted here, its working.

You have to make the source edits wich I post, as you can see you are in "source modifications" section, no "Script Section", so you have to modify the source to script works.

The script sample will work after you make the source modifies I put in txt file donwload

image.thumb.png.8c5d4be5853f59a7598510c8f3bd77df.png

Edited by Zell
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.01
  • Content Count:  73
  • Reputation:   1
  • Joined:  11/27/18
  • Last Seen:  

Nice, can you make search items selling by vendors?

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
Reply to this topic...

×   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...