Cepillado Posted May 4, 2014 Share Posted May 4, 2014 Hello, I'm having a problem trying to save an element data into a .ini file, here's my code local playerName = getPlayerName( source ) local levelAdmin = getElementData(source,"Admin") local stringName = string.format("Users/%s.ini",playerName) local stringAdmin = string.format("Admin: %i\n",levelAdmin) fileOpen(stringName) fileWrite(stringName,stringAdmin) fileClose(stringName) But when I disconnect, I get 2 warnings and nothing saves: Bad 'file' pointer @ 'fileWrite' (1) and Bad 'file' pointer @ 'fileClose' (1). Thanks Link to comment
Castillo Posted May 4, 2014 Share Posted May 4, 2014 fileOpen returns a file userdata, which you must use for fileWrite and fileClose. local playerName = getPlayerName( source ) local levelAdmin = getElementData ( source, "Admin" ) local stringName = string.format ( "Users/%s.ini", playerName ) local stringAdmin = string.format ( "Admin: %i\n", levelAdmin ) local file = fileOpen ( stringName ) if ( file ) then fileWrite ( file, stringAdmin ) fileClose ( file ) end 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