Jump to content

IIYAMA

Moderators
  • Posts

    6,089
  • Joined

  • Last visited

  • Days Won

    216

Everything posted by IIYAMA

  1. Serverside scripts right? You can use loadstring, but I recommend you to splits the scripts from the maps. Otherwise you probably have to edit the scripts. Because the event "onResourceStart" doesn't get triggered when you start a script with loadstring. Just start them with: https://wiki.multitheftauto.com/wiki/StartResource And add in the meta of the maps: <include resource="theResourceName" /> Which also gives you the benefit that you can also load client files easy. Or you use my map loader for that: https://community.multitheftauto.com/in ... s&id=12068 Documentation: https://forum.multitheftauto.com/viewtopic.php?f=108&t=92549
  2. They both create the same type of elements. The only difference is that they use a different (middle) parent element. See here more information about those middle parents: https://wiki.multitheftauto.com/wiki/Element_tree
  3. .map vs createObject There is a difference between loading speed. Because for loading a map file there is only 1 MTA function needed(or none when it is included in the meta.xml). When using createObject you have to execute that per object and you have to use other functions to add properties. Map files will be loading directly with the C++ functions which are intern. When using MTA functions, they will call those functions external. Which is slower.
  4. IIYAMA

    ammo limit

    This function will make it a lot easier: local weapon = getPedWeapon(player,index)-- index = slot https://wiki.multitheftauto.com/wiki/GetPedWeapon New structure: [1] = {2,[color=#FF0000]{[22]=true,[23]=true,[24]=true}[/color],tonumber (get ("Handgun Limit"))}, local isWeaponLimited = value[2][weapon] -- true/nil if isWeaponLimited then Line 17 isn't required. if getPedTotalAmmo(v,value[1]) ~= value[3] then Put the timer on 500 ms, the result of getPedTotalAmmo only changes after the clients are sync their ammo back. This event isn't required to be bounded on a function that is for all players. addEventHandler ("onPlayerWeaponSwitch",root,weaponLimit)
  5. Fixed it! imageFileData = string.gsub(imageFileData,'\n', "") I had to remove the line breaks, now it works like charm! And thx for the reply Dealman! This is the circa the result: In illustrator Ingame Not original scale X and Y.
  6. Hmmm that is a good one. I tried it, but as result the quotes are misplaced. In the decoded string there are also quotes. Probably the reason why they use base64. The browser will also think: "Wtf, I can't decode a decoded image."
  7. With the function: https://wiki.multitheftauto.com/wiki/GetZoneName This function can check which area is what. You have to to write a system that gives you the positions and size by yourself.
  8. I am trying to read the svg file images and write them to temporary files. But it looks like the format isn't correct decoded and the temporary files don't work. local image = attributes["xlink:href"] if image then --data:image/png;base64, local _,stringMiddle = string.find(image,"base64,") if stringMiddle then local stringEnd = string.len(image) local imageInfo = string.sub(image, 0, stringMiddle) local imageFileData = string.sub(image, stringMiddle+1, stringEnd) if imageFileData then -- remove spaces etc. --------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------- imageFileData = string.gsub(imageFileData,'\\r', "\r") imageFileData = string.gsub(imageFileData,'\\n', "\n") -- from [url=http://stackoverflow.com/questions/23488404/decode-base64-string-and-write-to-file]http://stackoverflow.com/questions/2348 ... te-to-file[/url] -- --------------------------------------------------------------------------------------------- ----------------------------- imageFileData = base64Decode(imageFileData) if imageFileData and imageFileData ~= "" then local file = fileCreate("tempFolder/tempolaryImage.png") if file then fileWrite(file, imageFileData) fileClose(file) if fileExists("tempFolder/tempolaryImage.png") then outputChatBox("yea") local texture = dxCreateTexture ( "tempFolder/tempolaryImage.png") if texture then outputChatBox("texture was a success!") else outputChatBox("texture failed!") end --fileDelete("tempFolder/tempolaryImage.png") -- delete ones readed. end end else outputChatBox("imageFileData failed!") end end end end The file I am decoding looks like this: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB28AAAOsCAIAAADiCGozAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ bWFnZVJlYWR5ccllPAACPgVJREFUeNrs3QlcFOX/B/ARFhcBueQQREEUVBBCQBRRVARvkET5eSTl RWVFSaXkffZDf6mlpYlp/zDJ8ML7WlEpxBARQUhQVxAUQW4FQRb8z7G77C6zB5fn5/16lcvMM881 szOz3332mXb+/v5lZWXEC6Gvr//CynrjoTOb4fHjx+gEAAAAAAAAAACA5uEQLyrElp+f7+bmhnAe OvMldpqZmRn6AQAAAAAAAAAAoHnU0AUAAAAAAAAAAAAAoBSiyQAAAAAAAAAAAACgHEf1pLa2tlOm [b]etc. etc. etc.[/b] EwqFQjDqdPJpZnV4uEK6EB4u5+l1Wq18vthr9FgP6aLQcvmotlq6GRIT5TymOajEd0jLuXrfybGx sY+MH9JUmb/6lRxLKlrpI17+4vv3z5TuTB3dcvFQ1qr/PNjxWIzFrye8sPVss/lCbe5rq/Mrm32n WoJ8cfm61xDe1QAAAABu3f8XYACcGqtfVbrzzAAAAABJRU5ErkJggg==
  9. https://wiki.multitheftauto.com/wiki/GetRadarAreaSize
  10. My Facebook account is not for MTA, but you can pm me your skype name instead.
  11. wait for 1.6... or use 1.6 beta. 1.6 will enable functions to control that. I have the same problem with: https://forum.multitheftauto.com/viewtopic.php?f ... ain+script
  12. Why don't you ask him directly? You don't need us for this. Bonsai
  13. ah I miss read, it was already called. And it did already work. function getResult () if getElementData(localPlayer,"calculator") == true then local dataText = getElementData(localPlayer,"calculatorText") local result = loadstring ( "return "..dataText ) if result then local theNumber = result() if theNumber then setElementData(localPlayer,"calculatorText",theNumber) else setElementData(localPlayer,"calculatorText","Error") end end end end bindKey("num_enter","down",getResult)
  14. local theSum = "1+3" local result = loadstring ( "return "..theSum )(); local theNumber = result() -- call
  15. The result of loadstring must be called.
  16. There are a lot of ways to do this. local a,b = string.match("1+3","(%d+)+(%d+)") outputChatBox(tonumber(a)+tonumber(b))
  17. local result = tonumber(getElementData (source,dataName)) if result then
  18. Use both. But I do not understand how you get this problem in the first place. That bindKey scenario is very unclear because it is incomplete for me as reader. In my damage over write script I am working around it, by calculating the damage of explosions serverside. And sync the effects with triggerLatentClientEvent > client createExplosion(damaging = false).
  19. When you set the maxVelocity it doesn't mean it will actually reach it. That has to do with the acceleration, wheel grip and probably the amount of weight too. The property maxVelocity is for downgrading your vehicle speed. A kind of limiter.
  20. hmm, didn't know that because I never used it. if meta and next(meta) then textWidth = dxGetTextWidth(meta.stream_title or "", 1, "default-bold")
  21. 2 reasons why this error shows up. The meta data isn't downloaded yet from the streamed song. You have to keep in mind that the meta isn't directly available. The first part of the song have to be downloaded before it will shows up, while the lua code doesn't wait for it. The song doesn't have a title. Can be simply solved with: if meta then -- check if there is a meta available. textWidth = dxGetTextWidth(meta.stream_title or "", 1, "default-bold")
  22. I still do not recommend you to do it that way. (with streamed in/out) But make sure you freeze the player position when they spawn, till the process has been finished.
  23. Using onClientElementStreamIn, will not give you the result you want. And you have to uses the slow loading function for loading the objects. What you want is assigning elements to a 2D grid of X(300) units. local gridHolder = {} local gridSize = 300 local objects = getElementsByType("object") for i=1,#objects do local object = objects[i] local x,y,z = getElementPosition(object) local gridX = math.floor((x/gridSize)+0.5) local gridY = math.floor((y/gridSize)+0.5) local gridDataX = gridHolder[gridX] if not gridDataX then gridHolder[gridX] = {} gridDataX = gridHolder[gridX] end local gridDataY = gridDataX[gridY] if not gridDataY then gridDataY[gridY] = {} gridDataY = gridDataX[gridY] end gridDataY[#gridDataY+1] = getElementModel(object) end local gridsAroundPlayer = { {0,0},--center {0,-1},-- top {1,-1},-- right/top {1,0},-- right {1,1},-- right/bottom {0,1},-- bottom {-1,1},-- left/bottom {-1,0},-- left {-1,-1}-- left/top } local loadedIds = {} local loadedGrids = {} local nextGridUpdate = 0 addEventHandler("onClientRender",root, function () local timeNow = getTickCount() if timeNow > nextGridUpdate then nextGridUpdate = timeNow+300 local playerX,playerY,playerZ = getElementPosition(localPlayer) local gridX = math.floor((playerX/gridSize)+0.5) local gridY = math.floor((playerY/gridSize)+0.5) local newLoadedIds = {} local loadingGridsNew = {} for j=1,#gridsAroundPlayer do local offSet = gridsAroundPlayer[j] local gridX = gridX + offSet[1] local gridY = gridY + offSet[2] if not loadedGrids[gridX.."/".. gridY] then local gridDataX = gridHolder[gridX] if gridDataX then local gridDataY = gridDataX[gridY] if gridDataY then -- -- gridDataY, -- store every id inside: newLoadedIds[id] -- loadedIds[id] < make sure that id isn't placed in this variable. -- load mods on id... loadingGridsNew[gridX.."/".. gridY] = true end end end end for key, data in pairs(loadedGrids) do if not loadingGridsNew[key] then local gridDataX = gridHolder[gridX] if gridDataX then local gridDataY = gridDataX[gridY] if gridDataY then -- gridDataY, -- newLoadedIds < make sure the id isn't in this table. -- unload mods from id end end end end loadedGrids = loadingGridsNew loadedIds = newLoadedIds end end) This is not tested.
×
×
  • Create New...