Jump to content

fivosga

Members
  • Posts

    9
  • Joined

  • Last visited

Details

  • Gang
    ~|PoD|~

fivosga's Achievements

Newbie

Newbie (4/54)

0

Reputation

  1. ok! I will try to learn although I will totaly fail on it! Can you at least tell me what the problem is on DrakeN's version?
  2. I managed to edit community top times and make them quite nice and now I want to make a MY-SQL share with another clan. The problem is that the community top times are exporting in SQLite... How can I make them export in MY-SQL? This is the code of the SQLite database -- -- databasetable_server.lua -- -- A Lua table which is loaded/saved from the sqlite database -- Handled column types are TEXT and REAL -- SDatabaseTable = {} SDatabaseTable.__index = SDatabaseTable SDatabaseTable.instances = {} --------------------------------------------------------------------------- -- -- SDatabaseTable:create() -- -- -- --------------------------------------------------------------------------- function SDatabaseTable:create(name,columns,columnTypes) local id = #SDatabaseTable.instances + 1 SDatabaseTable.instances[id] = setmetatable( { id = id, name = name, columns = columns, columnTypes = columnTypes, rows = {}, }, self ) SDatabaseTable.instances[id]:postCreate() return SDatabaseTable.instances[id] end --------------------------------------------------------------------------- -- -- SDatabaseTable:destroy() -- -- -- --------------------------------------------------------------------------- function SDatabaseTable:destroy() SDatabaseTable.instances[self.id] = nil self.id = 0 ped = nil vehicle = nil end --------------------------------------------------------------------------- -- -- SDatabaseTable:postCreate() -- -- -- --------------------------------------------------------------------------- function SDatabaseTable:postCreate() -- Set column types as strings if not set while #self.columnTypes < #self.columns do table.insert( self.columnTypes, 'TEXT' ) end end --------------------------------------------------------------------------- -- -- SDatabaseTable:safestring() -- -- -- --------------------------------------------------------------------------- function safestring( s ) -- escape ' return s:gsub( "(['])", "''" ) end function qsafestring( s ) -- ensure is wrapped in ' return "'" .. safestring(s) .. "'" end function qsafetablename( s ) return qsafestring(s) end --------------------------------------------------------------------------- -- -- SDatabaseTable:load() -- -- -- --------------------------------------------------------------------------- function SDatabaseTable:load() for i=1,10 do if self:tryLoad() then return end end end --------------------------------------------------------------------------- -- -- SDatabaseTable:tryLoad() -- -- -- --------------------------------------------------------------------------- function SDatabaseTable:tryLoad() outputDebug( 'TOPTIMES', 'SDatabaseTable: Loading ' .. self.name ) self.rows = {} local cmd -- CREATE TABLE self:createTable() -- SELECT -- Build command cmd = 'SELECT * FROM ' .. qsafetablename( self.name ) local sqlResults = executeSQLQuery( cmd ) if not sqlResults then return false end -- Process into rows self.rows = {} for r,sqlRow in ipairs(sqlResults) do local row = {} for c,column in ipairs(self.columns) do row[column] = sqlRow[column] end table.insert( self.rows, row ) end -- Make copy to detect changes self.rowsCopy = table.deepcopy(self.rows) return true end --------------------------------------------------------------------------- -- -- SDatabaseTable:save() -- -- -- --------------------------------------------------------------------------- function SDatabaseTable:save() -- See if save required local bChanged = false if not self.rowsCopy or #self.rows ~= #self.rowsCopy then bChanged = true else for r,row in ipairs(self.rows) do for c,col in ipairs(self.columns) do if self.rows[r][col] ~= self.rowsCopy[r][col] then bChanged = true break end end if bChanged then break end end end if not bChanged then return end outputDebug( 'TOPTIMES', 'SDatabaseTable: Saving ' .. self.name ) -- Being save executeSQLQuery( 'BEGIN TRANSACTION' ); local cmd -- DELETE TABLE -- Build command --cmd = 'DELETE FROM ' .. qsafetablename( self.name ) cmd = 'DROP TABLE IF EXISTS ' .. qsafetablename( self.name ) executeSQLQuery( cmd ) -- CREATE TABLE self:createTable() -- Rebuild -- For each row for r,row in ipairs(self.rows) do -- INSERT INTO cmd = 'INSERT INTO ' .. qsafetablename( self.name ) .. ' VALUES (' for c=1,#self.columns do if c > 1 then cmd = cmd .. ', ' end local key = self.columns[c] if type(row[key]) == 'number' then cmd = cmd .. row[key] or 0 else cmd = cmd .. qsafestring( row[key] or '' ) end end cmd = cmd .. ')' executeSQLQuery( cmd ) end executeSQLQuery( 'END TRANSACTION' ); -- Make copy to detect changes self.rowsCopy = table.deepcopy(self.rows) end --------------------------------------------------------------------------- -- -- SDatabaseTable:createTable() -- -- -- --------------------------------------------------------------------------- function SDatabaseTable:createTable() local cmd -- CREATE TABLE -- Build command cmd = 'CREATE TABLE IF NOT EXISTS ' .. qsafetablename( self.name ) .. ' (' for c=1,#self.columns do if c > 1 then cmd = cmd ..
  3. This is not getting to anywhere. Im not receiving any answers. They only thing I want is a site to learn lua but a simle one to start from. I dont want to start with lua.org even if it is the official site. I dont realy give a damn if it is called LUA, Lua or lua! Not my problem the pronounciation. The only thing I want is either for some help to learn lua or a scripter that can help me with my project. Thanks
  4. I did but the wiki wont realy help me to do the things I want... I need professional things so the wiki is a bunch of crap for what I want.... Sliding TopTimes with a MY-SQL database instead of SQLite so we can sync our server with diferrent ones -A new userpanel that stores stats in the MY-SQL Database and for them to appear in the forum -Different Changes in Race Gamemode -Show Current Map in Gamemode -A new radar -A new speedometer -Make everything toggable in the panel through the options tab -Login Panel GUI that takes account name and pass from a database -Panel should contain = Stats (toptimes, money, rank, points, etc.), Map Shop, Horn Shop, Vehicle Customizations, Options tab (Panel color, Toggle fuctions such as ~|PoD|~Mods) -~|PoD|~Custom infernus mod -~|PoD|~Countdown -Antything else you would like to add and if you are volunteering to help please let me know . My skype : fivoss3
  5. I also want to learn scripting and I think your idea is great but I dont realy know from where to start. I started in lua.org but I could not understand anything. It would be fabulous to give me a site to start from. Thank you!
  6. Today we launched a new clan / server named ~|PoD|~ which is gonna be for DM/DD/FUN and we are trying to find a scripter that is interested to help and knows LUA for our server scripts, MY-SQL to output our server stats in a database and PHP so he can edit our forum and to be able to add a "Map Uploader" and "Stats" that output from our server panel to the website through MY-SQL... Im having high expectations so I want it to be better than -|TG|- or FFS. Also if you offer we will give you a free development server to develop your scripts... We want him to have experience and be free to help us just like NeXTreme so he will be co-owner of our server... Please help us if you have the experience. What we would like for our server: -Sliding TopTimes with a MY-SQL database instead of SQLite so we can sync our server with diferrent ones -A new userpanel that stores stats in the MY-SQL Database and for them to appear in the forum -Different Changes in Race Gamemode -Show Current Map in Gamemode -A new radar -A new speedometer -Make everything toggable in the panel through the options tab -Login Panel GUI that takes account name and pass from a database -Panel should contain = Stats (toptimes, money, rank, points, etc.), Map Shop, Horn Shop, Vehicle Customizations, Options tab (Panel color, Toggle fuctions such as ~|PoD|~Mods) -~|PoD|~Custom infernus mod -~|PoD|~Countdown -Antything else you would like to add and if you are volunteering to help please let me know . My skype : fivoss3 *Dont forget we will give you a free server for development which you can use for whatever you like.
×
×
  • Create New...