Jump to content

iron015

Members
  • Posts

    32
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

iron015's Achievements

Rat

Rat (9/54)

0

Reputation

  1. Доброе утро! Можно ли сделать так, чтобы одна наклейка накладывалась поверх другой? У меня при наложении второй наклейки первая пропадает. shader1 = {} shader2 = {} addCommandHandler("setshader", function(cmd, shd, scale, x, y) vehicle = getPedOccupiedVehicle(localPlayer) if tonumber(shd) == 1 then if not shader1[vehicle] then shader1[vehicle] = dxCreateShader("files/carpaints/shaders/s1.fx") engineApplyShaderToWorldTexture(shader1[vehicle], "vehiclegrunge256", vehicle) engineApplyShaderToWorldTexture(shader1[vehicle], "?emap*", vehicle) end dxSetShaderValue(shader1[vehicle], "gTextureColor", dxCreateTexture("files/carpaints/stickers/1.png")) dxSetShaderValue(shader1[vehicle], "sPicSize", scale, scale) dxSetShaderValue(shader1[vehicle], "sPicPos", x, y) dxSetShaderValue(shader1[vehicle], "sPicBright", false) dxSetShaderValue(shader1[vehicle], "sTexAddress", 4) dxSetShaderValue(shader1[vehicle], "sMask", true) dxSetShaderValue(shader1[vehicle], "sMaskHeight", -0.1) dxSetShaderValue(shader1[vehicle], "sEnableDirt", 1) dxSetShaderValue(shader1[vehicle], "sEnableEnv", 1) elseif tonumber(shd) == 2 then if not shader2[vehicle] then shader2[vehicle] = dxCreateShader("files/carpaints/shaders/s2.fx") engineApplyShaderToWorldTexture(shader2[vehicle], "vehiclegrunge256", vehicle) engineApplyShaderToWorldTexture(shader2[vehicle], "?emap*", vehicle) end dxSetShaderValue(shader2[vehicle], "gTextureColor", dxCreateTexture("files/carpaints/stickers/2.png")) dxSetShaderValue(shader2[vehicle], "sPicSize", scale, scale) dxSetShaderValue(shader2[vehicle], "sPicPos", x, y) dxSetShaderValue(shader2[vehicle], "sPicBright", false) dxSetShaderValue(shader2[vehicle], "sTexAddress", 4) dxSetShaderValue(shader2[vehicle], "sMask", true) dxSetShaderValue(shader2[vehicle], "sMaskHeight", -0.1) dxSetShaderValue(shader2[vehicle], "sEnableDirt", 1) dxSetShaderValue(shader2[vehicle], "sEnableEnv", 1) end end) addEventHandler("onClientPreRender", getRootElement(), function() for k, v in ipairs(getElementsByType("vehicle")) do px, py, pz = getElementPosition(v) fx, fy, fz = getMatrixForward(getElementMatrix(v)) ux, uy, uz = getMatrixUp(getElementMatrix(v)) dxSetShaderValue(shader1[v], "elementFwVector", fx, fy, fz) dxSetShaderValue(shader1[v], "elementUpVector", ux, uy, uz) dxSetShaderValue(shader1[v], "elementPosition", px, py, pz) dxSetShaderValue(shader2[v], "elementFwVector", fx, fy, fz) dxSetShaderValue(shader2[v], "elementUpVector", ux, uy, uz) dxSetShaderValue(shader2[v], "elementPosition", px, py, pz) end end) // // proj_paint_flat.fx // //------------------------------------------------------------------------------------------ // Settings //------------------------------------------------------------------------------------------ float3 elementPosition = float3(0,0,0); float3 elementFwVector = float3(0,0,0); float3 elementUpVector = float3(0,0,0); float2 sPicPos = float2(0,0); float2 sPicSize = float2(1,1); bool sPicBright = false; int sTexAddress = 4; bool sMask = true; float sMaskHeight = 0; bool sEnableDirt = false; bool sEnableEnv = false; texture gTextureColor; //------------------------------------------------------------------------------------------ // Include some common stuff //------------------------------------------------------------------------------------------ int gCapsMaxAnisotropy < string deviceCaps="MaxAnisotropy"; >; #define GENERATE_NORMALS #include "mta-helper.fx" //------------------------------------------------------------------------------------------ // Sampler for the main texture //------------------------------------------------------------------------------------------ sampler Sampler0 = sampler_state { Texture = (gTexture0); }; sampler Sampler1 = sampler_state { Texture = (gTexture1); }; sampler SamplerColor = sampler_state { Texture = (gTextureColor); MipFilter = Linear; MaxAnisotropy = gCapsMaxAnisotropy; MinFilter = Anisotropic; AddressU = sTexAddress; AddressV = sTexAddress; BorderColor = float4(0,0,0,0); }; //------------------------------------------------------------------------------------------ // Structure of data sent to the vertex shader //------------------------------------------------------------------------------------------ struct VSInput { float3 Position : POSITION0; float3 Normal : NORMAL0; float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; float2 TexCoord1 : TEXCOORD1; }; //------------------------------------------------------------------------------------------ // Structure of data sent to the pixel shader ( from the vertex shader ) //------------------------------------------------------------------------------------------ struct PSInput { float4 Position : POSITION0; float4 Diffuse : COLOR0; float3 Specular : COLOR1; float2 TexCoord : TEXCOORD0; float2 TexCoord1 : TEXCOORD1; float2 TexCoord2 : TEXCOORD2; float2 TexCoord3 : TEXCOORD3; float PointPlaneDist : TEXCOORD4; }; //------------------------------------------------------------------------------------------ // Create view matrix //------------------------------------------------------------------------------------------ float4x4 createViewMatrix( float3 pos, float3 fwVec, float3 upVec ) { float3 zaxis = normalize( fwVec ); // The "forward" vector. float3 xaxis = normalize( cross( -upVec, zaxis ));// The "right" vector. float3 yaxis = cross( xaxis, zaxis ); // The "up" vector. // Create a 4x4 view matrix from the right, up, forward and eye position vectors float4x4 viewMatrix = { float4( xaxis.x, yaxis.x, zaxis.x, 0 ), float4( xaxis.y, yaxis.y, zaxis.y, 0 ), float4( xaxis.z, yaxis.z, zaxis.z, 0 ), float4(-dot( xaxis, pos ), -dot( yaxis, pos ), -dot( zaxis, pos ), 1 ) }; return viewMatrix; } //------------------------------------------------------------------------------------------ // Create orthographic projection matrix //------------------------------------------------------------------------------------------ float4x4 createOrthographicProjectionMatrix(float near_plane, float far_plane, float viewport_sizeX, float viewport_sizeY) { float sizeX = 2 / viewport_sizeX; float sizeY = 2 / viewport_sizeY; float4x4 projectionMatrix = { float4(sizeX, 0, 0, 0), float4(0, sizeY, 0, 0), float4(0, 0, 2.0 / (far_plane - near_plane), 0), float4(0, 0, -(far_plane + near_plane) / (far_plane - near_plane), 1) }; return projectionMatrix; } //------------------------------------------------------------------------------------------ // lightEnableState int gLight0Enable < string lightEnableState="0,Enable"; >; int gLight1Enable < string lightEnableState="1,Enable"; >; int gLight2Enable < string lightEnableState="2,Enable"; >; int gLight3Enable < string lightEnableState="3,Enable"; >; int gLight4Enable < string lightEnableState="4,Enable"; >; // lightState float4 gLight0Diffuse < string lightState="0,Diffuse"; >; float3 gLight0Direction < string lightState="0,Direction"; >; float4 gLight1Diffuse < string lightState="1,Diffuse"; >; float3 gLight1Direction < string lightState="1,Direction"; >; float4 gLight2Diffuse < string lightState="2,Diffuse"; >; float3 gLight2Direction < string lightState="2,Direction"; >; float4 gLight3Diffuse < string lightState="3,Diffuse"; >; float3 gLight3Direction < string lightState="3,Direction"; >; float4 gLight4Diffuse < string lightState="4,Diffuse"; >; float3 gLight4Direction < string lightState="4,Direction"; >; //------------------------------------------------------------------------------------------ // MTACalcGTACompleteDiffuse // - Calculate GTA lighting including pointlights for vehicles (all 4 lights) //------------------------------------------------------------------------------------------ float4 MTACalcGTACompleteDiffuse( float3 WorldNormal, float4 InDiffuse ) { // Calculate diffuse color by doing what D3D usually does float4 ambient = gAmbientMaterialSource == 0 ? gMaterialAmbient : InDiffuse; float4 diffuse = gDiffuseMaterialSource == 0 ? gMaterialDiffuse : InDiffuse; float4 emissive = gEmissiveMaterialSource == 0 ? gMaterialEmissive : InDiffuse; float4 TotalAmbient = ambient * ( gGlobalAmbient + gLightAmbient ); // Add all the 4 pointlights float DirectionFactor=0; float4 TotalDiffuse=0; if (gLight1Enable) { DirectionFactor = max(0,dot(WorldNormal, -gLight1Direction )); TotalDiffuse += ( gLight1Diffuse * DirectionFactor ); } if (gLight2Enable) { DirectionFactor = max(0,dot(WorldNormal, -gLight2Direction )); TotalDiffuse += ( gLight2Diffuse * DirectionFactor ); } if (gLight3Enable) { DirectionFactor = max(0,dot(WorldNormal, -gLight3Direction )); TotalDiffuse += ( gLight3Diffuse * DirectionFactor ); } if (gLight4Enable) { DirectionFactor = max(0,dot(WorldNormal, -gLight4Direction )); TotalDiffuse += ( gLight4Diffuse * DirectionFactor ); } TotalDiffuse *= diffuse; float4 OutDiffuse = saturate(TotalDiffuse + TotalAmbient + emissive); OutDiffuse.a *= diffuse.a; return OutDiffuse; } //------------------------------------------------------------------------------------------ // Get Projected TexCoords //------------------------------------------------------------------------------------------ float2 getProjectedTexCoord(float4 projPos, float2 uv) { projPos.xy += uv.xy; float projX = (0.5 * (projPos.w + projPos.x)); float projY = (0.5 * (projPos.w - projPos.y)); return float2(projX, projY) / projPos.w; } //------------------------------------------------------------------------------------------ // VertexShaderFunction //------------------------------------------------------------------------------------------ PSInput VertexShaderFunction(VSInput VS) { PSInput PS = (PSInput)0; // Calculate screen pos of vertex and pass to pixel shader PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection); // Create view and projection matrices (for the projective texture) float4x4 sView = createViewMatrix(elementPosition + gWorld[2].xyz, - gWorld[2].xyz, gWorld[1].xyz); float4x4 sViewMask = createViewMatrix(elementPosition + elementUpVector , -elementUpVector , elementFwVector); float4x4 sProjection = createOrthographicProjectionMatrix(-800, 800, sPicSize.x, sPicSize.y); // Calculate the projective texture coordinates float4 worldPos = mul(float4(VS.Position.xyz,1), gWorld); float4 viewPos = mul(worldPos, sView); float4 projPos = mul(viewPos, sProjection); float4 viewPosMask = mul(worldPos, sViewMask); float4 projPosMask = mul(viewPosMask, sProjection); // Pass texture coordinates to pixel shader PS.TexCoord = VS.TexCoord; PS.TexCoord1 = VS.TexCoord1; // Pass projective texture coordinates to pixel shader PS.TexCoord2 = getProjectedTexCoord(projPos, sPicPos); PS.TexCoord3 = getProjectedTexCoord(projPosMask, sPicPos); // Calculate GTA lighting for vehicle float3 worldNormal = mul(VS.Normal, (float3x3)gWorld).xyz; PS.Diffuse = MTACalcGTACompleteDiffuse(worldNormal, VS.Diffuse); PS.Specular.rgb = saturate(gMaterialSpecular.rgb * MTACalculateSpecular(gCameraDirection, gLight1Direction, worldNormal, gMaterialSpecPower) * 0.75); // Texture mask float3 upVec = normalize(elementUpVector); PS.PointPlaneDist = dot(upVec.xyz, worldPos.xyz - elementPosition); return PS; } //------------------------------------------------------------------------------------------ // PixelShaderFunction //------------------------------------------------------------------------------------------ float4 PixelShaderFunction(PSInput PS) : COLOR0 { // Get Paintjob texture float4 texel = tex2D(SamplerColor, PS.TexCoord2.xy); // Mask the texture if ((PS.PointPlaneDist < sMaskHeight) && (sMask)) texel.a = 0; if (sTexAddress == 4) if ((PS.TexCoord3.x < 0) || (PS.TexCoord3.x > 1) || (PS.TexCoord3.y < 0) || (PS.TexCoord3.y > 1)) texel.a = 0; // Multiply by paint specular color if (!sPicBright) texel.rgb *= saturate(0.1 + gMaterialSpecular.rgb * 1.25); // Get vehicle paint color float4 finalColor = PS.Diffuse; // Get and apply env map texture float3 refTex = tex2D(Sampler1, PS.TexCoord1.xy).rgb; if (sEnableEnv) finalColor.rgb += saturate(refTex.rgb * gMaterialSpecular.rgb * 0.22); // Lerp betwen paint and texture finalColor.rgb = lerp(finalColor.rgb, texel.rgb, texel.a); // Apply specular highlight finalColor.rgb += PS.Specular.rgb; // Get and apply dirt texture float3 dirtTex = tex2D(Sampler0, PS.TexCoord.xy).rgb; if (sEnableDirt) finalColor.rgb *= dirtTex; // Pass the outcome finalColor.rgb = saturate(finalColor.rgb); finalColor.a = PS.Diffuse.a; return finalColor; } //------------------------------------------------------------------------------------------ // Techniques //------------------------------------------------------------------------------------------ technique ortographic_projection { pass P0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } } // Fallback technique fallback { pass P0 { // Just draw normally } }
  2. Проблему решил с помощью setElementRotation.
  3. Добрый день. Пытался сделать возможность настройки развала колёс, но при езде колеса двигаются восьмеркой. for k, o in ipairs(getAttachedElements(v)) do if getElementData(o, "wheeltype") and getElementData(o, "wheeltype") == "wheellf" then local px, py, pz = getVehicleComponentPosition(v, "wheel_lf_dummy") local rx, ry, rz = getVehicleComponentRotation(v, "wheel_lf_dummy") setElementAttachedOffsets(o, px, py, pz, rx, fbrk, rz) end if getElementData(o, "wheeltype") and getElementData(o, "wheeltype") == "wheelrf" then local px, py, pz = getVehicleComponentPosition(v, "wheel_rf_dummy") local rx, ry, rz = getVehicleComponentRotation(v, "wheel_rf_dummy") setElementAttachedOffsets(o, px, py, pz, rx, -fbrk, rz) end if getElementData(o, "wheeltype") and getElementData(o, "wheeltype") == "wheellr" then local px, py, pz = getVehicleComponentPosition(v, "wheel_lb_dummy") local rx, ry, rz = getVehicleComponentRotation(v, "wheel_lb_dummy") setElementAttachedOffsets(o, px, py, pz, rx, rbrk, rz) end if getElementData(o, "wheeltype") and getElementData(o, "wheeltype") == "wheelrr" then local px, py, pz = getVehicleComponentPosition(v, "wheel_rb_dummy") local rx, ry, rz = getVehicleComponentRotation(v, "wheel_rb_dummy") setElementAttachedOffsets(o, px, py, pz, rx, -rbrk, rz) end end
  4. ну проблем с работой я не наблюдал, просто в performancebrowser'е со временем работы сервера кол-во открытых xml постоянно пополняется.
  5. Ну у меня там мод большой, разбит на несколько файлов. Но во всех файлах, где есть открытие xml, примерно все так же написано. Вот еще кусок из другого файла. addEventHandler ( "onClientResourceStart", getResourceRootElement(), function (res) if res == getThisResource() then local xml = xmlLoadFile("data/coordinates.xml") if xml then local children = xmlFindChild ( xml, "RADPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") Gblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/cam.png" ) end end children = nil local children = xmlFindChild ( xml, "FUELPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") Fblip[i] = exports.res2:createCustomBlip ( x, y, 15, 15, "files/fuell.png" ) end end children = nil local children = xmlFindChild ( xml, "RNPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") Rblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/car1.png" ) end end children = nil local children = xmlFindChild ( xml, "SNPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") Sblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/car2.png" ) end end children = nil local children = xmlFindChild ( xml, "GAIPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") GMblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/car3.png" ) end end children = nil local children = xmlFindChild ( xml, "DBPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") Dblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/car4.png" ) end end children = nil local children = xmlFindChild ( xml, "BSPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") BSblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/car5.png" ) end end children = nil local children = xmlFindChild ( xml, "SHPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") SHblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/uch.png" ) end end children = nil local children = xmlFindChild ( xml, "TAXIPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") Tblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/taxi.png" ) end end children = nil local children = xmlFindChild ( xml, "GARAGEPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") GRblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/garage.png" ) end end children = nil local children = xmlFindChild ( xml, "GRPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") GZblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/gruz.png" ) end end children = nil local children = xmlFindChild ( xml, "TERMINALPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") TMblip[i] = exports.res2:createCustomBlip ( x, y, 20, 20, "files/term.png" ) end end children = nil end xmlUnloadFile(xml) xml = nil end end)
  6. iron015

    xml files

    Excuse me for the bad English , translated by an translator Good evening , I have on the server gradually replenishes the number of open xml files. for example: function banks ( res ) if res == getThisResource() then xml = xmlLoadFile("data/coordinates.xml") if xml then children = xmlFindChild ( xml, "TERMINALPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") z = xmlNodeGetAttribute(v,"z") r = xmlNodeGetAttribute(v,"r") bank[i] = createMarker ( x, y, z, "cylinder", 2, 255, 153, 0, 170 ) terminal[i] = createObject (1863, x, y, z, 0, 0, r) end xmlUnloadFile(xml) end end end end addEventHandler ( "onResourceStart", getRootElement(), banks )
  7. Добрый вечер, у меня на сервере постепенно пополняется число открытых xml файлов. По такому принципу выполняется открытие файлов во всём моде: function banks ( res ) if res == getThisResource() then xml = xmlLoadFile("data/coordinates.xml") if xml then children = xmlFindChild ( xml, "TERMINALPoints", 0 ) if children then for i,v in ipairs(xmlNodeGetChildren(children)) do x = xmlNodeGetAttribute(v,"x") y = xmlNodeGetAttribute(v,"y") z = xmlNodeGetAttribute(v,"z") r = xmlNodeGetAttribute(v,"r") bank[i] = createMarker ( x, y, z, "cylinder", 2, 255, 153, 0, 170 ) terminal[i] = createObject (1863, x, y, z, 0, 0, r) end xmlUnloadFile(xml) end end end end addEventHandler ( "onResourceStart", getRootElement(), banks )
  8. Добрый день, у меня функция getNearestVehicle иногда работает неправильно, пишет, что машина открыта, однако она остаётся закрытой. function getNearestVehicle( player ) x, y, z = getElementPosition( player ) for i, v in ipairs( getElementsByType( "vehicle" ) ) do if(getElementData (v, "owner" ) == getAccountName( getPlayerAccount( player ) ) ) then distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( v ) ) if distance <= ( prevDistance or distance + 1 ) then prevDistance = distance nearestVehicle = v end end end return nearestVehicle or false end function switchLock ( player ) veh = getNearestVehicle(player) if veh then locked = isVehicleLocked(veh) if locked then setVehicleLocked ( veh, false ) outputChatBox("Вы открыли ближайшую машину!", player, 243,149,72 ) setElementData (veh,"lock", 0) saveCars() else setVehicleLocked ( veh, true ) outputChatBox("Вы закрыли ближайшую машину!", player, 243,149,72 ) setElementData (veh,"lock", 1) saveCars() end end end addEvent( "switchLock", true ) addEventHandler( "switchLock", resourceRoot, switchLock )
  9. Здравствуйте! У меня проблема такая: При создании машины ID бывает 20, а после перезапуска 210(и с каждым созданием машины число растёт) function adminCreateVehicle ( source, cmd, model, price ) local accName = getAccountName ( getPlayerAccount ( source ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then if isPedInVehicle ( source ) then local exVehicle = getPedOccupiedVehicle ( source ) if exVehicle then local x,y,z = getElementPosition( exVehicle ) local ax,ay,az = getElementRotation ( exVehicle ) setTimer ( manualVehicleCreate, 3000, 1, x, y, z, ax, ay, az, tonumber(model), tonumber(price) ) end else local x,y,z = getElementPosition( source ) local ax,ay,az = getElementRotation ( source ) manualVehicleCreate ( x,y,z,ax,ay,az, tonumber(model), tonumber(price) ) end else outputChatBox ("Ошибка: вы не можете использовать эту команду",source, 255,255,127 ) end end addCommandHandler ("acarcreate", adminCreateVehicle) function manualVehicleCreate (x,y,z,ax,ay,az, model, price, new) maxcars = maxcars+1 cars[maxcars] = createVehicle ( model,x,y,z,ax,ay,az ) local color1, color2, color3, color4, color5, color6 = math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255) createVehiclesRow (model, x,y,z,ax,ay,az, color1, color2, color3, color4, color5, color6, price,"Nobody") setVehicleColor ( cars[maxcars], color1, color2, color3, color4, color5, color6 ) setElementData ( cars[maxcars], "saveable", true ) setElementData (cars[maxcars],"vehid",maxcars) setElementData (cars[maxcars],"xpos",x) setElementData (cars[maxcars],"ypos",y) setElementData (cars[maxcars],"zpos",z) setElementData (cars[maxcars],"anglex",ax) setElementData (cars[maxcars],"angley",ay) setElementData (cars[maxcars],"anglez",az) setElementData (cars[maxcars],"owner","Nobody") setElementData (cars[maxcars],"price",price) setElementData (cars[maxcars],"type",8) setElementData (cars[maxcars],"lock",0) setElementData (cars[maxcars],"antirad",0) setElementData (cars[maxcars],"money",0) setVehicleData ( getElementData ( cars[maxcars], "vehid" ), "id", tonumber(maxcars) ) if new then setVehicleDamageProof ( cars[maxcars], true) setTimer ( function ( veh ) setElementFrozen ( veh, true ) end, 2000, 1, cars[maxcars] ) end end function setVehicleData ( ID, typ, value ) setElementData ( cars[ID], saveableValues[typ], value ) updateVehiclesDB ( ID, typ, value ) end function updateVehiclesDB(ID, typ, value) -- Security array -- if(saveableValues[typ]) then local result = dbQuery ( database, "UPDATE `cars` SET `"..saveableValues[typ].."` = '"..value.."' WHERE `id` = "..ID.."" ) if(result) then dbFree ( result ) outputChatBox("saved Data: "..typ.." with the value: "..value.." for veh ID "..ID.."!") else outputChatBox("Can't save Data: "..typ.." with the value: "..value.." for veh ID "..ID.."!") end end end
  10. Здравствуйте! Вот какая у меня проблема : когда стрелка спидометра доходит до 60, она начинает скакать в разные стороны, а после этого при снижении скорости уходит в противоположную сторону от нуля. Помогите, пожалуйста. speedx, speedy, speedz = getElementVelocity ( theVeh ) actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) kmh = actualspeed * 180 local spx, spy, spz = getVehicleComponentRotation(theVeh, "speeds") setVehicleComponentRotation(theVeh, "speeds", spx, kmh , spz)
  11. нашёл решение, спасибо всем, может кому нужно будет if movable[ numF [vehicle] ] then local posX,posY,posZ = getElementAttachedOffsets( numF[vehicle] ) setElementAttachedOffsets (numF[vehicle],posX,posY-0.1,posZ) end
  12. спасибо, я так делал, но объект был почему-то справа от машины, когда выполнялась функция закрепления
  13. таким образом? if numF [vehicle] then movable [numF [vehicle] ] = false local carX,carY,carZ = getElementPosition( vehicle ) local posX,posY,posZ = getElementPosition( numF[vehicle] ) attachElements ( numF [vehicle], vehicle, posX-carX,posY-carY,posZ-carZ ) end еще раз извиняюсь за глупые вопросы, просто новичок в этом деле
  14. у меня скрипт сделан таким образом, что изначально объект можно перемещать в любое место, я хотел узнать, как сделать так, чтоб он зафиксировался на выбранном месте
  15. прошу прощения, что трачу время, и за глупые вопросы, а объект при этом не уйдет к центру машины?
×
×
  • Create New...