Jump to content

alexaxel705

Members
  • Posts

    24
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by alexaxel705

  1. https://github.com/alexaxel705/Map
  2. function VehEnt(theVehicle, seat) if(getElementModel(theVehicle) == 411) then addEventHandler("onClientRender", root, Target) end end addEventHandler("onClientPlayerVehicleEnter", localPlayer, VehEnt) function VehExt(theVehicle, seat) if(getElementModel(theVehicle) == 411) then removeEventHandler("onClientRender", root, Target) end end addEventHandler("onClientPlayerVehicleExit", localPlayer, VehExt)
  3. local screenWidth, screenHeight = guiGetScreenSize() local scalex = (screenWidth/1920) local scaley = (screenHeight/1080) local PlayerBones = {1, 2, 3, 4, 5, 6, 7, 8, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 51, 52, 53, 54} function Target() for _, thePlayer in pairs(getElementsByType("player", root, true)) do local minx, maxx, miny, maxy = screenWidth, 0, screenHeight, 0 for bones in pairs(PlayerBones) do local x,y,z = getPedBonePosition(thePlayer, PlayerBones[bones]) x,y = getScreenFromWorldPosition(x,y,z) if(x and y) then maxx = math.max(x, maxx) maxy = math.max(y, maxy) minx = math.min(x, minx) miny = math.min(y, miny) end end dxDrawLine(maxx, maxy, maxx, miny, tocolor(255,255,255,255), 2) dxDrawLine(maxx, miny, minx, miny, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx, maxy, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, maxx, maxy, tocolor(255,255,255,255), 2) end for _, theVehicle in pairs(getElementsByType("vehicle", root, true)) do local VehicleBones = getVehicleComponents(theVehicle) local minx, maxx, miny, maxy = screenWidth, 0, screenHeight, 0 for bones in pairs(VehicleBones) do local x,y,z = getVehicleComponentPosition(theVehicle, bones, "world") x,y = getScreenFromWorldPosition(x,y,z) if(x and y) then maxx = math.max(x, maxx) maxy = math.max(y, maxy) minx = math.min(x, minx) miny = math.min(y, miny) end end local sizeBox = 10 dxDrawLine(maxx, maxy, maxx+sizeBox, maxy, tocolor(255,255,255,255), 2) dxDrawLine(maxx+sizeBox, maxy, maxx+sizeBox, maxy-sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(maxx, miny, maxx+sizeBox, miny, tocolor(255,255,255,255), 2) dxDrawLine(maxx+sizeBox, miny, maxx+sizeBox, miny+sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, minx+sizeBox, maxy, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, minx, maxy-sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx+sizeBox, miny, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx, miny+sizeBox, tocolor(255,255,255,255), 2) end end function VehEnt() addEventHandler("onClientRender", root, Target) end addEventHandler("onClientPlayerVehicleEnter", localPlayer, VehEnt) function VehExt() removeEventHandler("onClientRender", root, Target) end addEventHandler("onClientPlayerVehicleExit", localPlayer, VehExt)
  4. alexaxel705

    Weather

    https://community.multitheftauto.com/index.php?p=resources&s=details&id=14553 Этот скрипт устанавливает свойственную регионам погоду. This script has its own regional weather base. local WeatherArr = { ["Los Santos"] = {0,1,2,3,4}, ["San Fierro"] = {5,6,7,8,9}, ["Las Venturas"] = {10,11,12}, ["Red County"] = {13,14,15,16}, ["Whetstone"] = {13,14,15,16}, ["Flint County"] = {13,14,15,16}, ["Bone County"] = {17,18,19}, ["Tierra Robada"] = {17,18,19}, ["UNDERWATER"] = {20}, ["Unknown"] = {21, 22}, }
  5. function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end dxDrawText(RGBToHex(getTeamColor(getTeamFromName("Police"))).."Police", 450,40,64,20,tocolor(255,255,255,255),1.00,"default-bold","center","center", nil, nil, nil, true)
  6. function checkwater() if(isPedDoingTask(localPlayer, "TASK_COMPLEX_IN_WATER")) then setElementHealth(localPlayer, getElementHealth(localPlayer)-0.5) end end addEventHandler("onClientPreRender", root, checkwater) in client
  7. @Erema93 Теоретически, для этого необходимо единовременно загрузить более 211 уникальных моделей в радиусе 300 метров. На практике такое трудно представить, разве что какая нибудь пирамида из авто. Theoretically, for this it is necessary to simultaneously load more than 211 unique models within a radius of 300 meters. In practice, it’s hard to imagine, except perhaps some kind of pyramid from a car.
  8. Вот видео инструкция по запуску скрипта.
  9. 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.
  10. alexaxel705

    Area name

    setPlayerHudComponentVisible("area_name", false) in client setPlayerHudComponentVisible(thePlayer, "area_name", false) in server
  11. 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
  12. 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
  13. 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 он освобождает раннее занятый слот.
  14. Для добавления новой модели, например на 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
  15. 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)
  16. Alternative vehicle-node script https://github.com/alexaxel705/vehicle-node Debug mode:
  17. 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))
  18. 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 )
  19. 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)
  20. В .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 текст")
  21. Сила 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 проектах единомышленники интерес проявляют. За одно ошибки поправят твои, да и труды твои не пропадут на случай если забросишь это дело.
  22. 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
  23. Space_Unicorn, Держи, может пригодится, углы поворота объектов уже указаны в эйлерах. не в кватернионах.
  24. http://dev.prineside.com/en/gtasa_samp_model_id/search/?q=lanitewin Из них посмотри, вариантов не много
×
×
  • Create New...