Jump to content

novo

Members
  • Posts

    325
  • Joined

  • Last visited

Everything posted by novo

  1. Aware that this is already solved, just came to recommend you using latentEvents when transfering a large data amount.
  2. not table[2][2] -- not + nil = true / false + false = true / negative + negative = positive (mathematical reference) So you can basically go through an if statement, or any other way you prefer, using the above trick to check whether that table value is either nil or false - as I did with table[3] within my previous sample code.
  3. (Just seen Dealman's latter reply but still going to publish this as an additional information). As Dealman stated above, in case an index does not contain anything it returns nil. Which entails an error when indexing a nil value. local table = { {"A", "B"} {"A"} } if table[2] then print(tostring(table[2][2])) -- tostring in order to be able to print any kind of variable print(tostring(nil)) -- prints nil end if table[3] then -- does not exist, hence not following up end
  4. You may use onResourcePreStart or onResourceStart.
  5. Have a look at this.
  6. novo

    LAST_INSERT_ID()

    I haven't got an exact answer for your issue (though either way you haven't set a FROM statement together with LAST_INSERT_ID) but you may use this workaround. SELECT MAX(houseID) FROM housing;
  7. novo

    script

    Actually, Lua permits you utilizing functions through different files (as long as these are not set as local). So you may simply create one or two (in case both client and server sides contain these) new script files and run them before the main codes by adding them above on the meta file. Once done so, overwrite outputChatBox to your own custom function. local _outputChatBox = outputChatBox function outputChatBox () return true -- in case you do not want to show up any message end function outputChatBox (message, ...) local advertisement = message:lower():find("visit", 1, true) -- pass the text to lowercase and checking whether it contains any desired word return advertisement or _outputChatBox(message, ...) -- returns 'true' only in case previous statement returns so, or either outputs a message (because advertisement will then be equal to false) end
  8. As seen at databasetable_server.lua, function SDatabaseTable:tryLoad() ( ... ) local cmd -- SELECT -- Build command cmd = 'SELECT * FROM ' .. qsafetablename( self.name ) local sqlResults = executeSQLQuery( cmd ) ( ... ) end in order to transfer and utilize sqlite-stored toptimes with your new system, you'll simply need to gather these's info and insert them into your mysql database. 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
  9. novo

    Basic's SQL

    Well, it depends on how frequently you're updating the accounts data - though I do not recommend you using any other way to find an account than the username itself. Technically you're able to do so but, in case of a shared account, an account might contain either the serial of another computer the user has connected through or whatever.
  10. novo

    Basic's SQL

    I'm afraid I'm unable to provide you an appropriate answer to your question, though you can add new columns through ALTER.
  11. novo

    Basic's SQL

    You can add as many values you wish, though the columns should be previously created.
  12. novo

    Basic's SQL

    As specified here and checked here, seems like. Use the following code @second link. CREATE TABLE IF NOT EXISTS `accounts` (username TEXT, serial TEXT, playerName TEXT); INSERT INTO `accounts` SET `username` = 'IIYAMA'; INSERT INTO `accounts` SET `username` = 'novo'; UPDATE `accounts` WHERE `username` = 'IIYAMA' SET `serial`= 'ABCD', `playerName` = 'name'; UPDATE `accounts` SET `serial`= 'ABCD', `playerName` = 'name' WHERE `username` = 'novo';
  13. novo

    Help Bindkey

    Another gui is being created because you've done that everytime that F3's being pressed, pmGUI's executed and hence another window created. I recommend you setting a variable called state through which you will iterate in order to show and hide your desired guis. Either way, I would just do the following: (as you've requested us to not do any further improvements in your code, here's an example) -- Create the window as soon as the client-code is loaded local pmWindow = guiCreateWindow(498, 143, 353, 549, "", false) guiSetVisible(pmWindow, false) -- making it invisible showCursor(false) -- disabling cursor, though it should be already disabled so.. whatever local pmEnabled = false function dxText () if not pmEnabled then return end -- do not execute any further code within this function as long as 'pmEnabled' is false dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender", root, dxText) function togglePM () pmEnabled = not pmEnabled -- example: pmEnabled is false, doing 'not false' will return true - so we then iterate this way between states guiSetVisible(pmWindow, pmEnabled) -- set our window visible or not, depending on the previously set state showCursor(pmEnabled) -- same as making the window visible, though with the cursor end bindKey("F3","up", togglePM) --bindKey("F3","up", showDxText) -- REMOVED
  14. novo

    Basic's SQL

    I would rather do it as follows: local connect = dbConnect ( "sqlite", "file.db" ) local possibleData = { "username TEXT", "serial TEXT", "playerName TEXT" } dbExec(connect, "CREATE TABLE IF NOT EXISTS `accounts` (" ..table.concat(possibleData,", ")..")") addCommandHandler("test", function (player) local account getPlayerAccount(player) if not isGuestAccount (account) then local accountName = getAccountName(account) local serial = getPlayerSerial(player) local playerName = getPlayerName(player) -- local query = dbExec(connect, "SELECT * FROM `accounts` WHERE `username` = ?", accountName) local _, rows = dbPoll(query, -1) if rows == 0 then -- in case an account's data row is not created yet dbExec(connect, "INSERT INTO `accounts` SET `username` = ?", accountName) end dbExec(connect, "UPDATE `accounts` SET `serial`= ?, `playerName` = ? WHERE `username` = ?", serial, playerName, accountName) end end )
  15. Actually, maps are being sent to client-side through tables in order to load them uniquely from an specific player's client-side. (multi-gamemodes) Though yeah, loadMapData loads the map server-side hence creating all the objects, vehicles, etc. for everyone.
  16. novo

    file

    In order for this to work, the files should also be included in meta.xml with the download attribute set to "false". Then you can simply download the files you wish using downloadFile and then executing any necessary code attached to onClientFileDownloadComplete. local files = {} files.textures = {infernus = {status = {txd = false, dff = false}, "infernus.txd", "infernus.dff"}} files.images = {"something.png"} function files:download () for key, value in pairs(self) do if type(value) == "table" then for key, value in pairs(value) do if type(value) == "table" then -- textures (as it contains sub-tables) for index, file in ipairs(value) do -- status will be ignored as it's not a numerical index downloadFile(value) -- infernus.txd / infernus.dff / ... end else downloadFile(value) -- something.png / ... end end end end end addEventHandler("onClientFileDownloadComplete", root, function(name, success) if not success then return end -- Example if name == "infernus.txd" then files.textures.infernus.status.txd = true elseif name == "infernus.dff" then files.textures.infernus.status.dff = true end -- if files.textures.infernus.status.txd and files.textures.infernus.status.dff then -- both files are downloaded engineImportTXD(engineLoadTXD("infernus.txd"), 425) engineReplaceModel(engineLoadDFF("infernus.dff", 0), 425) end end ) Just for you to get an idea about what you would need, though does not mean the upper way is the unique functional nor the most efficient. What I did above is downloading both texture files (infernus.txd and infernus.dff) and checking whether both files are downloaded before replacing a model with them, using a couple of booleans named there as 'status'.
  17. novo

    [TUT] Lua Tables

    However, for those who still did not understand the differences between pairs and ipairs; local numerical = {"A", "B", "C"} for index, value in ipairs(numerical) do print(index.." => "..value) -- 1 => A end local alphabetical = {"A", ["two"] = "B", three = "C"} -- Alphabetical indexing can be done either with brackets or rawly (as I've done with three). Though it will be necessary to utilize brackets if you wish adding special characters to these. for key, value in pairs(alphabetical) do print(key.." => "..value) -- 1 (numerical indexing) => A end Also note that, ipairs will ignore alphabetical indexes. Whilst pairs will, as Walid stated above, gather both types, numerical and alphabetical ones.
  18. novo

    file

    It actually is possible. You may make the players load the necessary client-sided code and simultaneously download files (ref. latent events) during their play and replacing textures or whatever else you expect doing with these.
  19. novo

    Help plis

    I recommend you to move your question to a foreign specialized forum.
  20. novo

    Spawn player.

    You're welcome, make sure to check this out if you wish learning more about relational operators.
  21. I guess you will then have to use getCameraMatrix and its facing integers together with few arithmetic operations.
  22. novo

    Spawn player.

    getPlayerAccount returns the player's account object, or false if the player passed to the function is invalid. And as I guess you want to check if player's account name is equal to Terminator, you should retrieve it by using getAccountName. And thus comparing the returned string; local account = getPlayerAccount(source) local accountName = getAccountName(account) if accountName == "Terminator" then -- exactly equal to
  23. The problem is that you've set your resource's name to [myserver]. By using square brackets, the system will be checking for resources under [myserver] and thus using it as a differentiaton directory. You can see an example at [gamemodes], [gameplay] and so on. So basically you'll need to rename your resource to myserver as specified on the wiki introduction. To create your own resource, simply make a folder with your preferred name. We'll use "myserver" for this tutorial. Now you should be under this directory: server/mods/deathmatch/resources/myserver/
  24. onClientVehicleDamage is client-side only, would be onVehicleDamage server-side. Actually, you should do it client-side as you might want to utilize all the arguments it offers.
  25. novo

    Marker Vehicle

    That's because i is lowercase and it's supposed to be upper (warpPedIntoVehicle), as Lua is not case-sensitive.
×
×
  • Create New...