itHyperoX Posted February 27, 2017 Share Posted February 27, 2017 Hi, i making a custom weapon name script, but i got some errors. I tried 4 hours to fix, but i dont know whats wrong. local WeaponNames = { [16] = "Nade", [24] = "One Deag" } function getWeaponRealName(weapon) if weapon then local weaponmodel = getWeaponNameFromID(weapon) if WeaponNames[weaponmodel] then return WeaponNames[weaponmodel] else return getWeaponIDFromName(weaponmodel) end end end Export: outputChatBox("#FFFFFF You picked up the ammo. #6F9F86(".. theAmmo ..") #ffffffCustomWeaponName: #6F9F86("..exports.serverFiles:getWeaponRealName(weaponID)..")",player,255,255,255,true) Pics And i'm gettint this on chat: You picked up the ammo. (20) CustomWeaponName: (0) Thanks any help Link to comment
pa3ck Posted February 27, 2017 Share Posted February 27, 2017 So your table keys are the weapon ID's, so what is this for? local weaponmodel = getWeaponNameFromID(weapon) Shouldn't it be if WeaponNames[weapon] then return WeaponNames[weapon] Link to comment
itHyperoX Posted February 27, 2017 Author Share Posted February 27, 2017 same error http://imgur.com/a/oPzad Link to comment
itHyperoX Posted February 27, 2017 Author Share Posted February 27, 2017 local WeaponNames = { [16] = "Nade", [24] = "One Deag" } function getWeaponRealName(weapon) if weapon then if WeaponNames[weapon] then return WeaponNames[weapon] else return getWeaponIDFromName(weaponmodel) end end end 208. line is the "else" Link to comment
pa3ck Posted February 27, 2017 Share Posted February 27, 2017 (edited) return getWeaponIDFromName(weaponmodel) Where is weaponmodel defined? Looks like you misunderstand that function. It gets the weaponID from the name, not the name from the ID. Use return getWeaponNameFromID(weapon) instead Edited February 27, 2017 by pa3ck Link to comment
Administrators Lpsd Posted February 27, 2017 Administrators Share Posted February 27, 2017 (edited) local WeaponNames = { [16] = "Nade", [24] = "One Deag" } function getWeaponRealName(weapon) if weapon then if WeaponNames[weapon] then return WeaponNames[weapon] else return getWeaponNameFromID(weapon) end end end Edited February 27, 2017 by LopSided_ Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now