Jump to content

IIYAMA

Moderators
  • Posts

    6,062
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. How about you start with using the code I gave you? And change it to something that could work for you? -- test data local weapon = 31 local ammo = 3000 --- local item1 = {type = "weapon" , weapon = weapon, ammo = ammo} saveItemInVehicleTrunk (vehicle, item1) local item2 = {type = "weapon" , weapon = 38, ammo = 9999} -- minigun saveItemInVehicleTrunk (vehicle, item2) local items = getItemsInVehicleTrunk (vehicle) for i=1, #items do local item = items[i] if item.type == "weapon" then iprint("weapon id:", item.weapon, ", ammo:", item.ammo) end end
  2. 1. You can get the colshape of a marker. https://wiki.multitheftauto.com/wiki/GetElementColShape 2. Get the elements of a specific type and check if there are none. https://wiki.multitheftauto.com/wiki/GetElementsWithinColShape local colshape = getElementColShape ( marker ) local players = getElementsWithinColShape ( colshape, "player" ) local vehicles = getElementsWithinColShape ( colshape, "vehicle" ) if #vehicles == 0 and #players == 0 then end Note: you might also need to check if the elements are not in the same dimension + interior, if you make use of those.
  3. Where in the script are you storing the weapons in the vehicle?
  4. IIYAMA

    Discord Python

    It is a php interface from MTA. It can help you to make an access point for (local) http requests. If you want to communicate with MTA, the http protocol is more or less your only option. If you think this is confusing, then please read: https://www.geeksforgeeks.org/get-post-requests-using-python/ It explains you a little bit about http and how to use that in python. Not familiar with the php language on the MTA side of things? There are multiple sockets available, just not specific python. https://wiki.multitheftauto.com/wiki/Resource_Web_Access This is what you are going to need at the end: MTA < SOCKET < (protocol http) < Python
  5. One thing you might have to take in to consideration is that the resource might take too long to save a large buffer. Especially when onResourceStop is triggered. The resource wants to stop, but it can't because too much is going on. Don't end up with a too large buffer, because the server might want to kill the resource process. (warning: resource xxx takes too long to stop...) Shouldn't be required > Just to be safe, add a flush feature which will write the buffer in to the db, which you can use before making a attempt to stop the resource. Then you are at least prepared for...
  6. Sure there is any chance of fail. For example an application or server crash. But atleast you know that it didn't happen because your database was too busy writing every single update to the storage.
  7. Serverside is running on the server. Application (in case of a local server): Program Files (x86)\MTA San Andreas 1.5\server Clientside is running on clients/players. Application: Program Files (x86)\MTA San Andreas 1.5\Multi Theft Auto.exe Those are two very different applications. And between those two applications there is something called ping, = connection delay. Even a local server has a little bit of ping, even though it is displayed as 0. Your code does not wait for ping, it just runs until it finished all the instructions you gave it. If you want to let those two sides communicate with each other you need to use triggerEvent. See examples on these pages: From clientside to serverside: (examples included) https://wiki.multitheftauto.com/wiki/TriggerServerEvent From serverside to clientside: (examples included) https://wiki.multitheftauto.com/wiki/TriggerClientEvent Enchantment You can also use an enchantment, which I created for people that have trouble with communication between serverside and clientside. Installation Clientside addEventHandler("onClientResourceStart", resourceRoot, function () callServer( "getTitlesTable", function (TitlesTable_) -- < This is the callback function TitlesTable = TitlesTable_ end ) end) Clientside if TitlesTable then for i, k in ipairs(TitlesTable) do dxDrawRelativeRectangle(598, 219+i*30, 296, 30, isMouseInPosition((598/resolutionX )*sWidth,((219+i*30)/resolutionY )*sHeight, (219/resolutionX )*sWidth, (32/resolutionY )*sHeight) and tocolor(255, 255, 255, 158) or tocolor(0, 0, 0, 158)) dxDrawRelativeText(k[1], 701, 200+i*30, 785+40, 239+(i+1)*30, tocolor(255, 255, 255, 255), 0.40, dxfont5_bebas_font, "left", "center") end end Serverside - no changes - Documentation can be found here.
  8. How about you save it first inside of your memory? You can always upgrade it to SQL/MySQL later. Start with something as simple as this. local vehicleTrunkItems = {} function saveItemInVehicleTrunk (vehicle, item) local trunk = vehicleTrunkItems[vehicle] if not trunk then trunk = {} vehicleTrunkItems[vehicle] = trunk end trunk[#trunk + 1] = item end function getItemsInVehicleTrunk (vehicle) return vehicleTrunkItems[vehicle] or false end Define all functions you need, till it more or less works as you want.
  9. IIYAMA

    table problem

    You can also attach the eventHandler to the parent GUI, if you have at least one GUI parent. local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "window", true ) local button = {} function click () if source ~= myWindow then if source == button[1] then elseif source == button[2] then end end end button[1] = guiCreateButton( 0.3, 0.1, 0.2, 0.1, "button 1!", true, myWindow ) -- 1 button[2] = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "button 2!", true, myWindow ) -- 2 addEventHandler("onClientGUIClick", myWindow, click, true) -- true = propagation enabled
  10. For both resources. A https://wiki.multitheftauto.com/wiki/TriggerEvent Set the base element to resourceRoot. B https://wiki.multitheftauto.com/wiki/AddEventHandler Set the attachedTo element to resourceRoot as well. And they will not interfere with each other, even when the event name is the same.
  11. Are we talking about 1 resource or multiple ones? Because resource A can't disable the cursor for resource B. GUI's do not have any influence on the cursor function.
  12. No, only serverside with: https://wiki.multitheftauto.com/wiki/OnPlayerDamage Or clientside with: https://wiki.multitheftauto.com/wiki/OnClientPlayerDamage Or https://wiki.multitheftauto.com/wiki/OnClientPlayerWeaponFire + https://wiki.multitheftauto.com/wiki/ProcessLineOfSight
  13. The very reason for the error is unclear. Because the issue is happening somewhere else. This is how you can get rid of the error, for this function only. function destroyLine ( line ) if contentMessages[line] then -- is there a `line` to destroy? for k,part in ipairs(contentMessages[line]) do destroyWidget(part) end contentMessages[line] = {} return true -- success < not required, but it might help you in the future solve the real issue. end return false -- something is wrong? end
  14. You can use teaEncode, there are a wide range of plug-ins available for your web applications to decode it. Another option is for you to send it (internal) to a node application and transfer it from there across https.
  15. That is not why I recommend using the browser. Sure a linter can tell you if it is broken or not. But it doesn't tell you anything about the object types. Breaking your JSON is annoying, but that doesn't happen as often as having your format being ruined by accidentally creating a mixed table. Your browser will tell you for each object if you are dealing with an array or an object. When it is ruined, you are not being able access your arrays formats as easy any more. Those must be strictly maintained. _________________________ About your main issue. How about you write a validator? validator = { { key = "money", func = function (value) return type(value) == "number" end }, { key = "name", func = function (value) return type(value) == "string" end }, }
  16. @Nickqq Line 14, might show a warning every frame. It also has no purpose, so feel free to remove it. Can you show me the debugconsole?
  17. @KiritoAguiar I moved your post. > https://forum.multitheftauto.com/forum/127-programação-em-Lua/
  18. IIYAMA

    Ban player

    @slapz0r local serial = getAccountSerial ( account ) if serial then addBan (nil, nil, serial) end
  19. 1. Open your browser. 2. Right-mouse button > inspector 3. Go to the console tab. 4. Copy the JSON.parse method. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse 5. Place your json string as an argument. JSON.parse("the string") 6. Copy and past the code in to the console and run it. You have now loaded your JSON to it's origin. Or rather live version of it. Now you can inspect.
  20. Afaik I said in my pm's that you have to use the MTA function. https://wiki.multitheftauto.com/wiki/DxDrawCircle And now you are still asking for help for a shader which you do not understand at all? + keep bumping, which I have warned you already for. If you want people their attention, then atleast write a message with some useful content.
  21. Hovering is probably not possible. But you can get from each object it's texture names, based on the model id. https://wiki.multitheftauto.com/wiki/EngineGetModelTextureNames Or on screen: (+ filter option based on model id) https://wiki.multitheftauto.com/wiki/EngineGetVisibleTextureNames
  22. It is indeed a little bit strange. But on the other side, it does provide a way to optimise access for variables manually. It is just a pity that it can't optimise itself based on patterns of variable requests.
  23. Yes, I can understand that. But it is not ethical for MTA to implement such a privacy sensitive feature, so I doubt they will add something like that.
  24. That is more or less a privacy breach.
  25. local messages = { en = { ["welcome"] = "Hi" }, nl = { ["welcome"] = "hoi" } } function getMessageTextById(id, language) return messages[language] and messages[language][id] or messages["eng"][id] or "" end How about you create a global language system? @slapz0r iprint(getMessageTextById("welcome", "nl"))
×
×
  • Create New...