..:D&G:.. Posted October 25, 2014 Posted October 25, 2014 Hello guys, I just found out about this error from debugscript attempt to perform arithmetic on a boolean value function updateInventory( ) windows.inventory[2].panes = { } local t = exports.items:get( getLocalPlayer( ) ) if t then for k, v in ipairs( t ) do local image = exports.items:getImage( v.item, v.value, v.name ) local width = dxGetTextWidth( v.name, 1, "clear" ) + 20 local height = 10 * ( 3 ) table.insert( windows.inventory[2].panes, { image = image or ":players/images/skins/-1.png", onHover = function( cursor, pos ) local width2 = dxGetTextWidth( v.name, 1, "clear" ) + 5 dxDrawRectangle( pos[1], pos[2], pos[3] - pos[1], pos[4] - pos[2], tocolor( unpack( getKeyState( 'delete' ) and { 255, 0, 0, 63 } or { 255, 255, 0, 63 } ) ) ) dxDrawRectangle( pos[1] + 64, pos[2] - 32, width2, height, tocolor( 0, 0, 0, 255 ), true ) dxDrawText( v.name, pos[1] + 110, pos[2] , pos[1] + width, pos[2] - height, tocolor( 255, 255, 255, 255 ), 1, "clear", "center", "center", false, false, true ) end, The error is for this line: local width = dxGetTextWidth( v.name, 1, "clear" ) + 20 Can anyone tell me what's wrong please? MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
..:D&G:.. Posted October 25, 2014 Author Posted October 25, 2014 Anyone? MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
Moderators IIYAMA Posted October 25, 2014 Moderators Posted October 25, 2014 v.name is nil or false or something else invalid. So dxGetTextWidth returns false. Which means you can't count up 20 at a variable which is false. You have to check the source of where this value has been created. 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
..:D&G:.. Posted October 25, 2014 Author Posted October 25, 2014 This is from the MTA Paradise gamemode, any ideas, any one how to fix it? MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
Dealman Posted October 25, 2014 Posted October 25, 2014 It fails to get the width, thus it will return false. You can't do calculations on a boolean(true/false). With most likeliness the variable v.name is not properly defined or passed through. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Moderators IIYAMA Posted October 25, 2014 Moderators Posted October 25, 2014 [quote name=..&G:..]This is from the MTA Paradise gamemode, any ideas, any one how to fix it? You can try this to solve the warning. local width = (dxGetTextWidth( v.name, 1, "clear" ) or 0 ) + 20 But it is better to edit MTA Paradise and fix it there. This is only a temporary/not bug free way of doing. WUT! there is a smiley in your name. O_o 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
..:D&G:.. Posted October 25, 2014 Author Posted October 25, 2014 I managed to find the problem. When a player is given an item by the script, it has to have a name/value like "Bank Card" or a name in the database. Now, I am trying to make each script name the items. MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
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