Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. Use the function: getPositionFromElementOffset Which you can find on this page, under examples: https://wiki.multitheftauto.com/wiki/GetElementMatrix That function allows you to get offset positions, no matter what rotation a vehicle has. -- Get the position of a point 1 unit above the element: x,y,z = getPositionFromElementOffset(element,0,0,1)
  2. Did you try to disable your hud resource and reconnect?
  3. In that case you can better use the X and Y position. For example working with chunks, like Minecraft does: local chunkSize = 50 function convertPositionToChunk (x, y) x = x + 3000 y = y + 3000 if x > 0 and x <= 6000 and y > 0 and y <= 6000 then return math.ceil(x / chunkSize), math.ceil(y / chunkSize) end return false -- not in a chunk = out of the map end print(convertPositionToChunk (100, 200)) Or use this to make your 500 colshapes. If you really want to know if it is an issue, then just test with a potato laptop.
  4. If that error shows up, it isn't only Members that is nil, but also the crew (sub-)table. Why don't you use your function? You can never trust data that has been inputted by a user after all. > doesCrewExist(crew)
  5. source is only available for events (functions that are executed when an event is triggered +addEventHandler). So it's value is in this case nil(no value). Use thePlayer instead, since you need a player element for the function 'getPlayerAccount.'
  6. Another problem, which is most likely that the clients haven't download/load the scripts yet, while receiving the avatar. The following code will trigger the onRequestImage event when the client has loaded his resource. Server function ShowImage () local player = client -- ... addEvent("onRequestImage", true) addEventHandler("onRequestImage", resourceRoot, ShowImage, false) Client addEventHandler("onClientResourceStart", resourceRoot, function () triggerServerEvent("onRequestImage", resourceRoot) end, false)
  7. That would be a little bit hard, since the effect is applied globally, so there will always be a little bit desync. But you can make sure the code doesn't do anything when other players are entering vehicles: addEventHandler("onClientVehicleEnter", getRootElement(), function(thePlayer) if thePlayer ~= localPlayer then return end Note: Even if the "onClientVehicleEnter" event is clientside, it does still trigger for remote players.
  8. As alternative: It would be possible to use a render-target in between. Draw the first shader inside of the rendertarget, then apply the render-target on to the second shader and draw that one on to the screen. https://wiki.multitheftauto.com/wiki/DxCreateRenderTarget I am not sure what the impact on the quality as well as the performance will be. Probably not so good for toasters... so stick with 1 shader if you possible can...
  9. This code is executed every frame. I can see that you add some validation checks. But check the execution rate of the following code, if it is too high it will be a much bigger than not playing sounds: As for the not playing sound, you forgot to index the table: themes[math.random(#themes )]
  10. You can also use this useful function: https://wiki.multitheftauto.com/wiki/CheckPassiveTimer Which does more or less the same as AfuSensi his example, after adding the source code.
  11. That question can only be answered if you know why the FPS is dropping. And there are multiple reasons for. A common reason: Execution time exceeds the frame time 1000 / 60 max fps = 16,66666666666667 = frame time local timeNow = getTickCount() for i=1, 10000 do end outputChatBox(getTickCount() - timeNow) -- execution time So even if your computer can run the game at 60 fps, if the execution time takes longer than the frame time the next frame has to wait longer and so your pc will render less frames each second. And how to optimise that? Well, making sure that this does not happen with the total execution time of all render events, as (not so) simple as that. By setting priority for 2 addEventHandlers that are attached to render events, 1 super high priority and 1 super low priority, you probably will be able to calculate the total execution time for that event. addEventHandler( "onClientRender", root, ..., false, "high+1000" ) addEventHandler( "onClientRender", root, ..., false, "low-1000" )
  12. You will also need to separate clientside from serverside. Red coloured functions are clientside. Orange coloured functions are serverside and blue can be used for both.
  13. Export functions must be a global, so that whole concept will probably not work. Here was a similar quest asked, with 2 possible solutions when you want to re-use the same function name.
  14. If that resource name is not allowed, then what is the resource name now?
  15. These brackets are used for hidden folders: [hidden folder] The resource name is the folder that contains DIRECTLY the meta.xml.
  16. @Argom These are more or less the basic components for a not moving image, which can be enhanced with a moving image later on. (order matters): https://wiki.multitheftauto.com/wiki/DxCreateTexture function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end <function start> https://wiki.multitheftauto.com/wiki/GetLocalPlayer https://wiki.multitheftauto.com/wiki/GetPedOccupiedVehicle https://wiki.multitheftauto.com/wiki/GetElementMatrix x1, y1, z1 = getPositionFromElementOffset(vehicle, 0, 0, 0) x2, y2, z2 = getPositionFromElementOffset(vehicle, 3, 0, 0) https://wiki.multitheftauto.com/wiki/DxDrawMaterialLine3D <function end> https://wiki.multitheftauto.com/wiki/OnClientPreRender
  17. If you want to create environments, OOP would be another way and maybe also use a meta table to inherit properties But I can understand that it might be a little bit complex, especially when you are doing it like this: showContentConstructor = { new = function (self) local newShowContent = {} setmetatable(newShowContent, self.metaTable) return newShowContent end, prototype = { -- initial properties text = "<please set text>", sayHI = function (self) return outputChatBox(self.text) end } } -- Set the meta table as lookup table when the information is not found in the instance table showContentConstructor.metaTable = {__index = showContentConstructor.prototype} -- create new instances showContent1 = showContentConstructor:new() showContent2 = showContentConstructor:new() showContent1:sayHI() showContent1.text = "test1" showContent1:sayHI() showContent2:sayHI() showContent2.text = "test2" showContent2:sayHI() Unfortunately there are no options without tables afaik, so you really need to be able to understand the basics of tables, if you want to build this. So I recommend doing it the way as in my previous reply, which should be easy to do.
  18. A function name is just a variable. When creating a function with the same name, you will overwrite that variable/function. You can solve your problem with a table. Main file: showContent = {} setTimer(function () -- add a little delay so that the function can be added before calling it. showContent[1]() showContent[2]() showContent[3]() end, 100, 1) For each other file: local fileID = --[[...]] showContent[fileID] = function () sayHI() end
  19. You can't give a player to another player. givePlayerMoney ( killer, source ) Some extra validation might be required, not only a player can kill another player. if ( killer ) and ( killer ~= source ) and getElementType(killer) == "player" and money > 0 then givePlayerMoney ( killer, money ) end
  20. If that is the case, then your code didn't wait for the 2 events per model (txd + dff). That is the moment you can apply the model, not a millisecond before that.
  21. Here: addEventHandler("onClientResourceStart", resourceRoot, function ( ) setTimer ( function ( ) refreshList ( ) local file = xmlLoadFile ( '@saving.xml', 'data' ) if file then for i, v in ipairs ( xmlNodeGetChildren( file ) ) do local name = tostring( xmlNodeGetAttribute( v, 'name' ) ) local enabled = toboolean( xmlNodeGetAttribute( v, 'enabled' ) ) if ( getModData(name) and tostring( enabled ):lower ( ) ~= "false" ) then --[[ here ]] end end end end, 500, 1 ) end ) (download + register the name) local immediatelyLoading = {} -- -- onClientResourceStart -- local _, _, dff, txd = getModData(name) dff = 'modlar/' .. dff txd = 'modlar/' .. txd -- set up status local loadingStatus = { value = 2, name = name, dff = dff, txd = txd } -- set up reference to status immediatelyLoading[dff] = loadingStatus immediatelyLoading[txd] = loadingStatus -- -- onClientFileDownloadComplete -- local loadingStatus = immediatelyLoading[file] local value = loadingStatus.value value = value - 1 loadingStatus.value = value if value == 0 then immediatelyLoading[loadingStatus.dff] = nil -- clear immediatelyLoading[loadingStatus.txd] = nil -- clear local name = immediatelyLoading.name -- load model end And also here: function onDownloadFinish (file, success) if ( source == resourceRoot ) then if ( success ) then refreshList() new("Your mod has been successfully downloaded ("..tostring(file)..")", 0, 255, 0) end end end addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish ) Using registration to load the mod immediately when both files are downloaded.
  22. Because the files haven't been validated. Use the downloadFile function again to validate if the correct files are placed on the client his pc. Note: If the correct file is found, no re-download will be starting. After the event onClientDownloadComplete, for dff and txd you can start the replacement process.
  23. Very cool!
  24. dbQuery is used for retrieving information from the database. Even if you are only inserting data, there is still information returned about the success/failure state. dbPoll is used to collect that information (from the queryHandle). Since you didn't use that function on the queryHandle = the variable you named `zapisz` , there was no attempt to collect that information, so it was still waiting to be collected and therefore it gave you that warning. If you do not think you need that information, you can better use dbExec. That is just a one-way trip.
  25. Should be fine. As long as you do not over do it. Note: The position X and Y can also be used for the weather.
×
×
  • Create New...