Drakath Posted February 8, 2014 Share Posted February 8, 2014 attempt to compare nil with number if (tonumber(getPlayerMoney (source)) >= tonumber(cost)) then Is it possible that money can be nil? Or is it the cost that is nil? Link to comment
Castillo Posted February 8, 2014 Share Posted February 8, 2014 Debug it. outputChatBox ( tostring ( cost ) ) Link to comment
Moderators IIYAMA Posted February 8, 2014 Moderators Share Posted February 8, 2014 Cost is nil. getPlayerMoney can only return nil when the player isn't a player or he has already left the game. But that will give a second error/warning. Link to comment
xXMADEXx Posted February 9, 2014 Share Posted February 9, 2014 Cost is nil.getPlayerMoney can only return nil when the player isn't a player or he has already left the game. But that will give a second error/warning. Cost could be nil. Link to comment
Moderators IIYAMA Posted February 9, 2014 Moderators Share Posted February 9, 2014 Cost is nil.getPlayerMoney can only return nil when the player isn't a player or he has already left the game. But that will give a second error/warning. Cost could be nil. or something that isn't a int or float. Link to comment
Drakath Posted February 9, 2014 Author Share Posted February 9, 2014 I tried debugging it with: outputChatBox ( tostring ( cost ) ) But all results outputted a number just like tonumber(cost) I'm not sure how do players manage to make this error. Also when I added this line: if not tonumber(cost) == nil then I couldn't buy it anymore. Link to comment
tosfera Posted February 9, 2014 Share Posted February 9, 2014 Are you sure that you're trying to receive the money of the right person? I've had trouble with this too, but that was because my money was... oh well... 0. ^^" ( without tonumber, this will also give you an error. ) You should try to see what 'source' is: outputDebugString ( getPlayerName ( source ) ) Link to comment
Moderators IIYAMA Posted February 9, 2014 Moderators Share Posted February 9, 2014 well if it output always correct, then it should work. The most secure way would be: local cost= tonumber(cost) local money = getPlayerMoney (source) if cost and money then if money >= cost then outputDebugString("works") else outputDebugString("not enough money") end else outputDebugString("cost or money do not exist.") end Link to comment
Saml1er Posted February 9, 2014 Share Posted February 9, 2014 local cost = tonumber(cost) or 0 This. Link to comment
Moderators IIYAMA Posted February 9, 2014 Moderators Share Posted February 9, 2014 local cost = tonumber(cost) or 0 This. You want to change everything to free when the price is bugged? Link to comment
Saml1er Posted February 9, 2014 Share Posted February 9, 2014 local cost = tonumber(cost) or 0 This. You want to change everything to free when the price is bugged? Oh, right. Well He might be setting the price wrong or something else that its returning nil. Link to comment
Drakath Posted February 10, 2014 Author Share Posted February 10, 2014 Well, I received "cost or money do not exist." output a few times but at least there are no more errors. Thanks. 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