sheenidgs Posted February 5, 2016 Posted February 5, 2016 (edited) Hi I want ask my problem about settings.xml I have a script like this server.lua local sqlHandle = nil local connString = nil local accParse = { "id","admin","level","team","xp","points","skin","kills","deaths","location","money","bank" } -- inisialisasi MySQL local sqlHost = "host=" ..get( "MySQLHost" ) or "none" local sqlPort = "port=" ..get( "MySQLPort" ) or "none" local sqlUser = get( "MySQLUser" ) or "none" local sqlPass = get( "MySQLPass" ) or "none" local sqlDB = "dbname=" ..get( "MySQLDB" ) or "none" settings.xml "MySQLHost" value="127.0.0.1"> "MySQLPort" value="3306"> "MySQLUser" value="mta-sa"> "MySQLPass" value="mta"> "MySQLDB" value="mta_sa"> In server.lua, I use get function to get the settings value in settings.xml, BUT it doesn't work and I don't know why I've read this wiki -> https://wiki.multitheftauto.com/wiki/Settings_system and it should be work. This is what i've tried: - change "MySQLHost" to "*MySQLHost" <-- it doesn't work - change "MySQLHost" to "*joinpanel.MySQLHost" <-- it works! But that's not my goal. I want make this setting applied to all of the resources i had. It should be works if I'm not input the access modified and resource name This is settings.xml what I mean Edited February 5, 2016 by Guest
ViRuZGamiing Posted February 5, 2016 Posted February 5, 2016 How about this? there might be a better way tho, local resourceTable = getResources() -- get a table of resources for resourceKey, resourceValue in ipairs(resourceTable) do local name = getResourceName(resourceValue) --name.MySQLHost end "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
sheenidgs Posted February 5, 2016 Author Posted February 5, 2016 How about this? there might be a better way tho, local resourceTable = getResources() -- get a table of resources for resourceKey, resourceValue in ipairs(resourceTable) do local name = getResourceName(resourceValue) --name.MySQLHost end Thanks for your inspiration!!!! I've solve this problem with this way: - create a resource with Meta.xml file only for resource info Meta.xml from resource mysql "Rachmad Setiawan" type="configuration" name="MySQL" version="1.0" description="A MySQL Configuration from A Resource" /> - include this resource (mysql) to a target resource (the resource that you want to use this configuration) Meta.xml "Rachmad Setiawan" type="client-login" name="Login Panel" version="1.0" description="A login panel using MySQL" /> -- Butuh resource lain untuk konfigurasinya, seperti MySQL --> resource="mysql" /> - add resource owner (mysql) to the configuration -- Pengaturan koneksi ke database di MySQL --> "#mysql.host" value="127.0.0.1"> "#mysql.port" value="3306"> "#mysql.user" value="mta-sa"> "#mysql.pass" value="mta"> "#mysql.db" value="mta_sa"> - get the configuration server.lua local sqlHandle = nil local connString = nil local accParse = { "id","admin","level","team","xp","points","skin","kills","deaths","location","money","bank" } -- inisialisasi MySQL local sqlHost = "host=" ..get( "mysql.host" ) or "none" local sqlPort = "port=" ..get( "mysql.port" ) or "none" local sqlUser = get( "mysql.user" ) or "none" local sqlPass = get( "mysql.pass" ) or "none" local sqlDB = "dbname=" ..get( "mysql.db" ) or "none" Thanks for the help
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