TrickyTommy Posted August 16, 2017 Posted August 16, 2017 Hi. The script should draw an image of my current weapon if i don't hold weapon id 44 or 45, but it is not doing so. -- weap icon local weaponName = getPedWeapon(localPlayer) outputDebugString (weaponName) if tostring(weaponName) == not "44" and tostring(weaponName) == not "45" then local WeaponIcon = dxDrawImage (1360/dX*jX, 70/dY*jY, 200/dX*jX, 100/dY*jY, "assets/images/weapons/"..tonumber(fegyverid)..".png") else outputDebugString ("else") end "else" is being displayed, whether i hold weapon id 44, 45 or not.
MTA Team Lpsd Posted August 16, 2017 MTA Team Posted August 16, 2017 -- weap icon local weaponName = getPedWeapon(localPlayer) outputDebugString (weaponName) if tostring(weaponName) == "44" or tostring(weaponName) == "45" then local WeaponIcon = dxDrawImage (1360/dX*jX, 70/dY*jY, 200/dX*jX, 100/dY*jY, "assets/images/weapons/"..tonumber(fegyverid)..".png") else outputDebugString ("else") end This would be a better way to do it. However, if you want to check if something isn't true, you do it like so: if not a == 1 then --a is not 1 else --a is 1 end You were doing it like this: if a == not 1 then --a is equal to false 1 (?) else --will always return else due to incorrect if statement end
TrickyTommy Posted August 16, 2017 Author Posted August 16, 2017 (edited) yeah, i just noticed it. still not working.... local weaponID = getPedWeapon(localPlayer) outputDebugString (weaponID) if not weaponID == 44 and not weaponID == 45 then local WeaponIcon = dxDrawImage (1360/dX*jX, 70/dY*jY, 200/dX*jX, 100/dY*jY, "assets/images/weapons/"..tonumber(weaponID)..".png") else outputDebugString ("else") end at least this way weapons get drawn: local weaponID = getPedWeapon(localPlayer) outputDebugString (weaponID) local NotExist = {["44"] = true, ["45"] = true} if not NotExist[weaponID] then WeaponIcon = dxDrawImage (1360/dX*jX, 70/dY*jY, 200/dX*jX, 100/dY*jY, "assets/images/weapons/"..tonumber(weaponID)..".png") else outputDebugString ("else") end but yet it is attempting to draw on 44 and 45 Edited August 16, 2017 by TrickyTommy
MTA Team Lpsd Posted August 16, 2017 MTA Team Posted August 16, 2017 (edited) You're still doing it wrong, try like this and it should work local weaponID = getPedWeapon(localPlayer) outputDebugString (weaponID) if weaponID == 44 or weaponID == 45 then local WeaponIcon = dxDrawImage (1360/dX*jX, 70/dY*jY, 200/dX*jX, 100/dY*jY, "assets/images/weapons/"..tonumber(weaponID)..".png") else outputDebugString ("else") end You want to check if the current weapon ID is X or Y You are currently trying to check if the currently weapon ID is not X and Y, which will never be true because a variable can't be two different values at the same time Edited August 16, 2017 by LopSided_
TrickyTommy Posted August 16, 2017 Author Posted August 16, 2017 yes. because i don't want to get the weapon's picture on the screen. i have not found a good image for it yet.
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