lucasds Posted May 29, 2019 Share Posted May 29, 2019 (edited) function collectLeite(thePlayer) if getElementType(thePlayer) == "player" then if getElementData(thePlayer,"MilkBuckets") <= 10 then setElementData(thePlayer,"MilkBuckets", (getElementData(thePlayer,"MilkBuckets")) + 1) outputChatBox("#727272You have collected #ffff00 " ..(getElementData(thePlayer,"MilkBuckets")).. "/10 Milk Buckets", thePlayer, 255, 255, 255, true) else outputChatBox("#727272You already have 10/10 Buckets of Milk", thePlayer, 255, 255, 255, true) end end end addCommandHandler( "collect", collectLeite ) Error script.lua:3 attempt to compare boolean with number Edited May 29, 2019 by LucasDSNL Link to comment
DNL291 Posted May 29, 2019 Share Posted May 29, 2019 function collectLeite(thePlayer) if getElementType(thePlayer) == "player" then local g_MilkBuckets = tonumber( getElementData(thePlayer,"MilkBuckets") ) or 0 if type(g_MilkBuckets) ~= "number" then return end if g_MilkBuckets < 10 then setElementData(thePlayer,"MilkBuckets", g_MilkBuckets + 1) outputChatBox("#727272You have collected #ffff00 " ..tostring((g_MilkBuckets + 1)).. "/10 Milk Buckets", thePlayer, 255, 255, 255, true) elseif g_MilkBuckets == 10 then outputChatBox("#727272You already have 10/10 Buckets of Milk", thePlayer, 255, 255, 255, true) else outputChatBox( "Unknown error", thePlayer, 255, 0, 0 ) end end end addCommandHandler( "collect", collectLeite ) @LucasDSNL 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