Limestone Posted July 8, 2016 Group: Members Topic Count: 155 Topics Per Day: 0.03 Content Count: 647 Reputation: 16 Joined: 11/21/11 Last Seen: December 28, 2022 Share Posted July 8, 2016 Hi! is it possible to execute a script in src? for example, i replace Cash shop's code, if i click the cash shop instead of showing its interface, a menu will show? Thank you! Quote Link to comment Share on other sites More sharing options...
0 Kurofly Posted July 8, 2016 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 283 Reputation: 31 Joined: 07/08/14 Last Seen: January 15, 2022 Share Posted July 8, 2016 (edited) You could add an event label and then call it when opening the shop. Let's say you want to create a label named 'OnCashShopOpening' (yeah should think about something else ^^) src/map/npc.c : void npc_read_event_script(void) { int i; struct { char *name; const char *event_name; } config[] = { {"Login Event",script_config.login_event_name}, {"Logout Event",script_config.logout_event_name}, {"Load Map Event",script_config.loadmap_event_name}, {"Base LV Up Event",script_config.baselvup_event_name}, {"Job LV Up Event",script_config.joblvup_event_name}, {"Die Event",script_config.die_event_name}, {"Kill PC Event",script_config.kill_pc_event_name}, {"Kill NPC Event",script_config.kill_mob_event_name}, {"Stat Calc Event",script_config.stat_calc_event_name}, ++ {"Cash Shop Event",script_config.cash_shop_event_name}, }; src/map/npc.h : //Script NPC events. enum npce_event { NPCE_LOGIN, NPCE_LOGOUT, NPCE_LOADMAP, NPCE_BASELVUP, NPCE_JOBLVUP, NPCE_DIE, NPCE_KILLPC, NPCE_KILLNPC, NPCE_STATCALC, ++ NPCE_CASHSHOP, NPCE_MAX }; src/map/script.c : struct Script_Config script_config = { 1, // warn_func_mismatch_argtypes 1, 65535, 2048, //warn_func_mismatch_paramnum/check_cmdcount/check_gotocount 0, INT_MAX, // input_min_value/input_max_value "OnPCDieEvent", //die_event_name "OnPCKillEvent", //kill_pc_event_name "OnNPCKillEvent", //kill_mob_event_name "OnPCLoginEvent", //login_event_name "OnPCLogoutEvent", //logout_event_name "OnPCLoadMapEvent", //loadmap_event_name "OnPCBaseLvUpEvent", //baselvup_event_name "OnPCJobLvUpEvent", //joblvup_event_name "OnPCStatCalcEvent", //stat_calc_event_name "OnTouch_", //ontouch_name (runs on first visible char to enter area, picks another char if the first char leaves) "OnTouch", //ontouch2_name (run whenever a char walks into the OnTouch area) ++ "OnCashShopOpening", }; src/map/script.h : extern struct Script_Config { unsigned warn_func_mismatch_argtypes : 1; unsigned warn_func_mismatch_paramnum : 1; int check_cmdcount; int check_gotocount; int input_min_value; int input_max_value; const char *die_event_name; const char *kill_pc_event_name; const char *kill_mob_event_name; const char *login_event_name; const char *logout_event_name; const char *loadmap_event_name; const char *baselvup_event_name; const char *joblvup_event_name; const char *stat_calc_event_name; const char* ontouch_name; const char* ontouch2_name; ++ const char* cash_shop_event_name; } script_config; src/map/clif.c void clif_parse_cashshop_open_request( int fd, struct map_session_data* sd ){ sd->npc_shopid = -1; // Set npc_shopid when using cash shop from "cash shop" button [Aelys|Susu] bugreport:96 clif_cashshop_open( sd ); ++ npc_script_event(sd, NPCE_CASHSHOP); } In any npc: - script dubnpc -1,{ OnCashShopOpening: debugmes "it works!!"; end; } Tested and working I don't know if there's a way to call a specific npc event or even to call a script function, sorry but I don't know much about src at all so that's all I've got. Edited July 9, 2016 by Kurofly 1 Quote Link to comment Share on other sites More sharing options...
0 REKT Posted July 9, 2016 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 206 Reputation: 11 Joined: 12/06/11 Last Seen: September 13, 2024 Share Posted July 9, 2016 You could add an event label and then call it when opening the shop. I know how to create a label but I have no idea where you could put the call ^^ Let's say you want to create a label named 'OnCashShopOpening' (yeah should think about something else ^^) src/map/npc.c : void npc_read_event_script(void) { int i; struct { char *name; const char *event_name; } config[] = { {"Login Event",script_config.login_event_name}, {"Logout Event",script_config.logout_event_name}, {"Load Map Event",script_config.loadmap_event_name}, {"Base LV Up Event",script_config.baselvup_event_name}, {"Job LV Up Event",script_config.joblvup_event_name}, {"Die Event",script_config.die_event_name}, {"Kill PC Event",script_config.kill_pc_event_name}, {"Kill NPC Event",script_config.kill_mob_event_name}, {"Stat Calc Event",script_config.stat_calc_event_name}, ++ {"Cash Shop Event",script_config.cash_shop_event_name}, }; src/map/npc.h : //Script NPC events. enum npce_event { NPCE_LOGIN, NPCE_LOGOUT, NPCE_LOADMAP, NPCE_BASELVUP, NPCE_JOBLVUP, NPCE_DIE, NPCE_KILLPC, NPCE_KILLNPC, NPCE_STATCALC, ++ NPCE_CASHSHOP, NPCE_MAX }; src/map/script.c : struct Script_Config script_config = { 1, // warn_func_mismatch_argtypes 1, 65535, 2048, //warn_func_mismatch_paramnum/check_cmdcount/check_gotocount 0, INT_MAX, // input_min_value/input_max_value "OnPCDieEvent", //die_event_name "OnPCKillEvent", //kill_pc_event_name "OnNPCKillEvent", //kill_mob_event_name "OnPCLoginEvent", //login_event_name "OnPCLogoutEvent", //logout_event_name "OnPCLoadMapEvent", //loadmap_event_name "OnPCBaseLvUpEvent", //baselvup_event_name "OnPCJobLvUpEvent", //joblvup_event_name "OnPCStatCalcEvent", //stat_calc_event_name "OnTouch_", //ontouch_name (runs on first visible char to enter area, picks another char if the first char leaves) "OnTouch", //ontouch2_name (run whenever a char walks into the OnTouch area) ++ "OnCashShopOpening", }; src/map/script.h : extern struct Script_Config { unsigned warn_func_mismatch_argtypes : 1; unsigned warn_func_mismatch_paramnum : 1; int check_cmdcount; int check_gotocount; int input_min_value; int input_max_value; const char *die_event_name; const char *kill_pc_event_name; const char *kill_mob_event_name; const char *login_event_name; const char *logout_event_name; const char *loadmap_event_name; const char *baselvup_event_name; const char *joblvup_event_name; const char *stat_calc_event_name; const char* ontouch_name; const char* ontouch2_name; ++ const char* cash_shop_event_name; } script_config; Then you can call for that label using 'npc_script_event(sd, NPCE_CASHSHOP);' I don't know if there's a way to call a specific npc event or even to call a script function, sorry but I don't know much about src at all so that's all I've got. The real matter here is where are you gonna put that command? I quickly checked the cash shop source and I don't have a clue, guess you'll have to try it out ^^ Good luck ~~ I was wondering how does it work via script? can anyone give an example? Quote Link to comment Share on other sites More sharing options...
0 Technoken Posted July 9, 2016 Group: Members Topic Count: 27 Topics Per Day: 0.01 Content Count: 505 Reputation: 127 Joined: 04/04/16 Last Seen: Sunday at 02:20 PM Share Posted July 9, 2016 Maybe you can do it like this? prontera,180,140,4 script Cash Shop 73,{ switch( select("Shop 1:Shop 2:Shop 3")){ case 1: callshop "shop1",1; break; case 2: callshop "shop2",1; break; case 3: callshop "shop3",1; break; } end; } - pointshop shop1 -1,#CASHPOINTS,678:5,607:5,608:1 - pointshop shop2 -1,#CASHPOINTS,678:5,607:5,608:1 - pointshop shop3 -1,#CASHPOINTS,678:5,607:5,608:1 Quote Link to comment Share on other sites More sharing options...
0 Kurofly Posted July 9, 2016 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 283 Reputation: 31 Joined: 07/08/14 Last Seen: January 15, 2022 Share Posted July 9, 2016 (edited) Ok I got it! src/map/clif.c void clif_parse_cashshop_open_request( int fd, struct map_session_data* sd ){ sd->npc_shopid = -1; // Set npc_shopid when using cash shop from "cash shop" button [Aelys|Susu] bugreport:96 clif_cashshop_open( sd ); ++ npc_script_event(sd, NPCE_CASHSHOP); } In any npc: - script dubnpc -1,{ OnCashShopOpening: debugmes "it works!!"; end; } Tested and working I edited my first post too so that everything's in one post Edited July 9, 2016 by Kurofly Quote Link to comment Share on other sites More sharing options...
0 REKT Posted July 9, 2016 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 206 Reputation: 11 Joined: 12/06/11 Last Seen: September 13, 2024 Share Posted July 9, 2016 Ok I got it! src/map/clif.c void clif_parse_cashshop_open_request( int fd, struct map_session_data* sd ){ sd->npc_shopid = -1; // Set npc_shopid when using cash shop from "cash shop" button [Aelys|Susu] bugreport:96 clif_cashshop_open( sd ); ++ npc_script_event(sd, NPCE_CASHSHOP); } In any npc: - script dubnpc -1,{ OnCashShopOpening: debugmes "it works!!"; end; } Tested and working I edited my first post too so that everything's in one post This what i want pretty neat! i have an idea for this thank you again Kuro Quote Link to comment Share on other sites More sharing options...
Question
Limestone
Hi! is it possible to execute a script in src? for example, i replace Cash shop's code, if i click the cash shop instead of showing its interface, a menu will show? Thank you!
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.