OnItemClick???

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
613
63
Hi all! Does anyone know any way to take the item in which the inventory is clicked? Or you should make a hook for this type OnItemClick?? greetings
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
613
63
Server on client side?
I imagine on the side of the server ... to know which item the player clicks on and thus be able to play with the inventory of the players or create a new way to use loot faster
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,096
4,836
113
At your house.
github.com
I imagine on the side of the server ... to know which item the player clicks on and thus be able to play with the inventory of the players or create a new way to use loot faster
Server side I think doesn't recieve any sort of click events just move events.
I may try to look for client event.
I also want to add hurt and such events on the client.
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
613
63
That would be great, doing it on the server side would be perfect ... I imagine
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
613
63
I am almost 100% sure that the item click is not going to the server, since it would flood the network connection.
And would there be any way to move items from a chest to inventory on the client's side?
 

MeshBenth

☒Rustʕ•ᴥ•ʔRedux☒
Member
Oct 5, 2017
48
47
8
Parts Unknown
And would there be any way to move items from a chest to inventory on the client's side?
C#:
var boxInvId = NetEntityID.Get(Get());
var inventory = NetEntityID.Get(PlayerClient.GetLocalPlayer().rootControllable.gameObject);
for (var i = 0; i <= 30; i++) {
    Inventory.ItemMovePredicted(inventory, boxInvId, i, i);
}
C#:
public static LootableObject Get() {
    var lootableObJs = UnityEngine.Object.FindObjectsOfType < LootableObject > ();
    return lootableObJs.FirstOrDefault(lootableObJ => lootableObJ.IsLocalLooting());
}
EZz :p:p
 
  • Like
Reactions: salva

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,096
4,836
113
At your house.
github.com
C#:
var boxInvId = NetEntityID.Get(Get());
var inventory = NetEntityID.Get(PlayerClient.GetLocalPlayer().rootControllable.gameObject);
for (var i = 0; i <= 30; i++) {
    Inventory.ItemMovePredicted(inventory, boxInvId, i, i);
}
C#:
public static LootableObject Get() {
    var lootableObJs = UnityEngine.Object.FindObjectsOfType < LootableObject > ();
    return lootableObJs.FirstOrDefault(lootableObJ => lootableObJ.IsLocalLooting());
}
EZz :p:p
That seems like a client side method that loops through all of the lootableobjects and checks if you are looting any.


And would there be any way to move items from a chest to inventory on the client's side?
That would require to call something on the server. What are you trying to achive with the click event?
 

MeshBenth

☒Rustʕ•ᴥ•ʔRedux☒
Member
Oct 5, 2017
48
47
8
Parts Unknown
That seems like a client side method that loops through all of the lootableobjects and checks if you are looting any.



That would require to call something on the server. What are you trying to achive with the click event?
This code gets all things from 0 to 30 slot in the inventory and transfers them to the active box - this is a draft worker
 

daironcuba

New Member
Member
Sep 24, 2021
2
0
1
cuba
Hello everyone, could you give me the source code, I want to do the same, move the items with a simple click, could you help me?