• Getting a Entitiys Class name
    3 replies, posted
Its a simple question which can probably be answered with one gmod wiki link. I have this Serverside code for the network util.AddNetworkString("AssistantPlayerCanPickupItem") hook.Add("PlayerCanPickupItem", "PlayerCanPickupItem", function(ply , ent)     net.Start("AssistantPlayerCanPickupItem")     net.WriteEntity(ent)     net.Send(ply) end) and this clientside code thats supposed to execute code when the entitie is a specific entity. net.Receive("AssistantPlayerCanPickupItem", function()     local PickedEntity = net.ReadEntity()     print(PickedEntity:GetClass())     if PickedEntity == "item_healthkit" or "item_healthvial" then         --execute code     end end) The Entity is, as you can see, supposed to be the big healthkit or the little healthvial. When i print out PickedEntity without any other functions on it it prints [NULL] Entity. What class/function do i need to use on it to get the entity name to check it in the if statement? I tryd GetClass() which made a error, GetName() made a nil value too. I checked it in the print() only to see in the console if it even returns the right thing. Since i cant really see what the return is in the if statement.
If I had to guess it's NULL because you're picking it up thus deleting the entity. When you don't pick it up the entity is still there and as such it's not NULL. Assuming you only want to know whether it's either of those classes and nothing else, just network if it's one of them, don't network the entity.
Why dont you just get the class serverside and network the class string over.
did it even better now. I edited the OP with the fix
Sorry, you need to Log In to post a reply to this thread.