I use a Function but OnSellItem does not work?

eKoh

New member
Messages
75
Points
0
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

Code:
if ( Any idea to make it work == 1 )set myself$,"happy =)";else set myself$,"sad D;";
 
Last edited by a moderator:
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.)

Code:
*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.
 
Last edited by a moderator:
Thank you @Garr I will try it tomorrow, I hardly stand now haha

Code:
set myself$,"Happy =)";
 
Last edited by a moderator:
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
default_tongue.png
!

30rtk5c.jpg


 
Last edited by a moderator:
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~~

 
Last edited by a moderator:
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:

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

 
Last edited by a moderator:
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!

 
Last edited by a moderator:
Back
Top