Jump to content
  • 0

callfunc not working for item


darkpatow

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  07/09/20
  • Last Seen:  

Hi,

I created an item that should call a function which gives a random item from a defined array of items and announce it globally.

I created this function using the same piece of code from a NPC who does the same (and it's working).

On item_db, I put {callfunc "a_box_visu";} in the script field. The other fields (except for ID) are just a copy from Gift Box 3. 

When I use the item, it vanishes from the inventory but nothing happens.

Here's my script:

function	script	a_box_visu	
	{
		set aboxqual, rand(1,2);
			if (a_boxqual == 1)
			{
				setarray $@a_boxarray[0]
				,31214,31215,31221,31229,31233,31244,31255,31267,31272,31273,31276,31279,31287,31292,31294,31298,31301
				,31303,31310,31313,31314,31318,31324,31326,31327,31334,31337,31338,31342,31345,31347,31348,31349,31355
				,31361,31363,31364,31372,31378,31380,31381,31387,31389,31393,31396,31398,31399,31435,31436,31440,31446
				,31448,31456,31457,31459,31460,31465,31467,31474,31480,31481,31490,31491,31492,31493,31495,31512,31516
				,31521,31524,31526,31527,31528,31529,31532,31537,31541,31547,31553,31555,31557,31559,31560,31573,31574
				,31575,31576,31577,31578,31579,31580,31581,31582,31583,31584,31585,31586,31587,31588,31592,31608,31615
				,31616,31623,31625,31631,31635,31636,31642,31648,31650,31651,31663,31672,31673,31682,31684,31692,31714,31724;
			}
			if(a_boxqual == 2)
			{
				setarray $@a_boxarray[0]
				,31725,31726,31730,31740,31742,31747,31750,31754,31757,31758,31764,31765,31775,31780
				,31788,31789,31793,31799,31803,31811,31812,31813,31815,31816,31835,31836,31840,31842
				,31850,31858,31865,31879,31883,31890,31894,31900,31905,31908,31914,31933,31946,31952
				,31953,31969,31982,32004,32015,32021,32064,32066,32067,32071,32075,32079,32098,32099
				,32100,32154,32157,32160,32173,32177,32216,32222,32225,32244,32269,32277,32278,32279
				,32297,32310,32311,32322,32340,32355,32359,32367;
			}
			
			set $a_boxid, rand(getarraysize($@a_boxarray[0]));
			getitem $@a_boxarray[$a_boxid],1;
			announce strcharinfo(0) + " acabou de obter um(a) " + getitemname($@a_boxarray[$a_boxid]) + " na Caixa Especial de Visuais.", bc_all;
	}

 

Does anyone have an idea why this isn't working?

I loaded the script using @loadnpc [path], and i reloaded item_db before using the item.

Any help will be appreciated ?

Edited by darkpatow
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   21
  • Joined:  11/08/15
  • Last Seen:  

function	script	a_box_visu	{
		set aboxqual, rand(1,2);
			if (a_boxqual == 1)
			{
				setarray $@a_boxarray[0]
				,31214,31215,31221,31229,31233,31244,31255,31267,31272,31273,31276,31279,31287,31292,31294,31298,31301
				,31303,31310,31313,31314,31318,31324,31326,31327,31334,31337,31338,31342,31345,31347,31348,31349,31355
				,31361,31363,31364,31372,31378,31380,31381,31387,31389,31393,31396,31398,31399,31435,31436,31440,31446
				,31448,31456,31457,31459,31460,31465,31467,31474,31480,31481,31490,31491,31492,31493,31495,31512,31516
				,31521,31524,31526,31527,31528,31529,31532,31537,31541,31547,31553,31555,31557,31559,31560,31573,31574
				,31575,31576,31577,31578,31579,31580,31581,31582,31583,31584,31585,31586,31587,31588,31592,31608,31615
				,31616,31623,31625,31631,31635,31636,31642,31648,31650,31651,31663,31672,31673,31682,31684,31692,31714,31724;
			}
			if(a_boxqual == 2)
			{
				setarray $@a_boxarray[0]
				,31725,31726,31730,31740,31742,31747,31750,31754,31757,31758,31764,31765,31775,31780
				,31788,31789,31793,31799,31803,31811,31812,31813,31815,31816,31835,31836,31840,31842
				,31850,31858,31865,31879,31883,31890,31894,31900,31905,31908,31914,31933,31946,31952
				,31953,31969,31982,32004,32015,32021,32064,32066,32067,32071,32075,32079,32098,32099
				,32100,32154,32157,32160,32173,32177,32216,32222,32225,32244,32269,32277,32278,32279
				,32297,32310,32311,32322,32340,32355,32359,32367;
			}
			
			set $a_boxid, rand(getarraysize($@a_boxarray[0]));
			getitem $@a_boxarray[$a_boxid],1;
			announce strcharinfo(0) + " acabou de obter um(a) " + getitemname($@a_boxarray[$a_boxid]) + " na Caixa Especial de Visuais.", bc_all;
	}

You got this error.

image.png.11828fcb8a9d055a8f070dadf1f514de.png

I just put the '{' 

function	script	a_box_visu	{

 

Edited by Scanty
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  07/09/20
  • Last Seen:  

Thank you, @Scanty.

Now the script runs when i use the item.

Would you know why it's returning "null" for the item?

I couldn't understand why it doesn't work, because I use this same script in a NPC and it works.

image.png.171ec1fd39184b379afa3dc150680984.png

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   21
  • Joined:  11/08/15
  • Last Seen:  

2 hours ago, darkpatow said:

Thank you, @Scanty.

Now the script runs when i use the item.

Would you know why it's returning "null" for the item?

I couldn't understand why it doesn't work, because I use this same script in a NPC and it works.

image.png.171ec1fd39184b379afa3dc150680984.png

 

Sorry i didn't see this:

set aboxqual, rand(1,2);
			if (a_boxqual == 1)

this 'if (a_boxqual...)' -> aboxqual

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  07/09/20
  • Last Seen:  

@Scanty, it worked!

image.png.93425da12adaa471eca92868952e4f03.png

Thank you very much!

@edit: i should pay more attention to typos ??‍♂️

Edited by darkpatow
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...