Jump to content
  • 0

[SOLVED] [Debug]: Source (NPC): FAKE_NPC


Question

Posted (edited)

i always got the error in the picture when that says:


[Error]: buildin_getitem: Nonexistant item 0 requested.
[Debug]: Source (NPC): FAKE_NPC (invisible/not on a map)


heres my script can somebody tell me the error thanks in advance

function script specialbox {
    setarray .i[0],20727; // Itemlist in box
    set .chance, rand(100);

        // First item in list (20727) x 1 (1% Chance)
        if (.chance == 1){
        getitem .i[0],1;
        announce "["+strcharinfo(0)+"] won a ["+getitemname(.i[0])+"] from the Special Box.",0;
        end;
        } 

        // First item in list (20727) x 100 (5~10% Chance)
        if (.chance <= 10 && .chance > 5){
        getitem .i[1],100;
        end;
    }
}

 

1.PNG

Edited by chadness

2 answers to this question

Recommended Posts

  • 0
Posted

Try this.

Script.

function	script	Boxes	{

	setarray @i1[0],501; // Common
	setarray @i2[0],502; // Rare
	setarray @i3[0],503; // Super Rare
	set @i1rand,rand( getarraysize(@i1) ); 
	set @i2rand,rand( getarraysize(@i2) ); 
	set @i3rand,rand( getarraysize(@i3) ); 
   .chance = rand(100);

		// Super Rare
		if (.chance == 1){
			getitem @i3[@i3rand],1;
			announce "["+strcharinfo(0)+"] got ["+getitemname(@i3[@i3rand])+"] 'Super Rare'.",0;

		} 
        // Rare
		else if (.chance <= 10 && .chance >= 5){
			getitem @i2[@i2rand],1;
			announce "["+strcharinfo(0)+"] obtained ["+getitemname(@i2[@i2rand])+"] 'Rare'.",0;

		} 

		// Common
		else {
			getitem @i1[@i1rand],1;
			announce "["+strcharinfo(0)+"] obtained ["+getitemname(@i2[@i2rand])+"] 'Common'.",0;
	end; }
}

 

item_db (example).

501,Red_Potion,Red Potion,0,50,,70,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc "Boxes"; },{},{}

 

  • Upvote 1
  • 0
Posted
4 hours ago, cook1e said:

Try this.

Script.


function	script	Boxes	{

	setarray @i1[0],501; // Common
	setarray @i2[0],502; // Rare
	setarray @i3[0],503; // Super Rare
	set @i1rand,rand( getarraysize(@i1) ); 
	set @i2rand,rand( getarraysize(@i2) ); 
	set @i3rand,rand( getarraysize(@i3) ); 
   .chance = rand(100);

		// Super Rare
		if (.chance == 1){
			getitem @i3[@i3rand],1;
			announce "["+strcharinfo(0)+"] got ["+getitemname(@i3[@i3rand])+"] 'Super Rare'.",0;

		} 
        // Rare
		else if (.chance <= 10 && .chance >= 5){
			getitem @i2[@i2rand],1;
			announce "["+strcharinfo(0)+"] obtained ["+getitemname(@i2[@i2rand])+"] 'Rare'.",0;

		} 

		// Common
		else {
			getitem @i1[@i1rand],1;
			announce "["+strcharinfo(0)+"] obtained ["+getitemname(@i2[@i2rand])+"] 'Common'.",0;
	end; }
}

 

item_db (example).


501,Red_Potion,Red Potion,0,50,,70,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc "Boxes"; },{},{}

 

thanks men ❤️

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