dewu Posted October 9, 2014 Posted October 9, 2014 (edited) Hi guys. I have a problem with the use of "or" function, that's my code: if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then i tried every combinations, nothing works, help ;/ That's orginial function: if itemName == "Box of Matches" and getElementData(getLocalPlayer(), "Wood Pile") == 0 then How to add or? Edited October 9, 2014 by Guest
spoty Posted October 9, 2014 Posted October 9, 2014 did you tryed this if itemName == "Box of Matches" then getElementData(getLocalPlayer(), "Wood Pile") == 0 then return end or if itemName == "Box of Matches" then (getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then return end just a try
dewu Posted October 9, 2014 Author Posted October 9, 2014 It's not working. Also i tried: if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") == 0 or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then if itemName == "Box of Matches" and getElementData(getLocalPlayer(), "Wood Pile") == 0 or getElementData(getLocalPlayer(), "Wooden Sticks") == 0 then if itemName == "Box of Matches" and getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks") == 0 then if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks")) == 0 then
Moderators IIYAMA Posted October 9, 2014 Moderators Posted October 9, 2014 then something is wrong with your elementdata. This should work: (your code, not changed at all) if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") == 0 or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
dewu Posted October 10, 2014 Author Posted October 10, 2014 It's works if I have Wood Pile and Wooden Sticks in my inventory, then i can use Box of matches ;/ I want use Box of matches when I have Wood Pile or Wooden Sticks.
Moderators IIYAMA Posted October 10, 2014 Moderators Posted October 10, 2014 if itemName == "Box of Matches" -- if itemName is Box of Matches and ( -- start a new priority ( ( -- tonumber converts it to a number, tonumber(getElementData(localPlayer, "Wood Pile") ) or 0) > 0 or -- if not a number then it is 0 and check if it is higher then 0. ( -- same here tonumber(getElementData(localPlayer, "Wooden Sticks") ) or 0) > 0 ) -- end priority then Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted October 10, 2014 Moderators Posted October 10, 2014 debug it manually then. I can't help you if you aren't debugging your variables and elementdata. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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