Jump to content

iron015

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by iron015

  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. прошу прощения, что трачу время, и за глупые вопросы, а объект при этом не уйдет к центру машины?
  16. спасибо, это я в общем понял, просто хотел узнать, возможно ли сделать так, чтобы на поставленном месте прикреплялся объект без смещения
  17. Добрый вечер, помогите, пожалуйста, возможно ли сделать так, чтоб можно было прикреплять объект к машине, чтобы он остался на заданных координатах? if numF [vehicle] then movable [numF [vehicle] ] = false local posX,posY,posZ = getElementPosition( numF[vehicle] ) attachElements ( numF [vehicle], vehicle, posX,posY,posZ ) end Может есть какие-то другие методы?
  18. [2014-06-19 21:45:23] WARNING: admcar/client.lua:4: Bad argument @ 'getVehicleController' Вот такие warning'и в консоли setTimer(function () for id, player in ipairs(getElementsByType("player")) do local theVehicle = getPedOccupiedVehicle (player) local controller = getVehicleController(theVehicle) if theVehicle and not controller then return end if theVehicle and controller then local id = getElementModel ( theVehicle ) if id == 494 or id == 541 then local accName = getAccountName ( getPlayerAccount ( player ) ) local isMod = isObjectInACLGroup("user."..accName,aclGetGroup("Moderator")) local isSMod = isObjectInACLGroup("user."..accName,aclGetGroup("SuperModerator")) local isAdmin = isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) if not isMod and not isSMod and not isAdmin then removePedFromVehicle ( player ) outputChatBox("#FFFF00Эта машина предназначена только для #00FF00админов#FFFF00!",player,255,255,255,true) end end end end end,100,0)
  19. Здравствуйте. Можно ли сделать так, чтобы Warning'и скриптов не выводились в server.log?
  20. Да, я туда с другого скрипта вставил, чтоб за дрифт деньги давались. Но даже в нетронутом виде не сохранялось.
  21. вот ссылка на весь скрипт http://rghost.ru/56343989 --these are the banned vehicle ids where you cannot get drift points. local BannedIDs = { 432, 532 } local rootElem = getRootElement() local thisRoot = getResourceRootElement(getThisResource()) local player = getLocalPlayer() local vehicle local isValid = false local size = 1.2 local modo = 0.01 local score = 0 local screenScore = 0 local tick local idleTime local multTime local driftTime local Yellow = tocolor(255,232,25) local Red = tocolor(234,0,3) local TempCol = Yellow local mult = 1 local tablamult = {350,1400,4200,11200} local anterior = 0 local mejor = 0 local total = 0 local global_mejor = 0 local global_nombre = "N/A" local screenWidth, screenHeight = guiGetScreenSize() local x1,y1,x2,y2 = screenWidth*0.2,screenHeight*0.1,screenWidth*0.8,screenHeight*0.8 addEventHandler("onClientResourceStart", thisRoot, function() addEventHandler("onClientRender", rootElem, showText) outputChatBox("Waiting for server drift data...") triggerServerEvent("driftClienteListo", rootElem, player) end ) addEventHandler("onClientResourceStop", thisRoot, function() removeEventHandler("onClientRender", rootElem, showText) end ) function isValidVehicle(source) local temp = source or getPedOccupiedVehicle(player) if temp and getVehicleType(temp) ~= "Automobile" then return false end if getVehicleOccupant(temp,0) ~= player then return false end local vehID = getElementModel(temp) for k,v in ipairs(BannedIDs) do if vehID == v then return false end end return true end function showText() dxDrawText(string.format("Лучший дрифт: %s - %d",global_nombre,global_mejor),44,screenHeight-43,screenWidth,screenHeight,Yellow,1,"pricedown") local tempVehicle = getPedOccupiedVehicle(player) if not tempVehicle then isValid = false vehicle = nil return elseif not isValid then isValid = vehicle ~= tempVehicle and isValidVehicle(tempVehicle) vehicle = tempVehicle return elseif vehicle ~= tempVehicle then isValid = isValidVehicle(tempVehicle) vehicle = tempVehicle return end if size > 1.3 then modo = -0.01 elseif size < 1.2 then modo = 0.01 end size = size + modo tick = getTickCount() local angulo,velocidad = angle() local tempBool = tick - (idleTime or 0) < 750 if not tempBool and score ~= 0 then anterior = score setElementData(player, "Last Drift", anterior) total = total+anterior setElementData(player, "Total Drift", total) if score > mejor then mejor = score setElementData(player, "Best Drift", mejor) if score > global_mejor then triggerServerEvent("driftNuevoRecord", rootElem, score, getPlayerName(player)) end end triggerEvent("onVehicleDriftEnd", rootElem, tick-driftTime-750) score = 0 end if angulo ~= 0 then if tempBool then score = score + math.floor(angulo*velocidad)*mult else score = math.floor(angulo*velocidad)*mult triggerEvent("onVehicleDriftStart", rootElem) driftTime = tick end if TempCol == Red then TempCol = Yellow end screenScore = score idleTime = tick end local temp2 = string.format("Множитель: X%d\n%s",mult,mult~=5 and string.format("Повышение до X%d при %d",mult+1,tablamult[mult]) or "MAX") dxDrawText(temp2, 20,210,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) if velocidad <= 0.3 and mult ~= 1 then dxDrawText("\n\nСлишком медленно!", 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) end if tick - (idleTime or 0) < 3000 then local temp = "DRIFT" if score >= 100000 then temp = "DRIFT\n\nКОРОЛЬ дрифта!" elseif score >= 50000 then temp = "DRIFT\n\nБезумный дрифт!" elseif score >= 20000 then temp = "DRIFT\n\nВозмутительный дрифт!" elseif score >= 15000 then temp = "DRIFT\n\nКолоссальный дрифт!" elseif score >= 7000 then temp = "DRIFT\n\nСупер!" elseif score >= 3000 then temp = "DRIFT\n\nВеликолепный дрифт" elseif score >= 1000 then temp = "DRIFT\n\nХороший дрифт" elseif score < 1000 then temp = "DRIFT\n\nСлабовато" end dxDrawText(temp, x1,y1,x2,y2, TempCol, 2.2, "sans","center","top", false,true,false) dxDrawText(string.format("\n%d",screenScore), x1,y1-10,x2,y2, TempCol, size, "pricedown","center","top", false,true,false) end end function angle() local vx,vy,vz = getElementVelocity(vehicle) local modV = math.sqrt(vx*vx + vy*vy) if not isVehicleOnGround(vehicle) then return 0,modV end local rx,ry,rz = getElementRotation(vehicle) local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz)) local deltaT = tick - (multTime or 0) if mult~= 1 and modV <= 0.3 and deltaT > 750 then mult = mult-1 multTime = tick elseif deltaT > 1500 then local temp = 1 if score >= 11200 then temp = 5 elseif score >= 4200 then temp = 4 elseif score >= 1400 then temp = 3 elseif score >= 350 then temp = 2 end if temp>mult then mult = temp multTime = tick end end if modV <= 0.2 then return 0,modV end --speed over 40 km/h local cosX = (sn*vx + cs*vy)/modV if cosX > 0.966 or cosX < 0 then return 0,modV end --angle between 15 and 90 degrees return math.deg(math.acos(cosX))*0.5, modV end addEvent("driftCarCrashed", true) addEventHandler("driftCarCrashed", rootElem, function() if score ~= 0 then idleTime = nil score = 0 mult = 1 TempCol = Red triggerEvent("onVehicleDriftEnd", rootElem, 0) end end ) addEvent("driftActualizarRecord", true) addEventHandler("driftActualizarRecord", rootElem, function(score, name) global_mejor = score global_nombre = name end ) addCommandHandler("resetdrift", function() anterior,mejor,total = 0,0,0 setElementData(player, "Last Drift", anterior) setElementData(player, "Total Drift", total) setElementData(player, "Best Drift", mejor) end )
  22. в чате написал /debugscript 3, чисто, ошибок нет. local root = getRootElement() local thisResourceRoot = getResourceRootElement(getThisResource()) local drift_mejor = 0 local drift_nombre = "N/A" addEventHandler ( "onResourceStart", thisResourceRoot, function() call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Best Drift") call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Last Drift") call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Drift") local xmlFile = xmlLoadFile("recordDrift.xml") local xmlPuntaje = xmlFindChild(xmlFile, "score", 0) local xmlNombre = xmlFindChild(xmlFile, "name", 0) if xmlPuntaje and xmlNombre then drift_mejor = tonumber(xmlNodeGetValue(xmlPuntaje)) drift_nombre = xmlNodeGetValue(xmlNombre) outputDebugString(string.format("Дрифт: Рекорд восстановлен. (%d points) (%s)",drift_mejor,drift_nombre)) setTimer(triggerClientEvent, 3000, 1, root, "driftActualizarRecord", root, drift_mejor, drift_nombre) xmlUnloadFile(xmlFile) else outputDebugString("Drift: Не удалось загрузить рекорды.") end end ) addEventHandler ( "onResourceStop", thisResourceRoot, function() call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Best Drift") call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Last Drift") call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Total Drift") local xmlFile = xmlLoadFile("recordDrift.xml") if xmlFile then local temp = xmlFindChild(xmlFile, "score", 0) if not temp then temp = xmlCreateChild(xmlFile, "score") end xmlNodeSetValue(temp, tostring(drift_mejor)) local temp2 = xmlFindChild(xmlFile, "name", 0) if not temp2 then temp2 = xmlCreateChild(xmlFile, "name") end xmlNodeSetValue(temp2, drift_nombre) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) outputChatBox ( "Saved and unloaded the XML." ) end end ) addEventHandler("onVehicleDamage", root, function() thePlayer = getVehicleOccupant(source, 0) if thePlayer then triggerClientEvent(thePlayer, "driftCarCrashed", root, source) end end) addEvent("driftNuevoRecord", true) addEventHandler("driftNuevoRecord", root, function(score, name) if score > drift_mejor then outputChatBox(string.format("Новый рекорд дрифта! (%d очков) (%s)",score,name)) drift_mejor = score drift_nombre = name local xmlFile = xmlLoadFile("recordDrift.xml") if xmlFile then local temp = xmlFindChild(xmlFile, "score", 0) if not temp then temp = xmlCreateChild(xmlFile, "score") end xmlNodeSetValue(temp, tostring(drift_mejor)) local temp2 = xmlFindChild(xmlFile, "name", 0) if not temp2 then temp2 = xmlCreateChild(xmlFile, "name") end xmlNodeSetValue(temp2, drift_nombre) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) outputChatBox ( "Saved and unloaded the XML." ) end triggerClientEvent(root, "driftActualizarRecord", root, drift_mejor, drift_nombre) end end) addEventHandler("onElementDataChange",getRootElement(), function ( ElementData ) if ( ElementData == "Last Drift" ) then givePlayerMoney(source,getElementData(source,ElementData)) end end ) addEvent("driftClienteListo", true) addEventHandler("driftClienteListo", root, function(player) triggerClientEvent(player, "driftActualizarRecord", root, drift_mejor, drift_nombre) outputChatBox(string.format("Текущий рекорд %d очков (%s)", drift_mejor, drift_nombre), player) end) --- FIN
×
×
  • Create New...