-
Posts
132 -
Joined
-
Last visited
-
Days Won
2
Posts posted by Trust aka Tiffergan
-
-
first gets the cursor position, the camera matrix, and the vehicle position. Then, it calculates the sticker's X position by subtracting the camera's X translation from the cursor's X position, and adding the vehicle's X position. Similarly, it calculates the sticker's Y position by subtracting the camera's Y translation from the cursor's Y position, and adding the vehicle's Y position.
local cursorX, cursorY = getCursorPosition() local cameraMatrix = getCameraMatrix() local vehiclePosition = getElementPosition(vehicle) local stickerX = cursorX * 1024 - cameraMatrix[12] + vehiclePosition[0] local stickerY = cursorY * 1024 - cameraMatrix[13] + vehiclePosition[1] stickers[selectedStickerID][1] = stickerX stickers[selectedStickerID][2] = stickerY
-
Hello, I have problem using script radargen I got map from my server but the problem is I have a green shaders on my server and for example bonecountry, area51 are green and my map from radargen is original like from gta sa so does someone know how I can get output radar with my shaders?
-
can you show errors from 'debugscript 3' ?
- 1
-
I followed your guide exactly, but when I try to start the model, I get an error. " Resource is loaded, but has errors (Couldn't find file files/lod_conhoos1.txd for resource files)" How can I fix this?
-
Amazing adventure
-
I hope we will get another 20 years with that amazing mod
-
- Create a custom event in your script that will trigger the NPC driving the car.
- Within this event, you will use the setElementData function to set a custom server-side variable that will keep track of the NPC's driving state.
- You will then create another custom event that will be triggered regularly (for example, using a timer) to update the NPC's driving state based on the value of the custom server-side variable set in step 2.
- In this second event, you will use the setPedControlState function to set the NPC's driving state.
This way, you will be able to create a server-side setPedControlState that allows an NPC to drive a car in MTA.
-
To create your own shaders in MTA, you will need to have a good understanding of computer graphics and programming, as well as the DirectX graphics library. A good starting point would be to familiarize yourself with the basics of shaders, such as the different types of shaders (vertex shaders, pixel shaders, etc.), how they work, and the syntax of the DirectX Shader Model language.
The following resources may be helpful in learning how to create shaders in MTA:
The official MTA wiki (https://wiki.mtasa.com/wiki/Main_Page) has a section on shaders and provides information on how to use shaders in MTA.
The official MTA forums (https://forum.mtasa.com/) have a section on scripting, where you can find answers to questions and see examples of shaders created by other users.
YouTube tutorials and online courses on computer graphics and DirectX may also be helpful in learning how to create shaders.
Keep in mind that creating shaders requires a good understanding of programming and graphics, so it may take some time and effort to become proficient. But with practice and determination, you can create your own custom shaders for use in MTA.
Here is an example of a simple pixel shader that applies a grayscale effect to the game world
float4 PSMain(float2 texCoord : TEXCOORD) : COLOR { float4 color = tex2D(DiffuseMap, texCoord); float intensity = (color.r + color.g + color.b) / 3.0; color.r = intensity; color.g = intensity; color.b = intensity; return color; } technique Grayscale { pass Pass1 { PixelShader = compile ps_2_0 PSMain(); } }
This shader takes the texture coordinate data from the game world and applies a grayscale effect to it. The PSMain function calculates the average intensity of the color data and sets the red, green, and blue channels to that value, creating a grayscale image. The Grayscale technique specifies that this shader should be used as a pixel shader, and the Pass1 pass indicates that there is only one pass required to apply this effect.
This is just a simple example to give you an idea of what a shader in MTA might look like. More complex shaders can be created by using additional variables, calculations, and techniques.
- 1
-
You can use the "setWeaponProperty" function to set the recoil values for a specific weapon. For example, you can use the following code to set the recoil for an AK-47:
setWeaponProperty("AK-47", "poor", "recoil", 0.5) setWeaponProperty("AK-47", "good", "recoil", 0.3)
The first argument is the weapon name, the second argument is the skill level, and the third and fourth arguments are the property and value, respectively. The skill level can be "poor", "std", "pro", or "special", and the property can be one of the available weapon properties, such as "recoil", "spread", "accuracy", etc. The value is a number that represents the intensity of the property. You can adjust the values to create the desired recoil behavior for the weapon.
Also
You can write custom code that modifies the behavior of the weapon's recoil in real-time, based on various factors such as the player's movement, the weapon's condition, or any other variables you choose to include. For example, you could write a script that makes the recoil stronger when the player is moving and weaker when the player is standing still. The possibilities are endless, and the custom recoil behavior can be tailored to meet your specific needs.
-
3 hours ago, Xwaw said:
Re:
And give an example of a script for which you will use e.g. "this"
local myButton = createButton(0.5, 0.5, 0.1, 0.1, "Click me!", true) addEventHandler("onClientGUIClick", myButton, function() outputChatBox("Button clicked!") end)
In this example, the script creates a GUI button and adds an event handler for the
onClientGUIClick
event. When the button is clicked, the event handler is triggered, andthis
refers to the button element that was clicked. The output message will display "Button clicked!" in the chatbox.- 1
-
It's hard for me to understand what you mean, please describe your error better.
-
To solve the issue you are facing, you need to debug the problem to determine what is causing the players to get stuck in the ground. Here are some steps that you can follow to debug the issue:
-
Check the logs: Look at the server logs to see if there are any error messages that could be related to the issue.
-
Isolate the problem: Try to isolate the problem by disabling other resources one by one until you find the resource that is causing the issue.
-
Reproduce the issue: Try to reproduce the issue in a test environment to see if you can find any patterns or clues as to what is causing the problem.
-
Check the code: If you have access to the source code, check for any errors or issues in the code that could be causing the problem.
-
-
The last three arguments of the
attachElementToBone
function specify the rotation of the element in relation to the bone it's being attached to. The values are for the X, Y, and Z axes, respectively. To make the wheelbarrow appear normal, you'll need to adjust these values to get the desired orientation.A common approach to determining the correct values for these arguments is to use trial and error. You can make small adjustments to the values until the wheelbarrow appears to be in the desired orientation.
Keep in mind that the coordinate system used in 3D graphics can be different from the one you're used to, so it may take some time to get the hang of it.
-
In MTA, when a script is attached to an object, that object is considered the "source". The "root" element refers to the highest level parent object of the source. For example, if a script is attached to a vehicle, then the source would be the vehicle and the root would be the game world.
"This" refers to the object that the script is attached to, which is equivalent to the "source".
"SourceResource" refers to the resource that the script is part of. Resources are collections of files and scripts that define a specific aspect of the game, such as a custom game mode or a custom vehicle.
"SourceResourceRoot" refers to the root directory of the resource that the script is part of.
"Client" refers to the client-side script that is running on a player's computer. This is opposed to a server-side script, which runs on the game server.
In the context of
AddEventHandler
, these elements can be used to specify the object that the event handler is attached to. For example:
addEventHandler("onPlayerJoin", root, function() outputChatBox("Welcome to the server!") end)
In this example, the event handler is attached to the
root
element, meaning that it will trigger for every player that joins the server. The function passed toAddEventHandler
will be called, displaying a message in the chat for each player that joins. -
If the radar area created with the
createRadarArea
function is not visible, you may need to add it to the rendering process. To do this, you can modify theRADAR
function that draws the radar on the screen and add code to draw the radar area.You can use the
dxDrawMaterialLine3D
function to draw the shape of the radar area on the radar. You will need to provide the position and size of the radar area, as well as the rotation angle, which can be obtained from thegetElementRotation
function.
-- ... --# Blips local radarAreas = getElementsByType("radararea") for k, v in ipairs(radarAreas) do local x1, y1, z1, x2, y2, z2 = getRadarAreaSize(v) local minX, minY, minZ = math.min(x1, x2), math.min(y1, y2), math.min(z1, z2) local maxX, maxY, maxZ = math.max(x1, x2), math.max(y1, y2), math.max(z1, z2) local width, height, depth = maxX - minX, maxY - minY, maxZ - minZ local cx, cy, cz = (minX + maxX) / 2, (minY + maxY) / 2, (minZ + maxZ) / 2 local rot = getElementRotation(v) dxDrawMaterialLine3D(cx - width / 2, cy - height / 2, cz, cx + width / 2, cy - height / 2, cz, rt, 2, tocolor(255, 0, 0), cx, cy, cz, rot) dxDrawMaterialLine3D(cx + width / 2, cy - height / 2, cz, cx + width / 2, cy + height / 2, cz, rt, 2, tocolor(255, 0, 0), cx, cy, cz, rot) dxDrawMaterialLine3D(cx + width / 2, cy + height / 2, cz, cx - width / 2, cy + height / 2, cz, rt, 2, tocolor(255, 0, 0), cx, cy, cz, rot) dxDrawMaterialLine3D(cx - width / 2, cy + height / 2, cz, cx - width / 2, cy - height / 2, cz, rt, 2, tocolor(255, 0, 0), cx, cy, cz, rot) end -- ...
This code will render the outline of each radar area in red color on the radar. You can modify the color and thickness of the lines as needed.
-
local speed = 20 local buoyancy = 1.5 local drag = 1 function swimVehicle ( ) local x, y, z = getElementPosition(vehicle) local waterZ = getWaterLevel ( x, y, z ) if waterZ and z < waterZ then setElementData(vehicle, "buoyancy", buoyancy) setElementData(vehicle, "vehicleDrag", drag) setElementData(vehicle, "centerOfMass", {0,0,-1}) setVehicleHandling(vehicle, "engineAcceleration", speed) else setElementData(vehicle, "buoyancy", 0) setElementData(vehicle, "vehicleDrag", 0) setVehicleHandling(vehicle, "engineAcceleration", 0) end end addEventHandler("onClientRender", root, swimVehicle)
Please note that this is just a basic example, you would need to fine tune the values and add more functionality to make it more realistic and functional. Also, this example is for client-side script, you need to adapt it for server-side.
-
6 hours ago, Spectre7660 said:
My radar source is there; but radar areas, which is created with (createRadarArea) function, is not visible on the radar. How can I add it?
local enableBlips = true local renderNorthBlip = true local alwaysRenderMap = false local worldW, worldH = 1800,1800 local blip = 8 local sx, sy = guiGetScreenSize() local rt = dxCreateRenderTarget(290,175) local xFactor, yFactor = sx/1366,sy/768 local yFactor = xFactor function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end; return t; end function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end function RADAR() --Radar config setPlayerHudComponentVisible("area_name", false) setPlayerHudComponentVisible("vehicle_name", false) setPlayerHudComponentVisible("radar", false) local mW, mH = dxGetMaterialSize(rt) local x, y = getElementPosition(localPlayer) local X, Y = mW/2 -(x/(6000/worldW)), mH/2 +(y/(6000/worldH)) local camX,camY,camZ = getElementRotation(getCamera()) dxSetRenderTarget(rt, true) if alwaysRenderMap or getElementInterior(localPlayer) == 0 then dxDrawRectangle(0, 0, mW, mH, 0xFF7CA7D1) dxDrawImage(X - worldW/2, mH/5 + (Y - worldH/2), worldW, worldH, "gfx/world.png", camZ, (x/(6000/worldW)), -(y/(6000/worldH))) -- dxSetRenderTarget() dxDrawImage((18)*xFactor, sy-((216))*yFactor, (293)*xFactor, (177)*yFactor, "gfx/radarbg.png", 0, 0, 0, tocolor(0, 0, 0, 180)) dxDrawImage((30+5)*xFactor, sy-((200+5))*yFactor, (270-10)*xFactor, (155)*yFactor, rt, 0, 0, 0, tocolor(255, 255, 255, 80)) --# Blips local rx, ry, rz = getElementRotation(localPlayer) local lB = (33)*xFactor local rB = (8+290)*xFactor local tB = sy-(208)*yFactor local bB = tB + (155)*yFactor local cX, cY = (rB+lB)/2, (tB+bB)/2 +(35)*yFactor local toLeft, toTop, toRight, toBottom = cX-lB, cY-tB, rB-cX, bB-cY for k, v in ipairs(getElementsByType("blip")) do local bx, by = getElementPosition(v) local actualDist = getDistanceBetweenPoints2D(x, y, bx, by) local maxDist = getBlipVisibleDistance(v) if actualDist <= maxDist and getElementDimension(v)==getElementDimension(localPlayer) and getElementInterior(v)==getElementInterior(localPlayer) then local dist = actualDist/(6000/((worldW+worldH)/2)) local rot = findRotation(bx, by, x, y)-camZ local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.min(dist, math.sqrt(toTop^2 + toRight^2)), rot) local bpx = math.max(lB, math.min(rB, bpx)) local bpy = math.max(tB, math.min(bB, bpy)) local bid = getElementData(v, "customIcon") or getBlipIcon(v) local _, _, _, bcA = getBlipColor(v) local bcR, bcG, bcB = 255, 255, 255 if getBlipIcon(v) == 0 then bcR, bcG, bcB = getBlipColor(v) end local bS = getBlipSize(v) dxDrawImage(bpx -(blip*bS)*xFactor/2, bpy -(blip*bS)*yFactor/2, (blip*bS)*xFactor, (blip*bS)*yFactor, "gfx/blip/"..bid..".png", 0, 0, 0, tocolor(bcR, bcG, bcB, bcA)) end end if renderNorthBlip then local rot = -camZ+180 local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.sqrt(toTop^2 + toRight^2), rot) local bpx = math.max(lB, math.min(rB, bpx)) local bpy = math.max(tB, math.min(bB, bpy)) local dist = getDistanceBetweenPoints2D(cX, cY, bpx, bpy) local bpx, bpy = getPointFromDistanceRotation(cX, cY, dist, rot) if bpx and bpy then local bpx = math.max(lB, math.min(rB, bpx)) local bpy = math.max(tB, math.min(bB, bpy)) dxDrawImage(bpx -(blip*2)/2,bpy -(blip*2)/2,blip*2,blip*2,"gfx/blip/4.png",0,0,0) end end dxDrawImage(cX -(blip*2)*xFactor/2,cY -(blip*2)*yFactor/2,(blip*2)*xFactor,(blip*2)*yFactor, "gfx/player.png", camZ-rz, 0, 0) end end addEventHandler("onClientRender", root, RADAR) function Visible() if isVisible then addEventHandler("onClientRender", root, RADAR) else removeEventHandler("onClientRender", root, RADAR) end isVisible = not isVisible end bindKey ("F11", "down", Visible)
It looks like you are using the function
createRadarArea
to create a radar area, but it is not appearing on your radar. To make sure that the radar area is visible, you will need to make sure that it is being added to the element list that you are iterating through in thefor
loop starting on the following line:
for k, v in ipairs(getElementsByType("blip")) do
You will want to change this to include radar areas as well, for example:
for k, v in ipairs(getElementsByType("blip", "radararea")) do
This will ensure that the radar areas created withcreateRadarArea
function are included in the list of elements being drawn on the radar.
- 1
-
function enable_shaders() if not shadersEnabled then -- code to enable shaders, for example: setWeather(15) setFogDistance(50) shadersEnabled = true outputChatBox("Shaders enabled.") else outputChatBox("Shaders are already enabled.") end end function disable_shaders() if shadersEnabled then -- code to disable shaders, for example: setWeather(0) setFogDistance(200) shadersEnabled = false outputChatBox("Shaders disabled.") else outputChatBox("Shaders are already disabled.") end end
This example uses a global variable
shadersEnabled
to keep track of whether the shaders are currently enabled or disabled. Theenable_shaders()
function checks if the shaders are already enabled before enabling them, and thedisable_shaders()
function does the same for disabling the shaders.You would also need to initialize the global variable
shadersEnabled
to keep track of the current state of shaders, for example:shadersEnabled = false
You would then need to add a command handler to listen for the "shaders on" and "shaders off" commands:
addCommandHandler("shaders", function(player, command, option) if option == "on" then enable_shaders() elseif option == "off" then disable_shaders() end end)
Note that the code to actually enable and disable the shaders would depend on the specific technology you are using to implement the shaders, and in this example I provided an example of how to change the weather and fog distance, you may need to adjust that according to your needs.
- 1
-
Nice, I'm waiting to play
- 1
-
What is 'car uv?'
-
hello, i would like to buy a fanpage with players from mta interested in dayz server i hope this is correct section
-
Nice, by the way what is this map?
-
It's hard to say without more information about the problem. Some things you might want to check are:
Make sure that the dxDrawText function is being called after the dxDrawImage function so that the text is drawn on top of the image.
Verify that the tx and ty variables are being set to the correct screen coordinates before the dxDrawText call.
Check the item table in the dxDrawImage call to ensure that it contains the correct image file path.
Make sure that the item table is defined and containing expected values.
Verify that the screenW and screenH variables are set to the correct values for the current window size.
Check the output of getElementData(localPlayer, 'inv.item') or {} to ensure that it returns the expected data.
Make sure that the dxDrawText function is receiving the correct arguments and that they are in the correct order.
Check if there is any error message in the console.
It may be helpful to add some debugging output or print statements to help you see what's happening at each step.
-
To find the relative coordinates of the listener from the point of the sound source, you can use the following steps:
Calculate the distance between the listener's position and the sound source's position using the getDistanceBetweenPoints2D function.
Calculate the angle between the listener's position and the sound source's position by getting the angle between the two points using math.atan2(y2-y1, x2-x1)
Rotate the angle by the sound source's rotation (sound.rotZ) using math.rad(sound.rotZ)
Use this angle and the distance to calculate the relative x, y, and z coordinates of the listener from the sound source using math.cos(angle)*distance for the x coordinate and math.sin(angle)*distance for the y coordinate.
Use the resulting x, y, and z coordinates to position the listener on the sound source's vector.
here is an example of how the relative coordinates of the listener can be calculated using the steps I outlined above
local listener = {x = localPlayer.matrix:getPosition().x, y = localPlayer.matrix:getPosition().y, rotZ = localPlayer.matrix:getRotation().z} local sound = {x = -1788.82507, y = -2689.26538, z = 4.26150, rotZ = 180 + 90} local distance = getDistanceBetweenPoints2D ( sound.x, sound.y, listener.x, listener.y ) local angle = math.atan2(listener.y - sound.y, listener.x - sound.x) + math.rad(sound.rotZ) local listenerRelativeX = math.cos(angle) * distance local listenerRelativeY = math.sin(angle) * distance local listenerRelativePos = {x = sound.x + listenerRelativeX, y = sound.y + listenerRelativeY, z = listener.z}
This code calculates the relative position of the listener from the sound source using the distance and angle between the listener and sound source, and the rotation of the sound source. The resulting position is stored in the listenerRelativePos variable, which contains the x, y, and z coordinates of the listener relative to the sound source.
Note that this code is missing the calculation of the z coordinate, you need to add the calculation of the z coordinate based on the requirement of your game or application.
- 1
Hit marker dayz
in Scripting
Posted
here is a video on youtube how to make this