Slimwaffle Posted July 1, 2018 Share Posted July 1, 2018 I was wondering how I would go about getting weapon name to print to screen? I checked all the code and can't find a reference to name anywhere. The closest I found was weapon file. Which prints the weapon file path to screen but does not change when swapping weapons. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 1, 2018 Share Posted July 1, 2018 Is the weapon a prefab or a model? Asking because sometimes this doesn't work for prefab parent meshes - only the child mesh. On models, it appears to work all the time. Anyways, this is how you get the name like as shown in the editor when placed in a scene: entity:GetKeyValue("Name") Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Slimwaffle Posted July 1, 2018 Author Share Posted July 1, 2018 At the moment its just the default weapon autopistol and the ones from the fps pack. I want to print to screen above my ammo the name of the weapon currently being held So yeah mostly prefabs Quote Link to comment Share on other sites More sharing options...
Slimwaffle Posted July 1, 2018 Author Share Posted July 1, 2018 This is what I came up with that compiles without error. But its not printing a name value to screen. wep = self.weapons[self.currentweaponindex].entity:GetKeyValue("Name") context:SetBlendMode(1) context:SetColor(0,1,1,255) context:DrawText("Weapon = " ..wep , 20,(context:GetHeight() - 80)) Quote Link to comment Share on other sites More sharing options...
Slimwaffle Posted July 1, 2018 Author Share Posted July 1, 2018 I searched everywhere. There is no reference to name. I think I am going to have to add something in myself. I think maybe along the lines of on weapon pick up if weapon file is = "path to mp4.pfb" then name of next index = "mp4" Not sure if that will work. Seems a bit tedious. Would saving all the file paths (For each item) and the equivalent name (for each item) to a table and then search matching string in table and returning name value work better? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.