• How to find entity variable from name/filename?
    3 replies, posted
I want to get the entity variable from a descriptive name/identification. Specifically, this is being used to check if someone is holding a specific weapon entity, e.g., a specific gun or something. I am comparing this to something else, trying to decide whether or not the weapon in the player's inventory is the same one as the weapon I want them to have. The only way I have found how to do this is through either "WEAPON:GetPrintName()", or "ents.FindByName( string nameOfEntity )". "WEAPON:GetPrintName()" only works clientside, which doesn't work for my specific situation, as this is being handled entirely serverside and I'd like to keep it that way. I called this on the weapon entity I found in the player's inventory and compared it to the print name of the weapon I want them to have. "ents.FindByName( string nameOfEntity )" returned an empty table, but that could be because I don't know what I should put as the argument. I simply put the filename without extension in as the argument. I called this, trying to get the entity variable of the weapon I want the player to have, comparing it with what I find in their inventory. Since this is serverside, I thought it may be possible to just do something like this. [CODE] --"wep" is the weapon entity i found in player's inventory if wep.ID == "name of weapon I want them to have" then --whatever end [/CODE] Except this would require me to alter code inside of the weapon I want them to have, introducing a variable called 'ID' into it. Heck, I don't even know if I can access variables like that either, unless I'm inside of the weapon entity. Help?
Bump - I don't know what I'm doing. Literally any comment could help.
wep:GetClass()
[QUOTE=TheTechPony;49815071]wep:GetClass()[/QUOTE] Good lord, that's not an intuitive name for what it is doing.
Sorry, you need to Log In to post a reply to this thread.