Kafra with storage + gstorage

iskoy.flores

New member
Messages
21
Points
0
Github
iskoy.flores
I'm trying to make a kafra with both storage and gstorage options, but I can't seem to get it yet since I'm still new and still haven't been able to fully understand how scripting works - I'm trying the wiki but I'm still very clouded... To anyone kind enough please help!

Below is my script
 

// Prontera
//============================================================
prontera,151,187,3 script Kafra Employee::kaf_prontera 4_F_KAFRA6,{
cutin "kafra_06",2;
callfunc "F_KafSet";
mes "[Kafra Employee]";
mes "Welcome to the";
mes "Kafra Corporation~";
mes "The Kafra Services are";
mes "always here to support";
mes "you. So how can I be";
mes "of service today?";
callfunc "F_Kafra",5,0,0,40,800;
callfunc "guildopenstorage",5,0,0,40,800;
savepoint "prontera",156,182;
callfunc "F_KafEnd",0,1,"in the city of Prontera";
}
 
 
Find functions_kafras.txt in /npc/kafras/, find this part of code under function F_Kafra:

switch(getarg(1)){ // Save and Storage only case 1: setarray @K_Menu0$[0],"Save","Use Storage","Cancel"; break; // Storage only case 2: setarray @K_Menu0$[0],"Use Storage","Cancel"; break; // No Teleport (Common) case 3: setarray @K_Menu0$[0],"Save","Use Storage","Rent a Pushcart","Check Other Information","Cancel"; break; // Case 4 is Einbroch no tele message. // No save, or teleport. (Common) case 5: setarray @K_Menu0$[0],"Use Storage","Rent a Pushcart","Check Other Information","Cancel"; break; // Storage and Check Other Information only. case 6: setarray @K_Menu0$[0],"Use Storage","Check Other Information","Cancel"; break; // Save, Storage, and Pushcart only (Kafra Warehouse) case 7: setarray @K_Menu0$[0],"Save","Use Storage","Rent a Pushcart","Cancel"; break; // Save, Storage, Other Check information. (Turbo track) case 8: setarray @K_Menu0$[0],"Save","Use Storage","Check Other Information","Cancel"; break; // No Save (Rune Knight) case 9: setarray @K_Menu0$[0],"Use Storage","Rent a Pushcart","Use Teleport Service","Check Other Information","Cancel"; break; // Storage, Save, and Pushcart (Dewata, reorder of case 7) case 10: setarray @K_Menu0$[0],"Use Storage","Save","Rent a Pushcart","Cancel"; break; // Default message (obsolete) default: setarray @K_Menu0$[0],"Save","Use Storage","Use Teleport Service","Rent a Pushcart","Check Other Information","Cancel"; break; }
Add in an option for desired Kafras, basic change would be to add "Use Guild Storage" after "Use Storage" under default:

It'll end up like this:

// Default message (obsolete)default: setarray @K_Menu0$[0],"Save","Use Storage","Use Guild Storage","Use Teleport Service","Rent a Pushcart","Check Other Information","Cancel"; break;

You can add in that for every kafra kind you need, for which Kafra calls which kind check function call from kafra script itself:

callfunc "F_Kafra",5,0,1,20,600;
2nd number shows which case will be called (if there's no such number, default is called, so in this examle "default" case is called).

 
Last edited by a moderator:
Wow thank you very much sir! I wouldn't have been able to figure that out for myself. Many thanks and God bless!

By the way sir, if it isn't asking too much, could you point me into the right direction on where to start leaning scripts? There seems to be a lot of sources and I find them quite overwhelming.

For starters, I'd like to learn more about these kinds: callfunc "F_Kafra",5,0,1,20,600;

What does each value mean and where can I read about them?

Thanks again! ^^

 
Last edited by a moderator:
To be honest, I learned most of the things just from reading documentation /swt

Easiest way to find out is open /doc/script_commands.txt and find the command there. That's the best method, or you can use this site, but It's not up-to-date with Hercules commands and works better if you're looking for some particular basic command.

callfunc "F_Kafra",5,0,1,20,600;
All the following numbers are arguments, which are used within function itself to determine the outcome, they are fetched from within function via getarg(N) command. Their indexes start from 0 and go on forward, like getarg(0) will return 5, and getarg(3) will return 20.

According to function itself, here's what arguments are used for:

First argument: index - 0, value - 5, determines what kind of message Kafra will display before calling menu;

Second argument: index - 1, value - 0, determines what menu Kafra will call out;

Third argument: index - 2, value - 1, passed on to F_KafInfo function, determines Information provided when menu option "Check Other Information" is selected;

Fourth argument: index - 3, value - 20, passed on to F_KafStor function, determines cost of opening storage;

Fifth argument: index - 4, value - 600, passed on to F_KafCart function, determines cost of renting a cart.

When you want to find out what each number means for each function call, open said function script and check out where getarg(N) is called.

 
Thanks for the enlightenment sir. Scripting sure seems hard. But I guess there's no easy way around it except the manual. I'll try to learn from your example. Thanks again!

 
Back
Top