Jump to content
  • 0
eKoh

I use a Function but OnSellItem does not work?

Question

I made a large script and I rather to save it as a function to not have a mess but it seems that OnSellItem is not working:

 

f0ddea.jpg

 

I tried to rename to Service::OnSellItem, and it also does not work lol.

 

And the problem is that OnSellItem does not work when it is called from a Function

if ( Any idea to make it work == 1 )set myself$,"happy =)";else set myself$,"sad D;";
Edited by eKoh

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

About player not attached, I gave you info on doevent and donpcevent, donpcevent DOES NOT TRANSFER RID, while doevent DOES. About why you're getting NPC not found error is because the label you want to trigger is inside function. Functions are treated differently from NPC, and as far as I know you shouln't be able to trigger labels in them with do(npc)event. What might work, however, is summoning label without NPC name, like this:

doevent "::OnTrigger";

I'll test that and tell you result.

 

EDIT: Even that doesn't work. Only way you can trigger label in function is by goto inside function itself. Otherwise you can only call said function from the beginning with callfunc.

 

As an alternative you can create another function with what's supposed to be under that label code, or add in an argument to function which will decide which label to trigger, and switch(getarg(0)), for example, at the start of function.

Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

It'a kind of hard to tell why without seeing the script itself. Common problem is that you either misspelled NPC name or gave NPC a unique name, yet still try to call it via normal name.

 

Example:

function	script	TestCall	{donpcevent "Tes::OnTrigger"; // <- Will errordonpcevent "Testing#01::OnTrigger"; // <- Will errordonpcevent "Test::OnTrigger"; // <- Should succeedreturn;}prontera,185,147,4	script	Testing#01::Test	837,{mes "Hello!";callfunc "TestCall";close;OnTrigger:emotion e_sob;return;}

 

ETA: It doesn't work as in not found like this? Or it doesn't work in some other way? (because depending on how you call label it will either have RID attached or not, and OnSellItem should have RID attached.)

 

*doevent "<NPC object name>::<event label>";This command will start a new execution thread in a specified NPC object at the specified label. The execution of the script running this command will not stop, and the event called by the 'doevent' command will not run until the invoking script has terminated. No parameters may be passed with a doevent call.The script of the NPC object invoked in this manner will run as if it's been invoked by the RID that was active in the script that issued a 'doevent'. As such, the command will not work if an RID is not attached.---------------------------------------*donpcevent "<NPC object name>::<event label>";This command invokes the event label code within an another NPC or NPCs. It starts a separate instance of execution, and the invoking NPC will resume execution its immediately.If the supplied event label has the form "NpcName::OnLabel", then only given NPC's event label will be invoked (much like 'goto' into another NPC). If the form is "::OnLabel" (NPC name omitted), the event code of all NPCs with given label will be invoked, one after another. In both cases the invoked script will run without an attached RID, whether or not the invoking script was attached to a player. The event label name is required to start with "On".This command can be used to make other NPCs act, as if they were responding to the invoking NPC's actions, such as using an emotion or talking.
Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

Thank you @Garr I will try it tomorrow, I hardly stand now haha

 

set myself$,"Happy =)";
Edited by eKoh

Share this post


Link to post
Share on other sites
  • 0

Hello @garr I am still here cuz I want my script work (#FeelLikeAZombie), and the sad thing it is not working ¬¬ but the good thing that the problem is that the player is not attached, just like this:

 

2w7jw35.jpg

 

The script I've been using is just like yours, but I made some changes to make it easier to see what the problem is:

function	script	TestCall	{mes "you here";next;donpcevent "Test::OnTrigger"; // <- Should succeedreturn;}-	script	Testing#01::Test	837,{mes "Hello!";callfunc "TestCall";close;OnTrigger:mes "you her22e";return;}prontera,154,182,5	duplicate(Test)	Test#1	117

 

But I wonder why is there a "close" button when I click on the npc then go to next... I think it is kind of working but things like " mes " instructions do not work :P!

 

30rtk5c.jpg

 

Edited by eKoh

Share this post


Link to post
Share on other sites
  • 0

By the way...

 

I was using this "donpcevent" instruction to make my script work, but it does not, and it shows this:

 

o0cx0h.jpg

 

The script1 (where the function is called):

 

		Case 4:		next;			cutin "kafra_01",255;			callfunc ("F_RestockSetup");			close2;			callshop "Restock",2;	                npcshopattach "Restock";OnSellItem:donpcevent "F_RestockSetup::OnTrigger";			end;

 

 

The script 2, where the function is written:

 

function	script	F_RestockSetup	{//blablabla instructions blablablaL_RestockShop:	next;	mes "You can set only a ^FF0000Maxinum of 20^000000 items each list!";	return;OnTrigger:	//for.... blablbabla}

I think I did nothing wrong but there is always a possibility~~

Edited by eKoh

Share this post


Link to post
Share on other sites
  • 0

 

Hello @garr I am still here cuz I want my script work (#FeelLikeAZombie), and the sad thing it is not working ¬¬ but the good thing that the problem is that the player is not attached, just like this:

 

2w7jw35.jpg

 

The script I've been using is just like yours, but I made some changes to make it easier to see what the problem is:

function	script	TestCall	{mes "you here";next;donpcevent "Test::OnTrigger"; // <- Should succeedreturn;}-	script	Testing#01::Test	837,{mes "Hello!";callfunc "TestCall";close;OnTrigger:mes "you her22e";return;}prontera,154,182,5	duplicate(Test)	Test#1	117

Share this post


Link to post
Share on other sites
  • 0

WOHOOO!!! IT IS ALIVE!!!

 

As an alternative you can create another function with what's supposed to be under that label code.

 

I've just made this and it works perfectly!!!

 

Script 1:

		Case 4:		next;			cutin "kafra_01",255;			callfunc ("F_RestockSetup"); //Calling 1st function			close2;			callshop "Restock",2;			npcshopattach "Restock";						OnSellItem:			callfunc ("F_RestockSetup2"); //Calling 2nd function			end;

 

Script 2:

L_RestockShop:	next;	mes "You can set only a ^FF0000Maxinum of 20^000000 items each list!";	return; //Going back to 1st script}	function	script	F_RestockSetup2	{ // Coming back to here	for //blablbablabl instructions~~~

 

The good thing, is that I had no other if ( ) { or for ( ) { between the  functions, if there was any, it couldn't work.

 

Thankz a lot man ;D!

Edited by eKoh

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.