MrTasty

Members
  • Content Count

    932
  • Joined

  • Last visited

  • Days Won

    4

MrTasty last won the day on February 10

MrTasty had the most liked content!

Community Reputation

138 Excellent

About MrTasty

  • Rank
    Hoodsta

Details

  • Location
    United Kingdom
  • Occupation
    Scripting Guru

Recent Profile Visitors

3,220 profile views
  1. MrTasty

    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.
  2. 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.
  3. 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)
  4. Client-side variant of setVehicleHandling can only modify handling of vehicles which are local only, i.e. client-side vehicles that don't exist on the server side, which a player cannot enter.
  5. Cause you're only rendering onto a render-target. After you've rendered the contents in your render-target, you need to render the render-target itself as well. -- add this somewhere at the top in outermost scope local screenX, screenY = guiGetScreenSize() -- add this right after setting rendering target to screen (line 27) dxDrawImage(0, screenY - hud.przez, hud.szer, hud.przez, minimap)
  6. loadstring loads Lua code from a string into a function than you can call (to execute the loaded code). Looking at the loadstring error message, it does not appear that you're putting code into that, but rather a string of text, not code. You have two options: Either change line 65 to memo = guiCreateMemo(241, 24, 450, 437, "Bem vindo/a ao RPG City Reallife. Use o menu á esquerda para navegar pela documentação do servidor.\n\nRegras do Servidor:\n\n"..rules, false, window) and remove line 28 through 34 (the safer option, since you remove the ability for arbitrary code execution in your script) Or the second option, is to change the rules.txt file to contain valid code which this script expects. It appears to expect a table named theRules with a string of rules under the key "English", so your rules.txt should be local theRules = { ["English"] = "Art 1° - Não praticar Power Gaming: Mínimo (10H) Máximo(24H ..." } and it should load correctly. However, this is less safe, since it can allow someone with access to editing rules.txt to insert malicious code into the file, which is then executed on through clients' Lua interpreters.
  7. First of all, to clarify, onVehicleEnter, onClientClick etc. are native events, not native functions. resourceRoot contains all the elements created by thisResource. If you want to handle all objects created by this resource, you'll want to bind the events on resourceRoot. If you want to handle foreign elements (from other resources), you'll need to use root. If you're only interested in handling a specific element or elements, use (multiple) bind(s) to single element(s). onVehicleEnter on resourceRoot will only trigger for any player or ped who enters a vehicle created by this resource. onVehicleEnter on root will trigger for players or peds entering any vehicle, regardless of which resource created it. onClientClick's source is always root, so I don't think it will trigger for resourceRoot at all. You have to look at the wiki pages for each event, check what the source of the event is, and determine what element to attach the handler to. Root attaches onto everything (unless you set propagate to false), resourceRoot attaches to everything created by your resource. It goes down the element tree.
  8. According to what I found on mybb github , t, their hashing method is md5 of salt and md5 of password concatenated together and md5 hashed again, this time together. local passHash -- comes from the database local passSalt -- comes from the database local password -- user input if passHash == md5( md5(passSalt) .. md5(password) ) then -- password is correct else -- password is incorrect end
  9. -- make these accessible throughout this file local shader = nil local terrain = nil local active = false function toggleShader(state) if state == active then return false -- don't do anything if it's already in the desired state end if state then engineApplyShaderToWorldTexture(shader, 'cj_rubbish1') engineApplyShaderToWorldTexture(shader, 'sf_junction2') engineApplyShaderToWorldTexture(shader, ':Oroad01_law') engineApplyShaderToWorldTexture(shader, 'des_1line256') engineApplyShaderToWorldTexture(shader, 'concretebig4256128') active = true else engineRemoveShaderFromWorldTexture(shader, 'cj_rubbish1') engineRemoveShaderFromWorldTexture(shader, 'sf_junction2') engineRemoveShaderFromWorldTexture(shader, ':Oroad01_law') engineRemoveShaderFromWorldTexture(shader, 'des_1line256') engineRemoveShaderFromWorldTexture(shader, 'concretebig4256128') active = false end return true end addEventHandler('onClientResourceStart', resourceRoot, function() shader = dxCreateShader('shader.fx') terrain = dxCreateTexture('img/road.jpg') dxSetShaderValue(shader, 'gTexture', terrain) toggleShader(true) -- toggle on at start end ) addCommandHandler("shadertogglecmd", function() toggleShader(not active) -- invert toggle on command end )
  10. cancelEvent() cancels an event from happening. Prevents default behaviour. Return simply exits a function and sends a return value. CancelEvent can be used to prevent GTA hardcoded behaviour, whilst return can only prevent your own Lua code from any further execution in the current context.
  11. Have you tried dimensions? setElementDimension You can put all objects into dimensions -1, making them visible in every dimension, but keep players in seperate dimensions. Alternatively, you can manage the visibility of the objects manually through clientside scripts: Keep players in seperate dimensions but put the objects into the dimension of the localPlayer, on the client.
  12. Are you trying to store player money? I'd suggest you use an XML styled more like this: <accounts> <account name="playername1" balance="1000"></account> <account name="playername2" balance="1500"></account> </accounts> And use the Lua table associatively (like a directory) instead of as an array. local moneyT = { ["playername1"] = 1000, ["playername2"] = 1500, } Generally, the way you were trying to tackle this problem is over-complicated. You're storing two related values in seperate arrays when you can use associative arrays and additionally avoid having to loop over every value searching for someone's account - if you use associative arrays, you can just index it by the player's name. --Tabele accountsT = { -- [playername] = balance } --Funkcja zczytująca zapisane tabele addEventHandler("onResourceStart", root, function() -- Open the XML local xml = xmlLoadFile("accounts.xml") if xml then local accounts = xmlNodeGetChildren(xml, "account") -- Loop through the accounts for i, node in ipairs(accounts) do local name = xmlNodeGetAttribute(node, "name") local balance = xmlNodeGetAttribute(node, "balance") -- Store `balance` in accountsT table under key `name` accountsT[name] = balance end -- Unload the XML xmlUnloadFile(xml) else -- Create XML, save and unload local xml = xmlCreateFile("accounts.xml", "accounts") xmlSaveFile(xml) xmlUnloadFile(xml) end end ) --Funkcja zapisująca tabele addEventHandler("onResourceStop", root, function() -- Create the XML local xml = xmlCreateFile("accounts.xml", "accounts") -- Loop through each account for name, balance in ipairs(accountsT) do -- Create <account> node and store account number and balance as attributes local account = xmlCreateChild(xml, "account") xmlNodeSetAttribute(account, "name", name) xmlNodeSetAttribute(account, "balance", balance) end -- Save the XML xmlSaveFile(xml) xmlUnloadFile(xml) end ) --Reszta skryptu (komendy) --Funkcja do przelewów addCommandHandler("przelew", function(player, command, pname, amount) local target = getPlayerFromName(pname) if not target then outputChatBox("ERROR_TARGET_DOES_NOT_EXIST", player, 255, 0, 0) return end -- be sure to translate this yourself -- Check if target is yourself if target == player then outputChatBox("ERROR_CANT_SENT_TO_YOURSELF", player, 255, 0, 0) return end -- be sure to translate this yourself -- Check if amount is valid amount = tonumber(amount) or 0 -- default to zero to give invalid amount error but allow math.floor to work amount = math.floor(amount) -- make sure players aren't sending non-integers if not amount or amount <= 0 then outputChatBox("ERROR_INVALID_AMOUNT", player, 255, 0, 0) return end -- be sure to translate this yourself -- If trying to send more than you have if amount > getPlayerMoney(player) then outputChatBox("ERROR_INSUFFICIENT_FUNDS", player, 255, 0, 0) return end -- be sure to translate this yourself takePlayerMoney(player, amount) givePlayerMoney(target, amount) outputChatBox("#09ff00Przelew ukończony pomyślnie!", player, 255, 255, 255, true) outputChatBox("#ffffff" .. getPlayerName(player) .. "#09ff00 przelał Ci #ffffff$" .. amount .. "#09ff00 do twojego portfela!", target, 255, 255, 255, true) end ) --Funkcja do wpłacania pieniędzy addCommandHandler("wplac", function(player, command, amount) amount = tonumber(amount) or 0 -- default to zero to given invalid amount error but allow math.floor to work amount = math.floor(amount) if not amount or amount <= 0 then outputChatBox("ERROR_INVALID_AMOUNT", player, 255, 0, 0) return end -- be sure to translate this yourself -- If trying to send more than you have if amount > getPlayerMoney(player) then outputChatBox("ERROR_INSUFFICIENT_FUNDS", player, 255, 0, 0) return end -- be sure to translate this yourself local name = getPlayerName(player) -- Create player's account if it doesn't exist yet if not accountsT[name] then accountsT[name] = 0 end takePlayerMoney(player, amount) -- take player's money accountsT[name] = accountsT[name] + amount -- and add it onto his account outputChatBox("#09ff00Wpłaciłeś na konto bankowe #ffffff$" .. amount .. "#09ff00!", player, 255, 255, 255, true) end ) --Funkcja do wypłacania pieniędzy addCommandHandler("wyplac", function(player, command, amount) amount = tonumber(amount) or 0 -- default to zero to given invalid amount error but allow math.floor to work amount = math.floor(amount) if not amount or amount <= 0 then outputChatBox("ERROR_INVALID_AMOUNT", player, 255, 0, 0) return end -- be sure to translate this yourself local name = getPlayerName(player) -- Create player's account if it doesn't exist yet if not accountsT[name] then accountsT[name] = 0 end local balance = accountsT[name] -- If trying to send more than you have if amount > balance then outputChatBox("ERROR_INSUFFICIENT_FUNDS_ON_ACCOUNT", player, 255, 0, 0) return end -- be sure to translate this yourself accountsT[name] = accountsT[name] - amount -- reduce player's account balance givePlayerMoney(player, amount) -- and give him the amount outputChatBox("#09ff00Wpypłaciłeś z konta bankowego #ffffff$" .. amount .. "#09ff00!", player, 255, 255, 255, true) end ) I haven't tested the code above, but should it not work, hopefully you'll be able to fix whatever minor bugs I've got there. Don't forget to add your translations. I've restructured it to use returns to escape out of a function to avoid indentation leading to pyramids of doom. I have also removed XML saving on player quit, since it's kinda redundant. As long as the server doesn't crash, you're safe just saving the XML when the resource is stopped.
  13. For weapons held in a ped/player's hand, you use "ped" because a weapon held by a ped is part of the ped in GTASA. You'll need to apply the shader to the world texture named exactly like the weapon object's texture, and have the ped/player as the target element.
  14. You need to use getPedTask or getPedSimplestTask but I'm not sure what task you'd be looking for. Try displaying the tasks of the local player on screen for debugging, find out what tasks are active while aiming, then remove the debug displays since they're no longer needed, and check if these tasks are active before rendering the healthbar.
  15. MrTasty

    [Help] HLSL

    Are you asking for any particular help or just dumping a lot of code and letting others figure out you're trying to do or what the problem is?