Jump to content

Hale

Members
  • Posts

    174
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Hale

  1. Hale

    ERROR SQL

    You're missing a table from SQL I suppose. Make a new table with such name in your SQL database.
  2. Are you sure there is no other script creating that sound? And the alarm.mp3 file sounds normal?
  3. Hale

    Moderator

    Both onPlayerLogin and onResourceStart return different parameters, not the player. Use 'source' instead of 'thePlayer', and be sure to check if source is a player element (getElementType). function chat( ) if getElementType(source) ~= "player" then return end accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." .. accountname, aclGetGroup("Moderator")) then outputChatBox("Press 'm' To Open Your Moderator Panel", source, 0, 255, 0, false) else end end addEventHandler("onPlayerLogin",getRootElement(),chat) addEventHandler("onResourceStart",resourceRoot,chat)
  4. Try declaring the variables (in which timers will be stored) outside the functions first, like this: local beltAlarm, seatBeltOn, seatBeltOff function beltWarning() stopSound (beltAlarm) beltAlarm = playSound ("alarm.mp3", false) end addEvent ("beltWarning", true) addEventHandler ("beltWarning", getRootElement(), beltWarning) function belt() seatBeltOn = playSound ("belt.wav", false) end addEvent ("belt", true) addEventHandler ("belt", getRootElement(), belt) function unbelt() seatBeltOff = playSound ("unbelt.wav", false) end addEvent ("unbelt", true) addEventHandler ("unbelt", getRootElement(), unbelt)
  5. I suggest you first read the online Lua book, which will make you understand some basics and the main logic of programming in Lua. Afterward, move on to MTA wiki and read the tutorials that are listed on the main page.
  6. Initialize a connection inside "MySQL" resource, and then make exported functions that once called upon, will use the initialized connection. For example: mySQL = dbConnect( "mysql", "dbname=mta;host=localhost", "myserver", "12345") function query(str) if mySQL then local query = dbQuery(mySQL, str) if not ( query ) then return false end local result, num_rows, id = dbPoll(query, -1) return result or false, num_rows or false, id or false end return false end And then in meta.xml simply include: <export function="query" type="server"/>
  7. That... sucks. I suppose I should start using element data?
  8. Hale

    Question

    Here's a good example of how to check vehicle's speed, which is useful unless you want players to die from a vehicle hitting them at 1 km/h. addEventHandler( "onPlayerDamage", root, function (attacker, weapon, bodypart, loss) if isElement(attacker) and getElementType(attacker) == "vehicle" then local speedx, speedy, speedz = getElementVelocity (attacker) local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) local kmh = actualspeed * 180 if kmh > 50 then setElementHealth(source, 0) end end end )
  9. Hello, I've been working on a bigger project for a while, and up until now, I haven't realized I have a major issue regarding my data tables (Lua yes, as I'm trying to achieve best overall performance for the server). To briefly explain, instead of having dozen SQL queries for every data change a player makes, I simply store the data into a table and save it periodically or on resource stop. This was all server side, the main tables and exported functions (updateAccountData, getAccountData, pretty much the same as elementData but better for performance). As I was scripting I came to a realization that all that data in the table was reachable in server side, not client side, which is big of a problem, however, I thought if I move the table and exported functions to a shared .lua (declared in meta.xml as "shared" instead of "server" or "client") it would work just fine, but turns out the table is filled server side if the exported function is called from a server side .lua, and same for client, meaning they don't mix but rather have their own sides. My question is, is there a way to get data from a server side table to client side script/variable? What can or should I do if not, considering I have hundreds of calls to those exported functions from many different files. If you haven't understood what I did regarding the table and exported functions, here are some explanations: accounts = {} -- table containing player data function insertAccountData(element, data) accounts[element] = data end function getAccountData(element, dataName) if dataName then return accounts[element][dataName] or false end return accounts[element] end function updateAccountData(element, dataName, newData) if type(dataName) == "table" then for k,v in ipairs(dataName) do accounts[element][v] = newData[k] or false end else accounts[element][dataName] = newData or false end end function removeAccountData(element) accounts[element] = nil end In expectations of any possible help, thank you!
  10. Hale

    [BUG]META

    Follow the guidelines.
  11. Hale

    Help

    There are examples in the links provided. Maybe isCursorOnElement can be of help as well.
  12. Hale

    wring

    Can you tell us what are you trying to do?
  13. Happens sometimes, try restarting your browser or wait a couple of minutes. EDIT: Just noticed the date of his post...
  14. Hale

    Help

    Use getCursorPosition and processLineOfSight
  15. dxDrawRectangle(screenW * 0.7549, screenH * 0.6933 - 1 - (33*k), 1440 * 0.2347, 990 * 0.0211, tocolor(0, 0, 0, 145), false) dxDrawText(v.text, screenW * 0.7535, screenH * 0.6933 - 1 - (66*k), 1440 * 0.9896, 990 * 0.7144, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, true, false) Try this.
  16. I had the same problem, tried to find a way but there is none I discovered, it just counts it as one argument.
  17. Hale

    Minimap

    What kind of minimap are you talking about?
  18. This guy has the right idea, best way for good performance.
  19. You sure? Can you show us how did you put it server side in XML?
  20. How is that possible nowadays, didn't MTA create its own anti cheat/trainer system?
  21. The reason givePlayerMoney isn't working client side is because you're passing it an extra argument, which is thePlayer. givePlayerMoney in client side has only one argument, which is the amount of money to give. Also, I believe there is no way for an element that is showing to everyone to be destroyed for one player only, hence you should use setElementVisibleTo and a table with stored players that already entered the marker so they don't get the money again.
  22. That means you cannot use those exports (if I'm not wrong), so you should replace this: exports.dpAssets:createFont with dxCreateFont.
  23. Is that exact font existing, and is it declared in meta.xml? EDIT: I'm not sure if you can export fonts like the way you did. Is this working in other scripts?
  24. Try debugging your function by adding: outputDebugString(priceText) after this: if Carshop.currentVehicleInfo.price > 0 then priceText = "$" .. tostring(Carshop.currentVehicleInfo.price) else priceText = exports.dpLang:getString("price_free") end One of those two declarements isn't working properly.
×
×
  • Create New...