Jump to content

Recommended Posts

My friend and I used a mod, I gave him an item from the mod but even if he got the mod activated , he can't see the item, he can't use it but it still there and he got problem with the slot the item is in. So is there a command I can use to remove an Item from his slot?

 

Thanks for future reply!

Link to comment
https://forums.kleientertainment.com/forums/topic/49378-console-command/
Share on other sites

@Gekido2802, in your custom item make sure you have inst.entity:AddNetwork() otherwise it won't show up on the clients side properly. 

Well thanks for the info ^^ but my question was more if there was a command I could enter into the command console to remove an item from someone slot? 

@Gekido2802, you can try the following in the console.

 

for _,v in ipairs(AllPlayers) do v.components.inventory:RemoveItem("PREFAB NAME HERE") end

 

This will remove all the items of that prefab's name from all players. Alternatively you could simply disable the mod.

@rezecib, or it's missing entirely. It seems that the tutorials new modders are using does not have that in them. 

 

You're right I don't have it cuase I didn't find any tutorial with that :/

 

Where do I put the

 

if not TheWorld.ismastersim then

    return inst

end 

 

and what does it do?

 

Thanks for future reply! ^^

@Gekido2802, Well, whenever you're making anything for a mod, you should always start by copying over the most similar thing from the game's files. So if you're making an equippable item, start by copying over spear.lua or something. That way you don't have to worry so much about missing crucial stuff like if not TheWorld.ismastersim.

 

Edit: I talked about this approach in my guide, which is pinned at the top of this subforum. But I'm editing it right now to make sure it's clearer and I cover the new things in prefabs specifically.

Edited by rezecib

Thanks guys.

 

I fixed the problem adding :

 

inst.entity:AddNetwork()

 

if not TheWorld.ismastersim then

    return inst

end

 

and some other things that was in the game files but not in mine  :indecisiveness:

 

@rezecib, your tutorial is very well explained , it helped me a lots. Thanks

 

@Kzisor, for the command to remove an item from a player slot I used :

 

for k,v in ipairs(AllPlayers) do

    if v.name == "PLAYER NAME HERE" then 

        v.components.inventory:RemoveItemBySlot("SLOT NUMBER HERE") 

    end

end

 

Thanks a lot for the help!  :joyous: 

Edited by Gekido2802

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...