Jump to content

Tails

Members
  • Posts

    731
  • Joined

  • Days Won

    10

Everything posted by Tails

  1. You need to whitelist the domain with requestBrowserDomains https://wiki.multitheftauto.com/wiki/RequestBrowserDomains
  2. Try clearing your cache, if that doesn't help then it's probably a bug in the resource where it sends something to the client only when the resource starts. Your best bet is to contact the author to see if they can fix it.
  3. Tails

    Help, Marker

    You can use getVehicleTowedByVehicle to get the trailer attached to a truck. https://wiki.multitheftauto.com/wiki/GetVehicleTowedByVehicle First create your marker (serverside) local myMarker = createMarker(0, 0, 0, 'cylinder', 1, 255, 0, 0, 150) setElementID(myMarker, 'myMarker') Listen for hit event and check for petrol trailer for example (serverside) addEventHandler('onMarkerHit', myMarker, function(hitElement) if getElementType(hitElement) == 'vehicle' then local driver = getVehicleOccupant(hitElement) if driver then local trailer = getVehicleTowedByVehicle(hitElement) if trailer and getElementModel(trailer) == 584 then outputChatBox('You have a petrol trailer', driver, 0, 255, 0) else outputChatBox('You do not have a petrol trailer.', driver, 255, 0, 0) end end end end) Or listen for key press while inside the marker (clientside) addEventHandler('onClientKey', root, function(key, p) if key == 'e' and p then local vehicle = getElementVehicle(localPlayer) local myMarker = getElementByID('myMarker') if vehicle and isElementWithinColShape(vehicle, getElementColShape(myMarker)) then local trailer = getVehicleTowedByVehicle(vehicle) if trailer and getElementModel(trailer) == 584 then outputChatBox('You have a petrol trailer.', 0, 255, 0) else outputChatBox('You do not have a petrol trailer.', 255, 0, 0) end end end end) Hope this helps!
  4. 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
  5. 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
  6. 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.
  7. Instead of sending a PM, please clarify it here in this thread, so others can help too such as myself.
  8. Make sure you put lang.lua before client.lua in the meta file so it loads first.
  9. 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.
  10. 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.
  11. 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.
  12. 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)
  13. @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.
  14. 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
  15. 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
  16. @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!
  17. Looking really good so far. Is there going to be custom binds?
  18. 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.
  19. @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.
  20. This is no place for a beggar like yourself. I advice you to look somewhere else.
  21. 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.
  22. 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)
  23. 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.
  24. 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)
×
×
  • Create New...