MrTasty

Members
  • Content Count

    923
  • Joined

  • Last visited

  • Days Won

    3

MrTasty last won the day on December 3 2019

MrTasty had the most liked content!

Community Reputation

131 Excellent

About MrTasty

  • Rank
    Hoodsta

Details

  • Location
    United Kingdom
  • Occupation
    Scripting Guru

Recent Profile Visitors

3,151 profile views
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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?
  7. It's likely that the execution of the code is aborted by the Lua interpreter when it wants to store the result of guiCreateStaticImage(0, 0, 1280, 960, ":loginG/imagenes/ap.png", false) into a non-existant table. You need to add the following before any other code you may have: local GUIEditor = {} GUIEditor.staticimage = {} GUIEditor.label = {} GUIEditor.edit = {} GUIEditor.button = {} -- or (simply a matter of preference) local GUIEditor = { staticimage = {}, label = {}, edit = {}, button = {}, }
  8. Line 10 has a typo - it's removeEventHandler not removEventHandler. Besides, that line is unnecessary. The if-line above it already calls that function and its side-effects are executed (i.e. handler gets removed from the function or a false is returned because it's not attached anyway, so calling it again won't work - it'll either be removed or it wasn't attached in the first place)
  9. Is GUIEditor table defined? Are the sub-tables GUIEditor.staticimage, GUIEditor.label, GUIEditor.edit and GUIEditor.button defined? Also please use code tags next time, it's the <> button on the rich text editor toolbar.
  10. You can use a community script to get chat bubbles popping up above players, and (optionally) modify it to stop showing up normal chat messages, and use the exported functions to add bubbles for RP stuff like this /rp command. The command implementation is easy: addCommandHandler("rp", function (player, command, ...) -- first, concatenate all parameters of the command (/command parameter1 parameter2 etc) into one string seperated by spaces local text = table.concat({...}, " ") -- make sure text was actually provided so we don't display an empty bubble if text and #text > 1 then --todo: call an export for a chat bubble to show up -- e.g. exports:bubblechat:outputMessage(player, "* " .. text .. " *") -- the above line should work with https://community.mtasa.com/index.php?p=resources&s=details&id=12008 -- optionally, also display the text in chatbox formatted as follows: asterisk, space, player name, space, action text (e.g. "* Player_1 fastens his seatbelts") outputChatBox("* " .. getPlayerName(player) .. " " .. text, root, 255, 0, 255) end end )
  11. MrTasty

    fetchRemote Help

    You didn't make an attempt based on the advice I gave. Add a remotely triggerable event and handle on the client that applies the texture similar to onClientReLoadImage but without any chatbox outputs and not based on localPlayer's vehicle, but the vehicle you pass as the source parameter. Then, simply trigger that event on the server for all clients with the the vehicle whose texture is being changed as source.
  12. MrTasty

    fetchRemote Help

    C'mon, at least make an attempt yourself and show us the code with your attempted implementation. We're not here to do it for you. I told you what needs to be done, now you can figure out how to do it. You're not gonna learn otherwise. If you're unwilling to learn, perhaps you should hire (and pay) a scripter to do it for you.
  13. addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then startomg_movement() end end) This is my best guess on how to do that, and you already have that in your code. The state "GridCountdown" is apparently the countdown state. The very next state is "Running". Thus, state change from "GridCountdown", or any state tbh, to "Running" should only occur once the countdown is finished. Hence, onRaceStateChanging with new state being "Running" should be triggered just after the countdown ends. Are you sure the code you tested was the one you posted? Perhaps it didn't save and you kept testing some old code?
  14. MrTasty

    fetchRemote Help

    All you have to do is send an event to all clients telling them which texture to use for the shader. See if you can figure out how to do that on your own.
  15. I think you need to read https://wiki.multitheftauto.com/wiki/Scripting_Introduction first, before you can get around trying to "stick" objects to player.