SphereCommunity
Transfer Function - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Transfer Function (/Thread-Transfer-Function)



Transfer Function - Llirik - 11-25-2016 09:14 PM

I need transfer all items from my backpack (GM) to target (bank) char (Player)!
This is right script?

[FUNCTION legend_transfer]
targetf f_legend_transfer

[FUNCTION f_legend_transfer]
serv.newitem i_bag, 1, <argo.findlayer.29.uid>
local.newbag = <new.uid>
forcont <findlayer.21>
serv.newitem <baseid>, <amount>, <local.newbag>
endfor

Happy New Year!


RE: Transfer Function - Kanibal - 11-25-2016 10:18 PM

Code:
[FUNCTION f_backpack_to_bank]
findlayer(21).cont = <argo.findlayer(29).uid>
newitem=i_backpack
new.equip

(11-25-2016 09:14 PM)Llirik Wrote:  Happy New Year!
Lol

And if someone needs to move all items from char to his/her bank
Code:
[FUNCTION f_all_to_bank]
findlayer(1).cont = <findlayer(21).uid>
findlayer(2).cont = <findlayer(21).uid>
findlayer(3).cont = <findlayer(21).uid>
findlayer(4).cont = <findlayer(21).uid>
findlayer(5).cont = <findlayer(21).uid>
findlayer(6).cont = <findlayer(21).uid>
findlayer(7).cont = <findlayer(21).uid>
findlayer(8).cont = <findlayer(21).uid>
findlayer(9).cont = <findlayer(21).uid>
findlayer(10).cont = <findlayer(21).uid>
findlayer(12).cont = <findlayer(21).uid>
findlayer(13).cont = <findlayer(21).uid>
findlayer(14).cont = <findlayer(21).uid>
findlayer(17).cont = <findlayer(21).uid>
findlayer(18).cont = <findlayer(21).uid>
findlayer(19).cont = <findlayer(21).uid>
findlayer(20).cont = <findlayer(21).uid>
findlayer(22).cont = <findlayer(21).uid>
findlayer(23).cont = <findlayer(21).uid>
findlayer(24).cont = <findlayer(21).uid>
findlayer(31).cont = <findlayer(21).uid>
findlayer(21).cont = <findlayer(29).uid>
newitem=i_backpack
new.equip



RE: Transfer Function - Coruja - 11-26-2016 01:58 AM

if you want to move all backpack content to another packpack you must use CONT (which just change the item cont = move the item to another container) instead NEWITEM (which will create a new item)

also keep in mind that FINDLAYER always loop through all items equipped on player and only stop when it find the item on the layer X, so it's not a good idea use FINDLAYER inside FOR* loops, this will create a heavy loop and will waste server performance for no reason. To avoid this you can store the backpack UID just once (using REF1) before FORCONT starts. This will make FORCONT run moving the item directly to this backpack UID already defined (REF1) instead try to find the backpack UID again at each loop

Code:
[FUNCTION legend_transfer]
TARGETF f_legend_transfer

[FUNCTION f_legend_transfer]
REF1=<ARGO.FINDLAYER.layer_pack>
FORCONT <FINDLAYER.layer_pack>
  CONT=<REF1>
ENDFOR



RE: Transfer Function - Kanibal - 11-26-2016 03:19 AM

This will be much better
Code:
[FUNCTION legend_transfer]
targetf f_legend_transfer

[FUNCTION f_legend_transfer]
serv.newitem i_bag
new.name <argo.name> loot
ref1=<new.uid>
forcont <argo.findlayer.layer_pack>
  cont=<ref1>
endfor
ref1.cont=<findlayer.layer_pack>
argo.kill
argo.sysmesage Ahahahahahaah!

[PLEVEL 1]
legend_transfer