Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/05/23 in all areas

  1. in setElementData and getElementData functions you're using the "player" variable which is not defined in the code. In the for loop where you set the element data for the player's hunger you not specified the value that has to be set. Im cleaned your code a little bit. Try it, please. Hope it works. local db = dbConnect("mysql", "dbname=test; host=127.0.0.1;charset=utf8", "root", "", "share=0") -- This function loads the player's data from the database function loadPlayerData(player) -- Load the player's data from the database local query = dbQuery(db, "SELECT * FROM players WHERE serial = ?", getPlayerSerial(player)) local result = dbPoll(query, -1) -- If loading the data failed, use default values if not result or #result == 0 then setElementData(player, "money", getPlayerMoney(player)) setElementData(player, "hunger", 100) else setElementData(player, "money", result[1].money) setElementData(player, "hunger", result[1].hunger) end end -- This function saves the player's data to the database function savePlayerData(player) local money = getPlayerMoney(player) local hunger = getElementData(player, "hunger") -- Save the player's data to the database local query = dbQuery(db, "REPLACE INTO players (serial, money, hunger) VALUES (?, ?, ?)", getPlayerSerial(player), money, hunger) dbFree(query) end -- Function to return the player's hunger value function getPlayerHunger(player) return getElementData(player, "hunger") end -- Load the player's data when they join the server addEventHandler("onPlayerJoin", root, function() loadPlayerData(source) end) -- Save the player's data when they quit the server addEventHandler("onPlayerQuit", root, function() savePlayerData(source) end) -- Save the player's data when a parameter is changed addEventHandler("onElementDataChange", root, function(dataName) if dataName == "money" or dataName == "hunger" then savePlayerData(source) end end)
    1 point
  2. local msg = false function checkVehHealth() local veh = getPedOccupiedVehicle(localPlayer) if veh then local currHealth = getElementHealth(veh) if currHealth <= 0 and not msg then outputChatBox("Your vehicle HP is 0", 255, 0, 0) msg = true elseif currHealth > 0 then msg = false end end end addEventHandler("onClientRender", root, checkVehHealth) u can use a boolean variable to ensure the message is only displayed once
    1 point
  3. Hi I noticed that : - The vehicle starts to be on fire below 250 / 1000 - When it's flipped it takes 1100 of damage during the explosion I don't see any event about detecting the vehicle on fire but you can still detect it like this : addEventHandler("onClientVehicleEnter", root, function() local vehicle = source setTimer(function() if getElementHealth(vehicle) < 250 then print("onFire") killTimer(sourceTimer) end end, 500, 0) end)
    1 point
  4. 1.6 has now been released! Original post: Multi Theft Auto: San Andreas 1.6 is ready for testing! Our next major build is coming along nicely, so we are keen to let you guys into the action ASAP. Main highlights Two of the main exclusive highlights of this release is the script support for custom IMG containers, and ability to set model flags. Big thanks to @TheNormalnij for his efforts on making these happen! There are also numerous other changes such as updated translations and main menu texts, new GTA skins, improved sync, improved GTA camera screenshot quality and many other bug fixes and improvements which you can find on our Wiki page. By having you join us to test 1.6 we can make sure we catch any new bugs and fix them before the full release. Backwards compatibility 1.6 is not compatible with the older MTA:SA versions (including the most recent release - MTA:SA 1.5.9). This means that you need to connect to a 1.6 server if you wish to test the 1.6 client. There were a bunch of technical reasons for this incompatibility and they were all necessary for us to continue improving the mod. Currently 1.6 includes 12 backwards incompatible changes which you should be aware of. There may be more incompatible changes to be added during this testing phase. Please check out our preliminary release notes on our Wiki page. Public test servers We are hosting a number of official 1.6 public test servers during the 1.6 testing phase for you to try out. Welcome! After the testing phase is over, our public test servers will be shut down. Full release schedule We are planning a full release of 1.6 around May–June if testing phase goes well. To guarantee a smooth transition for your server, we recommend that you try out and upgrade your scripts on this new testing version before the full release. There will be a new announcement once 1.6 is fully released. Keeping your 1.6 up-to-date Once you've installed 1.6, MTA will automatically prompt you to update to a newer version whenever there is an update available, including once we release 1.6 in full - so no need to download and reinstall 1.6 again. What happens to 1.5? 1.5 installations will be kept intact even after the 1.6 release, to let players and server owners switch over to the new version whenever they feel they are ready. However, new features and changes will only be available on 1.6. Note, that you can have both 1.5 and 1.6 installed at the same time on your computer to allow you to switch between if you want. MTA will prompt you to switch to the correct version if the server doesn't support your current version. CLICK HERE TO DOWNLOAD MTA:SA 1.6 BETA If you spot a bug in MTA, please report it here, or if you spot a bug in of our default resources, please report it here instead. See you in game! --MTA Team
    1 point
×
×
  • Create New...