Question about the restock script with admin scalpel

Users who are viewing this thread

Hello guys, i need add the restocking script to my scriptset, i tried some codes but they dont work, how can i add this script at module system? (Sorry for bad language)


The admin scalpel codes are here.
Code:
    (else_try),
      (eq, ":weapon_item_id", "itm_admin_scalpel"),
      (try_begin),
        (agent_get_troop_id, ":attacker_troop_id", ":attacker_agent_id"),
        (eq, ":attacker_troop_id", "trp_godlike_hero"),
        (agent_set_hit_points, ":attacked_agent_id", 100, 0),
        (assign, ":damage_result", 0),
        (call_script, "script_cf_clean_blood", ":attacked_agent_id"),
      (try_end),
 
Lorassy said:
Hello guys, i need add the restocking script to my scriptset, i tried some codes but they dont work, how can i add this script at module system? (Sorry for bad language)
Hitting a stockpile scene prop with a scalpel to replenish it is a poor way to implement that functionality, since those scene props are not set to be destructible or take damage, so would need to either be changed that way (and slow down the server due to combat calculations on the hit boxes - a major performance impact avoided in earlier releases by limiting those props and reducing the collision meshes to the simplest shapes possible), or another inefficient manual hit detection script written applying to admins, checking distances to stockpiles when they swing a weapon. It would be better performing and easier to modify one of the "use" triggers of stockpiles, for example, something like:

Find the script "cf_buy_sell_item_stockpile" (which is called by the ti_on_scene_prop_cancel_use trigger of stockpile scene props, to implement buying and selling items when tapping the "use" button), and insert after the first try_begin block a few checks: first that the ":weapon_item_id" is the admin scalpel item, then check that the ":player_id" is an admin, then for good measure you could check the player's slot_player_admin_no_all_items slot equals 0 (to work with the admin permissions feature of the name server, if you use it), and then add 10 (or any number) to ":stock_count"; and finally add an else_try operation to continue to the original first block that was after the try_begin, if any of the aforementioned added checks fail: so the script will continue on to try see if the original buy or sell functionality is appropriate. There is no need to actually set the new value of the ":stock_count" variable in the scene prop's slot_scene_prop_stock_count, since that is handled by a section at the end of the script, that also updates the displayed value to the using player.

Those changes would allow an admin to wield an Admin Scalpel item, then "tap use" at any weapon or armor stockpile to add 10 to the current stock count. This would not break any existing functionality, since there is no stockpile for admin scalpel items - they can only be spawned directly.

I didn't just type out the exact script addition for you to copy (even though that would be easier), since it is better for me in the long run that people learn how to make changes to scripts themselves.
 
Shmuel said:
I'm a little confused... Which file do I place the admin scalpel code in?


Here is my script for this that I developed a few weeks ago:


Add the following to module_constants.py:
Code:
admin_restock_amount                  = 5 # amount admin restocks pile by for each use


In module_scripts.py, replace the first "(try_begin)" line in the function "cf_buy_sell_item_stockpile" with the following:

Code:
(try_begin), # if the item is an admin scalpol
   (eq, ":weapon_item_id", "itm_admin_scalpel"),
   (player_is_admin, ":player_id"),
   (player_slot_eq, ":player_id", slot_player_admin_no_all_items, 0),
   (val_add, ":stock_count", admin_restock_amount),
   (str_store_item_name, s4, ":item_id"),
   (str_store_string, s3, "str_log_admin_restocked_s4"),
   (str_store_player_username, s0, ":player_id"),
   (player_get_unique_id, reg0, ":player_id"),
   (server_add_message_to_log, "str_log_admin_target_self"),
(else_try),# if the item is wielded or worn, try selling it# if the item is wielded or worn, try selling it


Finally, at the end of module_strings.py add:
Code:
("log_admin_restocked_s4", "restocked a stockpile of '{s4}'s"),


To use ingame, tap F on a buy point with the admin scalpel to increase stock count by 5.


Note, this was only built and tested as part of a different module based on PW. I believe in theory it should work, however, you may experience odd behaviours that you may need to resolve.
 
Thanks for the quick reply

I believe I can't access these files as the provider installed scripts for me and I looked everywhere using FTP
I see cf_buy_sell_item_stockpile in scripts.txt but then it's all just numbers after that line

Where specifically would I find these .py files?

Thanks
 
Shmuel said:
Thanks for the quick reply

I believe I can't access these files as the provider installed scripts for me and I looked everywhere using FTP
I see cf_buy_sell_item_stockpile in scripts.txt but then it's all just numbers after that line

Where specifically would I find these .py files?

Thanks


Sorry, I didn't realise you were a complete novice.


You will need to make changes in the PW module system source files that are found on Github: https://github.com/vornne/pw_module_system If you have custom scripts make sure you get their source code and work from there.


Once you make the changes, you will need Python to rebuild the module. This will produce the .txt files, such as scripts.txt, which you will then need to upload to your server via the FTP.


There are various guides on the forums that will help you with this. If you struggle to find one, say and I maybe able to find one or I can explain you through the process on Teamspeak or Steam if you'd like.
 
Back
Top Bottom