Wei Posted June 22, 2012 Posted June 22, 2012 function refreshData() local x, y, z = getElementPosition( localPlayer ) or "N/A" local location = getZoneName ( x, y, z ) or "N/A" guiSetText( perDataLabel[5], "Position : "..x..","..y..","..z ) guiSetText( perDataLabel[6], "Location : "..location ) end Error that x is a nil value and for location is the error expected number at argument 2 got nil
Alexs Posted June 22, 2012 Posted June 22, 2012 function refreshData() local x,y,z = getElementPosition( localPlayer ) or "N/A" local location = getZoneName ( x,y,z ) or "N/A" guiSetText( perDataLabel[5], "Position : "..x..","..y..","..z ) guiSetText( perDataLabel[6], "Location : "..location ) end you use spaces in x, y, z....
Castillo Posted June 22, 2012 Posted June 22, 2012 @Alexs_Steel: The spaces between variable names has nothing to do with his problem, they make no difference. @blazy: The only problem I see is that you set "or N/A", but the function should return 3 arguments, so with one it'll cause that error. function refreshData ( ) local x, y, z = getElementPosition ( localPlayer ) local location = getZoneName ( x, y, z ) or "N/A" guiSetText ( perDataLabel[5], "Position : ".. tostring ( x ) ..",".. tostring ( y ) ..",".. tostring ( z ) ) guiSetText ( perDataLabel[6], "Location : ".. tostring ( location ) ) end
Callum Posted June 23, 2012 Posted June 23, 2012 Surely localPlayer will always exist, thus both the position and zone name will never return false.
Wei Posted June 23, 2012 Author Posted June 23, 2012 function sendMoney( sPlayer, sMoney ) if ( getPlayerMoney(source) >= tonumber(sMoney) ) then givePlayerMoney( sPlayer, sMoney ) takePlayerMoney( source, sMoney ) else outputChatBox("You don't have enought money", source) end end how can I make here if the sMoney is not number then will return end instead of error ?
Guest Guest4401 Posted June 23, 2012 Posted June 23, 2012 function sendMoney(sPlayer,sMoney) local sMoney = tonumber(sMoney) if sMoney then if getPlayerMoney(source) >= sMoney then givePlayerMoney(sPlayer, sMoney) takePlayerMoney(sPlayer, sMoney) else outputChatBox("You don't have enough money",source) end end end
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