alexaxel705

Members
  • Content Count

    17
  • Joined

  • Last visited

Community Reputation

12 Decent

3 Followers

About alexaxel705

  • Rank
    Square

Details

  • Location
    Russian Federation

Recent Profile Visitors

961 profile views
  1. Вот видео инструкция по запуску скрипта.
  2. alexaxel705

    Unlimit

    it's possible, using the same methods. for script Unlimited Object initial file size ~800 Mb. i'll try experementing with skins and objects in the future.
  3. alexaxel705

    Area name

    setPlayerHudComponentVisible("area_name", false) in client setPlayerHudComponentVisible(thePlayer, "area_name", false) in server
  4. Thomas_Nightfire GetMarrot return Angle in the range from -180 to 180 on which we need to turn wheel. -180 right, +180 left. if active reverse +180 right, -180 left function setPedAnalogControlState takes values from 0.0 to 1.0 therefore, we lower the angle concentration at an acceptable level
  5. Thomas_Nightfire function getPointInFrontOfPoint(x, y, z, rZ, dist) local offsetRot = math.rad(rZ) local vx = x + dist * math.cos(offsetRot) local vy = y + dist * math.sin(offsetRot) return vx, vy, z end function GetMarrot(angle, rz) local marrot = 0 if(angle > rz) then marrot = -(angle-rz) else marrot = rz-angle end if(marrot > 180) then marrot = marrot-360 elseif(marrot < -180) then marrot = marrot+360 end return marrot end function findRotation(x1, y1, x2, y2) local t = -math.deg(math.atan2(x2 - x1, y2 - y1)) return t < 0 and t + 360 or t end local px,py,pz = getElementPosition(localPlayer) local prx,pry,prz = getElementRotation(localPlayer) local vx,vy,vz = getPointInFrontOfPoint(px,py,pz, prz+90, 15) local thePed = createPed(299, vx,vy,vz+1, prz+180) local theVehicle = createVehicle(404, vx,vy,vz+1, 0,0,prz+180) warpPedIntoVehicle(thePed, theVehicle) function UpdateBot() px,py,pz = getElementPosition(localPlayer) prx,pry,prz = getElementRotation(localPlayer) vx,vy,vz = getElementPosition(theVehicle) local vrx,vry,vrz = getElementRotation(theVehicle) local brakes = false local maxspd = 40 local MaxDist = 4 local vehreverse = false if(getDistanceBetweenPoints2D(px,py, vx, vy) < MaxDist) then brakes = true end if(brakes) then setPedAnalogControlState(thePed, "accelerate", 0) setPedAnalogControlState(thePed, "brake_reverse", 0) setPedControlState(thePed, "handbrake", true) setElementVelocity (theVehicle, 0,0,0) else local vxv, vyv, vzv = getElementVelocity(theVehicle) local s = (vxv^2 + vyv^2 + vzv^2)^(0.5)*156 -- Speed local rot = GetMarrot(findRotation(vx,vy,px,py),vrz) if(rot > 80) then if(rot > 100) then vehreverse = true end rot = 20 elseif(rot < -20) then if(rot < -80) then vehreverse = true end rot = -20 end if(vehreverse) then setPedAnalogControlState(thePed, "brake_reverse", 1-(s*1/maxspd)) setPedAnalogControlState(thePed, "accelerate", 0) setPedControlState(thePed, "handbrake", false) if(s > 10) then setPedControlState(thePed, "handbrake", true) else if(rot > 0) then setPedAnalogControlState(thePed, "vehicle_left", (rot)/20) else setPedAnalogControlState(thePed, "vehicle_right", -(rot)/20) end end else if(rot > 0) then setPedAnalogControlState(thePed, "vehicle_right", (rot)/20) else setPedAnalogControlState(thePed, "vehicle_left", -(rot)/20) end setPedAnalogControlState(thePed, "brake_reverse", 0) setPedControlState(thePed, "handbrake", false) if(s < maxspd) then setPedAnalogControlState(thePed, "accelerate", 1-(s*1/maxspd)) else setPedAnalogControlState(thePed, "accelerate", 0) setPedAnalogControlState(thePed, "brake_reverse", (s/maxspd)-1) end end end end setTimer(UpdateBot, 50, 0) Demo
  6. function scriptCreateTank ( commandName ) local luckyBugger = getLocalPlayer() -- get the local player local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position local theVehicle = createVehicle ( 404, x, y, z + 10 ) -- create the tank 10 units above them setElementData(theVehicle, "model", 737) outputChatBox ( "You got Tank'd!", 255, 0, 0) end --Attach the 'scriptCreateTank' function to the "tank" command addCommandHandler ( "tank", scriptCreateTank ) [M]Province Надо указать новый ID модели setElementData(theVehicle, "model"). Модель которая указывается в createVehicle значения не имеет, главное чтобы была в диапазоне от 400 до 611. Во время события onClientElementStreamIn он читает новую модель, и занимает свободный слот в диапазоне игровых моделей от 400 до 611 с учетом типа транспортного средства, в данном случае "Automobile". При событии onClientElementStreamOut он освобождает раннее занятый слот.
  7. Для добавления новой модели, например на ID 737. Надо закинуть файлы txd и dff новой модели в папку models/ Добавить в meta.xml <file src="models/NewModel.dff" type="client" download="false" /> <file src="models/NewModel.txd" type="client" download="false" /> И добавить название модели в client.lua local ModelsName = { ... [736] ... [737] = {"models/NewModel", "Automobile"}, } Перед запуском скрипт надо распаковать. Ну и скачивать его соответственно с https://github.com/alexaxel705/Unlimited-Vehicle Для спауна авто используй функцию CreateVehicle() в server.lua Демонстрация работы скрипта: http://109.227.228.4/Unlimited-Vehicle-System.mp4
  8. local wind = false function checkTime() local h, _ = getTime() if(h == 6) then if(not isElement(wind)) then wind = createObject(1337,2321.5, -1659.5,13.5) outputChatBox("Object created") end else if(isElement(wind)) then destroyElement(wind) outputChatBox("Object destroyed") end end end addEventHandler("onClientRender", getRootElement(), checkTime)
  9. alexaxel705

    vehicle nodes

    Alternative vehicle-node script https://github.com/alexaxel705/vehicle-node Debug mode:
  10. I updated this function in June 2017 If today the question is relevant, then here is a stable solution local identityMatrix = { [1] = {1, 0, 0}, [2] = {0, 1, 0}, [3] = {0, 0, 1} } function QuaternionTo3x3(x,y,z,w) local matrix3x3 = {[1] = {}, [2] = {}, [3] = {}} local symetricalMatrix = { [1] = {(-(y*y)-(z*z)), x*y, x*z}, [2] = {x*y, (-(x*x)-(z*z)), y*z}, [3] = {x*z, y*z, (-(x*x)-(y*y))} } local antiSymetricalMatrix = { [1] = {0, -z, y}, [2] = {z, 0, -x}, [3] = {-y, x, 0} } for i = 1, 3 do for j = 1, 3 do matrix3x3[i][j] = identityMatrix[i][j]+(2*symetricalMatrix[i][j])+(2*w*antiSymetricalMatrix[i][j]) end end return matrix3x3 end function getEulerAnglesFromMatrix(x1,y1,z1,x2,y2,z2,x3,y3,z3) local nz1,nz2,nz3 nz3 = math.sqrt(x2*x2+y2*y2) nz1 = -x2*z2/nz3 nz2 = -y2*z2/nz3 local vx = nz1*x1+nz2*y1+nz3*z1 local vz = nz1*x3+nz2*y3+nz3*z3 return math.deg(math.asin(z2)),-math.deg(math.atan2(vx,vz)),-math.deg(math.atan2(x2,y2)) end function fromQuaternion(x,y,z,w) local matrix = QuaternionTo3x3(x,y,z,w) local ox,oy,oz = getEulerAnglesFromMatrix( matrix[1][1], matrix[1][2], matrix[1][3], matrix[2][1], matrix[2][2], matrix[2][3], matrix[3][1], matrix[3][2], matrix[3][3] ) return ox,oy,oz end local rotx, roty, rotx, rotw = 0, 0, 0.190809, 0.9816272 -- you can read the Quaternion from IPL file createObject(1337, 5540.6654, 1020.55122, 1240.545, fromQuaternion(rotx, roty, rotx, rotw))
  11. function enLVPD2(source, interior, vehicle) if(getElementType(source) == "player") then local vehicle = getPedOccupiedVehicle(source) if vehicle then outputChatBox("* Выйдите из Т/С", source, 255, 255, 0) else local accName = getAccountName ( getPlayerAccount ( source ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "LVPD" and "Admin" ) ) then setElementInterior ( source, 3, 238.68228, 141.67117, 1003.02344 ) else outputChatBox("*У Вас нет пропуска", thaPlayer, 255, 255, 0) end end end end addEventHandler ("onMarkerHit", m, enLVPD2 )
  12. function putPlayerInPosition(timeslice) local cx,cy,cz,ctx,cty,ctz = getCameraMatrix() ctx,cty = ctx-cx,cty-cy timeslice = timeslice*0.1 if getKeyState("num_7") then timeslice = timeslice*4 end if getKeyState("num_9") then timeslice = timeslice*0.25 end local mult = timeslice/math.sqrt(ctx*ctx+cty*cty) ctx,cty = ctx*mult,cty*mult if getKeyState("w") then abx,aby = abx+ctx,aby+cty end if getKeyState("s") then abx,aby = abx-ctx,aby-cty end if getKeyState("d") then abx,aby = abx+cty,aby-ctx end if getKeyState("a") then abx,aby = abx-cty,aby+ctx end if getKeyState("space") then abz = abz+timeslice end if getKeyState("lshift") then abz = abz-timeslice end setElementRotation(localPlayer,0,0, getPedCameraRotation(localPlayer), "ZXY", true) setElementPosition(localPlayer,abx,aby,abz) end function toggleAirBrake() air_brake = not air_brake or nil if air_brake then abx,aby,abz = getElementPosition(localPlayer) addEventHandler("onClientPreRender",root,putPlayerInPosition) else abx,aby,abz = nil removeEventHandler("onClientPreRender",root,putPlayerInPosition) end end bindKey("num_0","down",toggleAirBrake)
  13. В .client local All3DText = {} for _, source in ipairs(getElementsByType("pickup", true)) do -- Этот участок кода необходим если планируешь перезапускать текущий ресурс local text = getElementData(source, "3DText") if(text) then All3DText[source] = text end end addEventHandler("onClientElementStreamIn", getRootElement(), function() if getElementType(source) == "pickup" then local text = getElementData(source, "3DText") if(text) then All3DText[source] = text end end end ); addEventHandler("onClientElementStreamOut", getRootElement(), function() if getElementType(source) == "pickup" then local text = getElementData(source, "3DText") if(text) then All3DText[source] = nil end end end ); function dxDrawBorderedText(text,left,top,right,bottom,color,scale,outlinesize,font,alignX,alignY,clip,wordBreak,postGUI,colorCoded) local outlinesize = math.min(scale,outlinesize) if outlinesize > 0 then for offsetX=-outlinesize,outlinesize,outlinesize do for offsetY=-outlinesize,outlinesize,outlinesize do if not (offsetX == 0 and offsetY == 0) then dxDrawText(text:gsub("#%x%x%x%x%x%x",""), left+offsetX, top+offsetY, right+offsetX, bottom+offsetY, tocolor(0, 0, 0, 255), scale, font, alignX, alignY, clip, wordBreak, postGUI) end end end end dxDrawText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded) end function nameText() local cx,cy,cz = getCameraMatrix() for pickup, text in pairs(All3DText) do local px,py,pz = getElementPosition(pickup) local distance = getDistanceBetweenPoints3D(cx,cy,cz,px,py,pz) local posx,posy = getScreenFromWorldPosition(px,py,pz+0.025*distance+0.40) if posx and distance <= 15 then dxDrawBorderedText(text,posx,posy,posx,posy,tocolor(255,175,0,255),1,1,"default-bold","center","top",false,false,false) end end end addEventHandler("onClientHUDRender",root,nameText) В .server setElementData(housePickup, "3DText", "Мой 3D текст")
  14. Сила Lua - в таблицах. Имей ввиду что индекс первого элемента таблицы начинается с 1 а не с 0 как во многих языках программирования. http://www.lua.ru/doc/5.6.html Математика везде используется. Готовые функции помогают улучшить восприятие кода. https://wiki.multitheftauto.com/wiki/Category:Useful_Functions Тут пользовательских функций полно, во многих случаях позволяют не углубл*ться в высшую математику, аля матрицы шматрицы. Для интеграции с веб сервером можно использовать https://wiki.multitheftauto.com/wiki/PHP_SDK Для стандартизированной мультиязычностиязычной системы можно использовать например https://www.transifex.com/. Рекомендую изначально исходный язык делать английским. Так как в будущем проще будет на остальные языки перевести. Создай страницу на https://github.com/. Совместно с другими разрабатывай скрипты. Часто в OpenSource проектах единомышленники интерес проявляют. За одно ошибки поправят твои, да и труды твои не пропадут на случай если забросишь это дело.
  15. local mouseSensitivity = 0.3 local invertMouseLook = false local speed = 0 local strafespeed = 0 local rotX, rotY = 0,0 local function freecamFrame () local cameraAngleX = rotX local cameraAngleY = rotY local freeModeAngleZ = math.sin(cameraAngleY) local freeModeAngleY = math.cos(cameraAngleY) * math.cos(cameraAngleX) local freeModeAngleX = math.cos(cameraAngleY) * math.sin(cameraAngleX) local camPosX, camPosY, camPosZ = getCameraMatrix() local camTargetX = camPosX + freeModeAngleX * 100 local camTargetY = camPosY + freeModeAngleY * 100 local camTargetZ = camPosZ + freeModeAngleZ * 100 local camAngleX = camPosX - camTargetX local camAngleY = camPosY - camTargetY local camAngleZ = 0 local angleLength = math.sqrt(camAngleX*camAngleX+camAngleY*camAngleY+camAngleZ*camAngleZ) local camNormalizedAngleX = camAngleX / angleLength local camNormalizedAngleY = camAngleY / angleLength local camNormalizedAngleZ = 0 local normalAngleX = 0 local normalAngleY = 0 local normalAngleZ = 1 local normalX = (camNormalizedAngleY * normalAngleZ - camNormalizedAngleZ * normalAngleY) local normalY = (camNormalizedAngleZ * normalAngleX - camNormalizedAngleX * normalAngleZ) local normalZ = (camNormalizedAngleX * normalAngleY - camNormalizedAngleY * normalAngleX) camPosX = camPosX + freeModeAngleX * speed camPosY = camPosY + freeModeAngleY * speed camPosZ = camPosZ + freeModeAngleZ * speed camPosX = camPosX + normalX * strafespeed camPosY = camPosY + normalY * strafespeed camPosZ = camPosZ + normalZ * strafespeed camTargetX = camPosX + freeModeAngleX * 100 camTargetY = camPosY + freeModeAngleY * 100 camTargetZ = camPosZ + freeModeAngleZ * 100 setCameraMatrix ( camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ ) end local function freecamMouse (cX,cY,aX,aY) local width, height = guiGetScreenSize() aX = aX - width / 2 aY = aY - height / 2 if invertMouseLook then aY = -aY end rotX = rotX + aX * mouseSensitivity * 0.01745 rotY = rotY - aY * mouseSensitivity * 0.01745 local PI = math.pi if rotX > PI then rotX = rotX - 2 * PI elseif rotX < -PI then rotX = rotX + 2 * PI end if rotY > PI then rotY = rotY - 2 * PI elseif rotY < -PI then rotY = rotY + 2 * PI end if rotY < -PI / 2.05 then rotY = -PI / 2.05 elseif rotY > PI / 2.05 then rotY = PI / 2.05 end end function FreeCameraEnable(command, h) setCameraMatrix(x, y, z) addEventHandler("onClientRender", root, freecamFrame) addEventHandler("onClientCursorMove",root, freecamMouse) end addCommandHandler("startcam", FreeCameraEnable) function FreeCameraDisable(command, h) setCameraTarget(localPlayer) removeEventHandler("onClientRender", root, freecamFrame) removeEventHandler("onClientCursorMove",root, freecamMouse) end addCommandHandler("stopcam", FreeCameraDisable) Команда /startcam активирует, /stopcam деактивирует. Для перемещения камеры по клавишам надо дописывать скрипт. Всё уже реализовано в mods\deathmatch\resources\[editor]\freecam.zip