Clipper_ Posted December 23, 2014 Share Posted December 23, 2014 Hello Guys! I wanna get the current weapon name of player and to draw it on my hud local weapon = getPedWeapon (getLocalPlayer()) local weaponID = getWeaponNameFromID (getLocalPlayer(), weapon) dxDrawText("Weapon: "..weaponID..".", (0.585)*sWidth, (0.087)*sHeight, (0.293)*sWidth, (0.263)*sHeight, tocolor (64, 64, 64, 255),1.4,"pricedown","left","top",false,false,false,true) only with line 1, it shows me the ID. then tried to convert the ID in Name by following function from line 2. TY Link to comment
Eth Posted December 23, 2014 Share Posted December 23, 2014 try that: local weapon = getPedWeapon (getLocalPlayer()) local weaponID = getWeaponNameFromID (weapon) dxDrawText("Weapon: "..weaponID..".", (0.585)*sWidth, (0.087)*sHeight, (0.293)*sWidth, (0.263)*sHeight, tocolor (64, 64, 64, 255),1.4,"pricedown","left","top",false,false,false,true) Link to comment
Clipper_ Posted December 23, 2014 Author Share Posted December 23, 2014 Worked. Thank you! > Link to comment
Clipper_ Posted December 25, 2014 Author Share Posted December 25, 2014 i tried this to custom weapon names local weaponlist = { [ 31 ] = "M4A1", } local weaponID = getWeaponNameFromID (weaponlist) it is good? Link to comment
manve1 Posted December 25, 2014 Share Posted December 25, 2014 i tried this to custom weapon names local weaponlist = { [ 31 ] = "M4A1", } local weaponID = getWeaponNameFromID (weaponlist) it is good? You are trying to get an integer from a table without unpacking it or using a for loop. I suggest you look into these articles: For loop Lua unpack Link to comment
John Smith Posted December 25, 2014 Share Posted December 25, 2014 Or you can use it like this weaponList[getWeaponNameFromID(id)] To retrieve weapon name, but you would have to define id to make it work 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