Addlibs

Members
  • Content Count

    944
  • Joined

  • Last visited

  • Days Won

    4

Addlibs last won the day on February 10

Addlibs had the most liked content!

Community Reputation

139 Excellent

About Addlibs

  • Rank
    Hoodsta

Details

  • Location
    United Kingdom
  • Occupation
    Scripting Guru

Recent Profile Visitors

3,284 profile views
  1. Easy mistake. You're applying the wanted level to the wrong element (to the account instead of the player) Line 13 should be setTimer (setPlayerWantedLevel,500,1,source,wantedLevel)
  2. Addlibs

    (HELP) Nametag

    This isn't a requests section. We can guide you on how to do it, or help you out with particular patterns or algorithms, but we will not script for you. If you don't want to script it yourself either look through community.mtasa.com or pay someone to script it for you.
  3. Addlibs

    Simple help :D

    function RGBToHex(red, green, blue, alpha) -- Make sure RGB values passed to this function are correct if( ( red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 ) or ( alpha and ( alpha < 0 or alpha > 255 ) ) ) then return nil end -- Alpha check if alpha then return string.format("#%.2X%.2X%.2X%.2X", red, green, blue, alpha) else return string.format("#%.2X%.2X%.2X", red, green, blue) end end From MTA wiki useful functions, by NeonBlack
  4. This is a question for you. How do you want to the spawn location chosen? At random? If so, you'll want to use math.random between 1 and the number of spawn points you have, and then take the coordinates for that index. E.g. local spawns = { {x1, y1, z1}, {x2, y2, z2}, ... } -- later in the code when you're actually spawning local spawnIndex = math.random(1, #spawns) -- select a random index between 1 and number of spawns local spawnX, spawnY, spawnZ = spawns[spawnIndex][1], spawns[spawnIndex][2], spawns[spawnIndex][3] -- collect it's first, second and third parameters (x, y and z position)
  5. mysql_ping is part of an external module called MTA-MySQL, which is essentially deprecated at this point. It's way too old and I do not recommend using it. There are newer, better, built-in alternatives like dbConnect, dbQuery, etc. You should change the script's calls to those functions with the newer built-in (non module-based) functions.
  6. You're setting everyone's look-at coordinates to the centre of the localPlayer's screen, not the respective player's screen. Also, last time I used setPedLookAt, it didn't work for remote players correctly. Also, read the Wiki notices (specifically the first one - don't run this on onClientRender): Note: Avoid calling setPedLookAt every frame as this can cause bugs like being invincible to burning. Note: For remote players, you have to use setPedAimTarget before setPedLookAt.
  7. Share the code that you need help with, or at least tell us which script it is if it's from MTASA community resources website.
  8. Using setAccountData you run the risk that items may get duplicated, since there is no protection against an item being listed in the account data of two accounts. Using a central MySQL (external) or sqlite (internal) database table, you could avoid this by having one list of items and who they belong to, rather than seperate lists per account.
  9. https://wiki.multitheftauto.com/wiki/Serial#Notes I wouldn't recommend relying on serials as the sole authentication factor, as serials can be faked, they are not guarenteed to be unique (two players can have the same serial, it's just very unlikely). Indeed, under European privacy rules, if another user gets logged into someone else's account though serial collision, and gains the ability to view the account owner's information, you would probably be violating GDPR (I'm not a lawyer so don't quote me on that, but it definitely sounds like a violation of GDPR).
  10. You cannot return information from the server side this way. You need the server to trigger a client event back with the balance amount. The client should be something like this: -- ... triggerServerEvent("bank-hajs-panel", localPlayer) -- request balance from the server addEventHandler("onClientBrowserDocumentReady", theBrowser, function () bank = triggerServerEvent("bank-hajs-panel", localPlayer) executeBrowserJavascript(source, "document.getElementById('gotowka').innerHTML = '"..getPlayerMoney(localPlayer).."$';") executeBrowserJavascript(source, "document.getElementById('Witamy__nazwa_gracza').innerHTML = 'Witamy "..getPlayerName(localPlayer).."!';") executeBrowserJavascript(source, "document.getElementById('bank').innerHTML = 'Loading...';") -- display a placeholder while we're waiting for the server to return the balance end ) -- ... -- this should be at top level scope, outside any functions addEvent("bank-hajs-balans", true) addEventHandler("bank-hajs-balans", localPlayer, -- server triggers this event sending over the balance function(bank) if initBrowser then -- we only want to continue if the player hasn't hid the panel in the meantime local theBrowser = guiGetBrowser(initBrowser) executeBrowserJavascript(theBrowser, "document.getElementById('bank').innerHTML = '$"..tostring(bank).."';") -- update player's displayed balance end end ) The server should look like this: function bank() local konto = getPlayerAccount(client) -- account of the client who sent the event to the server if konto then triggerClientEvent(client, "bank-hajs-balans", client, getAccountData(konto, "bank.balance")) end end addEvent("bank-hajs-panel", true) addEventHandler("bank-hajs-panel", root, bank)
  11. Addlibs

    [HELP] BAN

    getPlayerID isn't an MTA function; could you show us it's code as well? Also, did you add the resource into admin ACL too? It needs to be privileged to use the function banPlayer.
  12. math.randomseed can affect the RNG of internal MTA logic, yes, but it also works the other way round too -- your math.randomseed can be overridden by internal MTA logic. This could affect seed-based generation if it happens to be interrupted by a map resource with XML vehicle definitions starting for example, which invokes MTA's internal RandomizeRandomSeed function which overrides srand (and by extension math.randomseed)
  13. Addlibs

    Question

    When set to "true", it will make the resource show up in resourcebrowser, which is a resource that handles the server's HTTP webserver, available at http://<server ip>:<http port>/resourcebrowser/ (http port is by default 22005). It will list all resources that are set to "showInResourceBrowser". It is an advanced feature honestly, and if you don't understand HTTP web access programming, you shouldn't worry about it. Unless you're making a resource which has a server-side HTTP page (not related to CEF) then you should set it to "false" or not include "showInResourceBrowser" attribute at all.
  14. Regarding specifically Lua-tables, they generally don't shrink as you nil values inside them (but nil'ing the reference to the table itself will clean up the memory at some point when GC runs, same for whatever is being referenced in the table, will be cleaned up, just that the space for its reference in the table will not be cleaned up), as table rehashing only occurs when adding new elements. A messy workaround is to add a lot of nil entries (about twice as much as the table had data at last rehash) to trigger a new rehash, which will shrink the table and remove the original and newly added nil elements. But the process of adding those nils will most likely cost you more in performance than you save up in memory space. You can still opt to nil out any table values regularly as good practice, just know that it probably won't reduce the table size in memory unless you are adding and nil'ing entries regularly.
  15. If you have OOP enabled, you can use the matrix forward vector multiplied by a scalar coefficient of the magnitude (i.e. strength of the velocity) local magnitude = 0.5 local rocket = createProjectile(ped, 19, x, y, z, 1.0, nil, 0, 0, 0, ped.matrix.forward * magnitude) Otherwise you can use local m = getElementMatrix(ped) local forward = Vector3(m[2][1], m[2][2], m[2][3]) -- offset from player position to position 1m ahead of them taking into account the rotation local magnitude = 0.5 local rocket = createProjectile(ped, 19, x, y, z, 1.0, nil, 0, 0, 0, forward * magnitude) Or, if you prevent to avoid using Vector3 local m = getElementMatrix(ped) local forwardX, forwardY, forwardZ = m[2][1], m[2][2], m[2][3] -- offset from player position to position 1m ahead of them taking into account the rotation local magnitude = 0.5 local rocket = createProjectile(ped, 19, x, y, z, 1.0, nil, 0, 0, 0, forwardX * magnitude, forwardY * magnitude, forwardZ * magnitude)