-
Posts
636 -
Joined
-
Days Won
8
Everything posted by ds1-e
-
Sorry, forget to add it to code, i did not slept today. [2019-02-24 11:01:00] WARNING: bw\blackwhite.lua:10: blackwhite.fx(16,12): error X3014: incorrect number of arguments to numeric-type constructor @ 'dxCreateShader' [fx/blackwhite.fx]
-
local screenX, screenY = guiGetScreenSize() local screenSource = dxCreateScreenSource(screenX, screenY) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() if getVersion ().sortable < "1.1.0" then outputChatBox("Resource is not compatible with this client.") return else blackWhiteShader, blackWhiteTec = dxCreateShader("fx/blackwhite.fx") if (not blackWhiteShader) then outputChatBox("Could not create shader. Please use debugscript 3.") else outputChatBox("shader " .. blackWhiteTec .. " was started.") end end end) addEventHandler("onClientPreRender", getRootElement(), function() if (blackWhiteShader) then dxUpdateScreenSource(screenSource) dxSetShaderValue(blackWhiteShader, "screenSource", screenSource) dxSetShaderValue(blackWhiteShader, "fIntesity", 128/255) dxDrawImage(0, 0, screenX, screenY, blackWhiteShader) end end) Thanks for answer, after doing changes, it shows an error.
-
Hey, as title says. How can i add possibility to change color intensity manual? To make it darker or brighter. // // blackwhite.fx // texture screenSource; sampler TextureSampler = sampler_state { Texture = <screenSource>; }; float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { float4 color = tex2D(TextureSampler, TextureCoordinate); float value = (color.r + color.g + color.b) / 3; color.r = value; color.g = value; color.b = value; return color; } technique BlackAndWhite { pass Pass1 { PixelShader = compile ps_2_0 PixelShaderFunction(); } }
-
No, you can disable synchronization whenever you setElementData. Anyway i had bad experience with elementData's, with same count of players. That's why i'm gonna test custom system for it. I don't think so that disabling fourth argument will help so much. https://wiki.multitheftauto.com/wiki/SetElementData bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] )
-
You can use tables as fast-temporary-storage, i will test soon custom temporary data system, thanks to help from MTA forums. (Check topics which i have created, related to them.) You can read about it here, it's simple, i already learned how to use it. Of course you don't need to use tables everywhere, you can setElementData, only when is important and needed, that's what i learned.
-
Most likely it's fault of scripts, thanks to IIYAMA i got some information about that. There can be plenty of reasons: - badly optimized scripts - too much elementData's (if you don't turn off synchronization, it synchronize with every player and also server), more players = more server resources usage. - high-res models/a lot of objects, or players in one place. - weapon sounds. - things which are drawing frequently on player screen (OnClientRender) I suggest you to check which resource, and what exactly is making big traffic/takes a lot of % of CPU. You will need a resource called 'ipb' which you should have within base server resources. Type start ipb in console, and then, once again type ipb. After that you will have possibility to check which resources are using a lot of CPU/server resources. If i am wrong, i bet IIYAMA, or someone else will correct me.
-
Hi. As title says how i can do bounce player or player + his car backward when player hitcolshape? So i can avoid him to go through colshape.
-
And this one is pairs it is? I mean the way to use loop in following code: function unglueOnExplosion() local attached = getAttachedElements(source) for i = 1, #attached do if getElementType(attached[i]) == "player" then triggerEvent("ungluePlayer", attached[i]) end end end addEventHandler("onVehicleExplode", getRootElement(), unglueOnExplosion) So i should use: for i = 1, #table do Whenever it's possible? And by the way, can you guys help me with this? I am writing handlings script and i encountered a problem, i don't know how i should apply loop for it. So, basically i have 2 tables with data, first contains a string for vehicle handling, and second table contains value for this. local valueNames = { "mass", "turnMass", "dragCoeff", "centerOfMass", "percentSubmerged", "tractionMultiplier", "tractionLoss", "tractionBias", "numberOfGears", "maxVelocity", "engineAcceleration", "engineInertia", "driveType", "engineType", "brakeDeceleration", "brakeBias", "ABS", "steeringLock", "suspensionForceLevel", "suspensionDamping", "suspensionHighSpeedDamping", "suspensionUpperLimit", "suspensionLowerLimit", "suspensionFrontRearBias", "suspensionAntiDiveMultiplier", "seatOffsetDistance", "collisionDamageMultiplier", "monetary", "modelFlags", "handlingFlags", "headLight", "tailLight", "animGroup", } local carsValue = { [434] = 4000, 8000, 1.7, {0.0, 0.0, -0.3}, -- and later more data... }
-
Hey, as the title say i want to know differences between them, and i have also one question related to it. This way to use loop is much faster than ipairs/pairs, i am right? If yes, then why? function unglueOnExplosion() local attached = getAttachedElements(source) for i = 1, #attached do if getElementType(attached[i]) == "player" then triggerEvent("ungluePlayer", attached[i]) end end end addEventHandler("onVehicleExplode", getRootElement(), unglueOnExplosion) And this is slower version of it? function unglueOnExplosion() local attached = getAttachedElements(source) for _, v in pairs(attached) do if getElementType(v) == "player" then triggerEvent("ungluePlayer", v) end end end addEventHandler("onVehicleExplode", getRootElement(), unglueOnExplosion)
-
Hey, as the title say, how can i check? For functions and loops?
-
Thanks, but can you help me one more time? I don't want create other topic for it, and question it's related with tables. How can i send this table from server-side within triggerClientEvent, and then create same, just with other title? Or copy everything what it contains? table = { first = {}, second = {}, }
-
I had already experience with elementData, on 40~ players, let's say was around 15 cars shooting to themselves, and the value of each car armor was done on elementData. There was also one elementData which was responsible for player blood. About my players. I have server in EU, a lot of EU players (they have very small ping 40-60 +/-), and some RU/UA/KZ players (they have ping around 100-120~). I am targeting in making optimisations in everything which changing very frequently (i think it's good to change it from elementData to table), this is one of 3 things, which also change frequently, i just want to see results, which tables can give me. And about this interface, i should send update of this table whenever vehicle got damage?
-
Wow, that's awesome. But this will not hurt server when triggering it all the time onClientVehicleDamage? Another question related to it, i will need to get this server-side table when player damage a car (there's a some kind of interface which shows actual armor bar of car), should i make it with triggerClientEvent or there's a better way? About code above, didn't test it yet.
-
-- shared vehiclesCacheData = { armorPoints = {}, } -- server -- checking data, returns good values. addCommandHandler("data", function(plr, command) local vehicle = getPedOccupiedVehicle(plr) if not vehicle then outputChatBox("You need to be in vehicle to get data.", plr) return end local parent = getElementData(vehicle, "core:parent") if parent and vehicle then outputChatBox("Data [1]: "..vehiclesCacheData.armorPoints[parent], plr) --outputDebugString("Parent: "..tostring(parent)) end end) -- adding data, somewhere in function vehiclesCacheData.armorPoints[carCol] = 17 * 100 -- client -- checking data, returns error or nil. addCommandHandler("data2", function(plr, command) local veh = getPedOccupiedVehicle(getLocalPlayer()) local parent = getElementData(veh, "core:parent") outputChatBox(vehiclesCacheData[parent].armorPoints) -- this will show error - attempt to index field '?' (a nil value) --outputChatBox(vehiclesCacheData.armorPoints[parent]) -- this will show nil end) I tried, it doesn't wanna work, seems like server/client have separate "shared" tables. Well, i decided to switch from using elementData to tables, everything should be okay, i wouldn't need to write this topic if just onVehicleDamage would have attacker parameter. So: - Efficient, at all, i had some problems with elementData, i'm sure that this thing was responsible for jumping bars of "vehicle armor", but that's by the way. - Less what can be, but i still should care for performance at all. - I can't you answer about it, no clue. - What parameters you mean? - It's one of the important things, not a visual thing only. - What will be best solution for it? To make it works fast, and efficiently. It shouldn't sync for players that aren't logged in, only for players in game.
-
Well i need to change some data which is server-sided, using client-side event, onClientVehicleDamage. + The data on server-side in table, should be updated when player damage a vehicle. (this should be synced for all the players)
-
Hey. I was doing some stuff with tables, and i encountered a problem. So, i have a table with cache data of vehicles, on server-side. I need to change some values, when vehicle got damaged, however i can't use this table on client-side or within onVehicleDamage because there's not attacker parameter, and without it i can't get some additional data. Looking for workarounds or a solution, - maybe create custom event which will be triggered from client (onClientVehicleDamage) -> server (custom function), but i think so it will decrease performance a lot (triggering on every damage of car done by player), or there's a easier way to get this table up-to-date on client-side, without decreasing performance.
-
I will need an export only for set this data once. So if i use the system above for same resource (example: change this data when player damage a car (damage function it's in the same resource)) it should works faster? Plus i can't disable synchronization for client, because client handle damage.
-
Hey once again. I just thought how can i improve performance on my server. My server is based on destroying cars (which have elementData with needed values), however as far i know setElementData synchronizes with all the players and server + elementData which I'm talking about right now was changing almost all the time (onClientVehicleDamage). So i found this topic: https://forum.multitheftauto.com/topic/65726-howwhy-to-stop-using-setelementdata-and-getelementdata/ And i already created some base functions of it: vehicleData = { -- outside function first_value = {} } -- on player vehicle spawn car = createVehicle(model, x, y, z, 0, 0, rz) carCol = createColSphere(x, y, z, 3.75) attachElements(carCol, car, 0, 1, 0) -- attach colsphere to car, without it probably i can't do anything. setElementData(car, "data", carCol) -- set colsphere data to element data of car. vehicleData.first_value[carCol] = math.random(1, 20) -- set some data -- vehicle have also like 5 more elementData, but they don't change later at all -- check data command addCommandHandler("data", function(plr, command) local vehicle = getPedOccupiedVehicle(plr) local parent = getElementData(vehicle, "data") if parent and vehicle then outputChatBox("Data of vehicle: "..vehicleData.first_value[parent], plr) end end) -- check table addCommandHandler("table", function(plr, command) for k, v in pairs(vehicleData.first_value) do outputChatBox(v, plr) end end) -- clearing data after vehicle explode function testFunction() local parent = getElementData(source, "data") if parent then vehicleData.first_value[parent] = nil outputDebugString("Data cleared.") end end addEventHandler("onVehicleExplode", getRootElement(), testFunction) So here are my questions: - elementData have any affect on player FPS? (if changing this value for example: on onClientVehicleDamage when on server are 30+ players online?) - Should this system improve efficiency of script? If yes, then it should works much better? - When i need also clear data, excluding vehicle explode, and script restart (table re-creates at resource restart?), i don't need to save that data anywhere, it should be saved only to moment when vehicle explode, because anyway player spawn a new car) - How can i export this table for use in other resource? I understand this a bit, by using export, but how i can later get first_value data? Can someone give me a example of it? Export + get/set another value for this data in another resource? Based on it: <export function="twerk" type="server"/> table = {} function twerk () return table end table = exports.resourceName:twerk()
-
I'll try it out soon, after it i'll answer you. Thanks.
-
Without timer this thing: setPedControlState(getLocalPlayer(), "walk", value[1]) isn't working, if i want to player move slowly all the time, after sometime it looks like this thing disable. (player can walk like you are exhausted, i want to player move all the time on ALT)
-
Hi. I created a function for enable/disable things like: walk, sprint, jump. However this function runs every 300ms on client side. Any idea how can i improve it, to remove timer at all? (I tried to do it without timer - but without it, it doesn't work as it should) function checkPlayerMovementStyle() local value = skinsData["Movement"][getElementModel(getLocalPlayer())] if value then setPedControlState(getLocalPlayer(), "walk", value[1]) toggleControl("sprint", value[2]) toggleControl("jump", value[3]) end end setTimer(checkPlayerMovementStyle, 300, 0)
-
What about your solution for this? Because i didn't test it/create it yet. Everything should be okay?
-
You can use: -- Server -- -- https://wiki.multitheftauto.com/wiki/SetFarClipDistance addEventHandler( "onResourceStart", resourceRoot, function( ) setFarClipDistance( 3000 ) -- We adjust visibility range to 3000 metres end ) But this doesn't help that much.
-
Thank you, i'll try it out soon.