Jump to content


  • Posts

  • Joined

  • Days Won


Everything posted by Tails

  1. Hi, there are already scripts that do this. Here's a couple: Zday by Dutchman101 Slothbot: https://community.multitheftauto.com/index.php?p=resources&s=details&id=672
  2. Hotfix has been uploaded! New bugs may be introduced with this version, however, playing videos should work again for the most part. Consider this is a temporary fix until we find a new and better solution. I also replaced the switch browser button with a Skip Ads button. This is basically a refresh button which will help you skip ads. Download the latest version here: https://community.multitheftauto.com/index.php?p=resources&s=details&id=12950
  3. We're currently looking at solutions right now. We may just have to use the default youtube page now and crop the image a bit. There are some issues though with popups and ads covering the video, but we could put the screen browser in the panel so you can interact with it and remove any popups shown or skip ads. Stay tuned.
  4. Instead of sending a PM, please clarify it here in this thread, so others can help too such as myself.
  5. Make sure you put lang.lua before client.lua in the meta file so it loads first.
  6. You can use table.sort for sorting, but first you have to extract the data you want from the table and place it in another to make it iterable. For instance: local sorted = {} for itemId, itemData in pairs(myItems) do table.insert(sorted, itemId) -- extract item ids end -- sort the items table.sort(sorted, function(a, b) return a < b end) iprint(sorted) You can also sort it by the item count local sorted = {} for itemId, itemData in pairs(myItems) do table.insert(sorted, itemData) -- extract the item data instead end table.sort(sorted, function(a, b) return a.count < b.count end) As you can see you can extract any data from your tables and sort them however you like.
  7. Don't use metatables just for simple table lookups, that's only asking for problems and will decrease performance. In your case (response to original post) an int loop would be faster: for i=1, #playerTable.playerItems do local v = playerTable.playerItems[i] outputChatBox("item: "..v[1]..", count: "..v[2]) -- item: Item, count: 1 end However I can imagine that with a list of 1000's of items you wouldn't really want to loop this table over and over. What you're doing is, you're inserting a new table for every item and there isn't really any way to get the "Item" from the table with a single lookup other than looping the entire thing. What you could do is change the structure of the table to something like this: -- a fixed table that contains all the item ids and information local items = { ['apple'] = {desc = 'A green apple', name = 'apple'} -- an item with id 'apple' } local myItems = { ['apple'] = {count = 10}, -- player has an item with id 'apple' and has 10 of them } Now you'd still have to loop it if you wanted to get all the items at once but if you want to get the count of a specific item you can access it according to the item id. -- say you know the item id, all you do is local item = myItems['apple'] if item then print(item.count) end -- for instance function takeItem(id, count) local item = myItems[id] if item then if item.count >= count then item.count = item.count - count end end end -- if you want to get all then you loop it for id, item in pairs(myItems) do print('ID:', id, 'Count:', item.count, 'Description:', items[id].desc) end Notice you don't have to loop it in the takeItem function which will help with performance. So instead of table.insert you keep a key table where the id's are fixed and don't change so that you can access them by their key/id. Hope this helps.
  8. Tails

    Expected account

    @1LoL1 cause getAccountPlayer expects an 'account' element but getAccount returns false cause it didn't find the account. All you need to do is add a check, for example: if account then -- continue here end Next time you use a function check the wiki page for it, it explains exactly what it will return and what it returns in case there's a mistake. In your case it didn't find the account so it returned false. Hope this helps.
  9. Or listen for the resourceBlocked event and request each blocked domain to be unblocked. addEventHandler('onClientBrowserResourceBlocked', browser, function(url) requestBrowserDomains({url}, true, function(accepted) if accepted then reloadBrowserPage(browser) end end) end)
  10. @Sorata_Kanda you can't pass any sort of functions or metatables unfortunately. However as IIYAMA said you can use loadstring to inject code into your scripts. I wrote this a while back: function load() return [[ function import(name) if type(name) ~= 'string' then error("bad arg #1 to 'import' (string expected)", 3) end local content = exports.import:getFileContents(name) if not content then error("can't import '"..name.."' (doesn't exist)", 2) end return loadstring('return function() '..content..' end')()() end ]] end function getFileContents(name) if not name then return end local path = 'exports/'..name..'.lua' if fileExists(path) then local f = fileOpen(path) local content = f:read(f.size) f:close() return content end return false end If you put this in a resource called "import" then you'd use it like this: loadstring(import.exports:load())() local utils = import('utils') iprint(utils) This loads files directly into a variable in your script. Ofcourse you can easily modify this to load files from different resources. Also in said files you will have to return the class or function or whatever you need to return just like real modules.
  11. not supported, however you can do this... local link = "https://media.rockstargames.com/rockstargames-newsite/img/global/downloads/buddyiconsconavatars/sanandreas_truth_256x256.jpg" local pix requestBrowserDomains({link}, true, function(accepted) if not accepted then return end fetchRemote(link, function(data, err) if err > 0 then error('Error: ', err) end pix = dxCreateTexture(data) end) end) function teste() if pix then dxDrawImage(0, 0, 256, 256, pix, 0, 0, 0, tocolor(255, 255, 255, 255), false) end end addEventHandler("onClientRender", root, teste) I didn't test it but it should work
  12. I found both movement and camera speed to be really slow, especially the camera. It takes 3-4 seconds for me to rotate the camera 360 degrees, unless I crank up the dpi on my mouse, which I rarely do. There should be an option to change the camera speed. Here's what the UI looks like: https://imgur.com/a/hcKVmV0
  13. @CodyJ(L) I tested the editor out yesterday and I know it's just alpha but I had a hard time understanding the UI and the controls. First thing I noticed when I opened up the editor was the UI. The UI is really small on 1080p and the menu's are also way too small. Second, it took me a while to figure out how to toggle the mouse and camera mode, almost up to the point where it irritated me. I expected it to be in camera mode right off the bat. Neither mouse or camera mode were toggled. When I was finally in camera mode, I could barely move my camera around because it's set to really slow by default. Also the camera overall behaved a bit strange imo. Finally, I decided I would place some objects, so I looked for the object list. Again, the UI is small and the lists are really tiny so it's hard to navigate in. I tried selecting and double clicking the items in the list but nothing would happen. At this point I had no idea what to do.I tried for a few more minutes but I just couldn't figure out how to place objects. When the beta gets released I will give it another try. Hopefully things will be better then. Good luck!
  14. Looking really good so far. Is there going to be custom binds?
  15. Are you supplying the video file through the resource meta? if so, you don't have to worry about it. the resource will only start once the download has finished. Otherwise if the browser is not a local browser then there's no way to know if something has finished downloading.
  16. @sanyisasha, check out bakagaijin: http://anirudh.katoch.me/project/bakagaijin/ I think this is as close you will get to interacting with other scripts in an object oriented way. I've used it before in one of my projects and it worked pretty well.
  17. This is no place for a beggar like yourself. I advice you to look somewhere else.
  18. Very nice Loki! Hopefully this will help out everyone who needs help setting this whole thing up. It's not an easy thing to do if you're completely new to all of this.
  19. You need to make a separate LOD object for every object. https://wiki.multitheftauto.com/wiki/SetLowLODElement Here's an example: local obj = createObject(id, x, y, z, rx, ry, rz) local lodObj = createObject(id, x, y, z, rx, ry, rz, true) setLowLODElement(obj, lodObj) engineSetModelLODDistance(id, 300)
  20. Use https://wiki.multitheftauto.com/wiki/OnClientGUIChanged it will trigger whenever someone is typing in an editbox. If you want to constantly check if someone is typing then use the focus and blur events like MIKI suggested.
  21. When a client triggers a server event a hidden variable called 'client' is passed in the event. triggerServerEvent("blabla", bla) -- server addEvent('blabla', true) addEventHandler('blabla', resourceRoot, function(bla) print(bla, getPlayerName(client)) end)
  22. @SSKE The scrollbar is part of the gridlist, it shows up when there are more items than can be shown.
  23. http://static.cegui.org.uk/static/WindowsLookProperties.html#ForceVertScrollbar guiSetProperty(gridlist, 'ForceVertScrollbar', 'False') I think that should do it.
  24. You can use render targets perfectly fine. They aren't rendered to the screen they are rendered to a new texture at run time. The image is the only thing that's being drawn to the screen. So, you could have a 100 draw functions and render it to a single texture and only draw that texture to the screen with dxDrawImage. The reason your text became blurry with render targets is because you were either stretching the image or the positions/dimensions were off. Take this simple object oriented approach and you'll have an easy to use function. It works similar to the CEGUI functions except that you're responsible for drawing it, although you could make the function handle that as well. function dxCreateFramedText(text, left, top, width, height, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) local self = {} local rt = dxCreateRenderTarget(width, height, true) self.draw = function(x, y, w, h) dxDrawImage(left, top, width, height, rt) end self.update = function() dxSetRenderTarget(rt, true) dxDrawText(text, 1, 1, width + 1, height + 1, tocolor(0, 0, 0), scale, font, alignX, alignY, clip, wordBreak, postGUI) dxDrawText(text, 1, -1, width + 1, height - 1, tocolor(0, 0, 0), scale, font, alignX, alignY, clip, wordBreak, postGUI) dxDrawText(text, -1, 1, width - 1, height + 1, tocolor(0, 0, 0), scale, font, alignX, alignY, clip, wordBreak, postGUI) dxDrawText(text, 1, 1, width - 1, height - 1, tocolor(0, 0, 0), scale, font, alignX, alignY, clip, wordBreak, postGUI) dxDrawText(text, 0, 0, width, height, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) dxSetRenderTarget() end self.setText = function(v) text = v self.update() end self.setColor = function(v) color = v self.update() end self.update() return self end local msg1 = dxCreateFramedText("Hello there",222,300,520,140,tocolor(0,255,0),3,'default','left','top',false,false,false) local msg2 = dxCreateFramedText("How are you?",222,400,520,140,tocolor(0,255,0),3,'default','left','top',false,false,false) addEventHandler('onClientRender', root, function() msg1.draw() msg2.draw() end) msg2.setColor(tocolor(0,255,255)) addCommandHandler('c', function() msg1.setColor(tocolor(255,99,0)) end) It may look a little over the top but yeah, it works, and it's fast.
  • Create New...