Jump to content

Swimer

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by Swimer

  1. I give you a BIG thank you! I've been struggling with this problem for 4 days now! You helped me a lot, I thank you!
  2. I created rockets (type 20) using the createProjectile function. But the force in this function only affects throwable objects. Setting velocity at launch or during flight is also useless. Perhaps it makes sense to set the velocity forcibly when calling the function (the last 3 arguments, before the last), but in this case, you need to somehow calculate the velocity for x, y and z. If my version is the best, then you can tell me how to calculate the velocity relative to 2 points. I suppose that I need to get the direction (for example, up: 0, 0, 1, left: 1, 0, 0, etc.) and this direction will be the desired velocity, but I tried this option, although it did not work: local x1,y1,z1 = 1, 2, 3 -- for example local x2,y2,z3 = getElementPosition(object) local directionX, directionY, directionZ = x1 - x2, y1 - y2, z1 - z2 createProjectile(localPlayer, 20, x1, y1, z1, 1, object, 0,0,0, directionX, directionY, directionZ) When using this method, the rocket simply flew somewhere (with the inversion of direction, roughly speaking, the same thing) There is an option to simply launch a regular missile (NOT homing) at the player's position (or a little further), but such a missile is incredibly easy to dodge by gaining the height of the fighter. POSSIBLY, I could implement this if I could change the flight path (for example, a callback when flying each unit up, with the ability to change the trajectory, but if I'm not mistaken, such a callback cannot be done) Let me remind you, I just need to increase the speed of the rocket
  3. Swimer

    2 hydra models

    With weapons, everything is clear, with a crash question. I can assume that the hydra can change the flight mode (horizontal, vertical) and the models are designed for this. Or the game is trying to get aircraft parts that are not in the hydra model (or vice versa).
  4. How do I create a new model, and give it the properties of a hydra. Or is there another way? I have several models that replace the hydra. I tried to replace other models of air vehicles with them, but when spawning some, the game immediately crashes, some explode on spawn due to their height and then crash, and some crash when the plane crashes into an obstacle (explosion). I don’t care about the physics of other aircraft, so can I somehow simply transfer the properties of the hydra to other aircraft models?
  5. No, I haven't tried it yet. This function is on the wiki site itself, but nevertheless when I started googling I didn't find anything
  6. I have a point of my object that needs to be rotated towards another, considering all 3 directions (3D). This, I understand, needs to be solved mathematically.
  7. I have already migrated the inventory system to Jquery-UI Draggable/Droppable
  8. I made my own inventory system, but the problem is that in a normal browser, all objects are transferred perfectly, and nothing happens in the game. Please tell me, is it possible to fix or do my Drag'n'Drop system?
  9. The fact is that I have been selecting the rotation values for an hour and I always get something like this: https://imgur.com/a/Og3pSf8 It turns out that the rotation of 2 axes leads to one
  10. I just copied the code from the MTA documentation, but it doesn't work. Here is the code: *Screenshot* The script registered in meta.xml (client side). Added YouTube to the white list in the MTA settings. And in the end, nothing appears on the screen.
  11. can it be used for my purposes? So that the function returns a string exactly when it was called?
  12. I need to get the result of a server function from an event handler. local plTeam = getPlayerTeam(localPlayer) if plTeam then if isPlayerInTeam(plr, plTeam) then local friend = getPlayerFriend(plr) -- Execute server-side function "getPlayerFriend(player)" text = friend.." ["..id.."]" end end
  13. I'm sorry if I chose the wrong category I know that in regular GTA you can change the physics by replacing the handle.cfg file. How to do it on MTA? And yes, it is also necessary that the client does not replace files manually. I need to change the aircraft physics, as the same hydra can fly in the air at the player's running speed. And it is desirable that these parameters be in the file.
  14. Aahahahahah. Nice. Topic closed. Thank you
  15. I need to get an object that is in front of the camera, but since GTA is a third-person game, the player’s neck or head is almost always in front of the camera, so I need ray to skip my player and continue moving on.
  16. I have a small code that aims to find a car or a player, but the ray starts moving from the camera and crashes into my player, how do I cancel the collision with MY character? if not isPedInVehicle(localPlayer) then local hit, x, y, z, elementHit = processLineOfSight ( ppx, py, pz, tx, ty, tz ) if hit then if elementHit then local sX, sY = getScreenFromWorldPosition( getElementPosition(elementHit) ) -- dxDrawText("G", sX, sY, sX, sY, tocolor(255, 255, 255), 1, "default") dxDrawImage(sX-16*px, sY-16*px, 32*px, 32*px, "assets/icons/PlayerInteract.png") if not (target == elementHit) then target = elementHit end else if target then target = nil end end else if target then target = nil end end end
  17. Oh my god. Thank you! Topic closed.
  18. I have a circle, I know the exact coordinates of its center, I know its radius and diameter, and there is a number of degrees (a number from 0 to 360). How can I draw a picture on the border of a circle, by degree of rotation? I know this can be done using all sorts of sines, cosines, but unfortunately this is a problem for me. *scheme*
  19. You probably misunderstood a little. I want to make a player interaction system, but in your system you just need to refine and make sure that the ray does not touch my player.
  20. local cursorShowing = false bindKey("f2", "down", function() cursorShowing = not cursorShowing showCursor(cursorShowing) end) local nameColor = white local nameSize = 1.2 local nameFont = "pricedown" addEventHandler( "onClientRender", getRootElement(), function( ) for _, plr in ipairs( getElementsByType( "player" ) ) do -- if not (plr == localPlayer) then local x, y, z = getPedBonePosition( plr, 8 ) local sX, sY = getScreenFromWorldPosition( x, y, z ) if sX then local id = getElementData(plr, "id") local text if id then text ="Player ["..id.."]" else text = "Player" end local leftX = sX- dxGetTextWidth(text, nameSize, nameFont )/2 local topY = sY-60 local rightX = leftX local buttonY = topY dxDrawText( text, leftX, topY, rightX, buttonY, nameColor, nameSize, nameSize, nameFont, "left", "top", false, false, false, false, false) end -- end end local w, h = guiGetScreenSize () local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 ) local px, py, pz = getCameraMatrix() local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz ) if hit then if elementHit then local sX, sY = getScreenFromWorldPosition( x, y, z ) dxDrawText("G", sX, sY, sX, sY, "red", 5, 5, "default") end end end )
  21. local w, h = guiGetScreenSize () local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 ) local px, py, pz = getCameraMatrix() local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz ) if hit then if elementHit then local xx,yy,zz = getElementPosition(elementHit) local sX, sY = getScreenFromWorldPosition( xx, yy, zz ) dxDrawText("G", sX, sY, sX, sY, "red", 5, 5, "default") end end I've made a small code from the example, but it doesn't work. What's the matter?
  22. I tried to search on the Internet, but nothing happened, because most likely I do not know how to formulate it correctly. How do I send a ray that starts from the camera, with the direction of the camera, and get the player it hits?
  23. The standard function has 4 necessary arguments, but I have 1, so it's unlikely. But Lua is too specific, so I'll try it now It works! Topic closed
  24. I'm sure not. And yes, this error is exactly when I function from an event handler that is called from the client. And the function works fine when I call it with onPlayerJoin
  25. Sure players = { } function getPlayerData(player) if players[getPlayerSerial(player)] then return players[getPlayerSerial(player)] end return nil end function getPlayerDataById(id) local p = exports.ids:getPlayerByID(id) return getPlayerData(p) end function savePlayerToData(player) if players[player] == nil then updateValue(player, "name", "") updateValue(player, "surname", "") updateValue(player, "sex", "0") -- Биологический пол (не ламинат) 1- мужской, 2 - женский updateValue(player, "lastposition", {2005,1543,13.5}) updateValue(player, "skin", 29) end return players[getPlayerSerial(player)] end function onLogin(username,password,checkboxState, plr) if not (username == "") then if not (password == "") then local account = getAccount ( username, password ) if ( account ~= false ) then logIn(source, account, password) triggerClientEvent (source,"hideLoginPanel",getRootElement()) triggerClientEvent (source,"saveXML",getRootElement(),username,password,tostring(checkboxState)) triggerEvent("spawnPlayerLL", source, plr) else triggerClientEvent(source,"changeMessage",getRootElement(),"1","Добро пожаловать, пожалуйста войдите.", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"1","Пожалуйста, введите Ваш пароль.", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"1","Пожалуйста, введите Ваш логин.", "red") end end addEvent("onLogin",true) addEventHandler("onLogin",getRootElement(),onLogin) function onRegister(username,password) if not (username == "") then if not (password == "") then local account = getAccount (username) if (account == false) then addAccount(tostring(username),tostring(password)) triggerClientEvent(source,"changeMessage",getRootElement(),"2","Вы успешно зарегистрировались.", "green") triggerClientEvent(source,"changeMessage",getRootElement(),"1","Вы успешно зарегистрировались, войдите.", "green") triggerClientEvent(source,"pressBack", getRootElement()) else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Этот логин не доступен.", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Пожалуйста, введите пароль..", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Пожалуйста, введите логин..", "red") end end addEvent("onRegister",true) addEventHandler("onRegister",getRootElement(),onRegister) function updateValue(player, key, value) if not (player == nil) then local p = getPlayerSerial(player) if players[p] == nil then players[p] = {} end players[p][key] = value end end function spawnPlayer(player) if not (player == nil) then local pdata = savePlayerToData(player) local x,y,z = unpack(pdata["lastposition"]) spawnPlayer(player,x,y,z,0,pdata["skin"],0,0) fadeCamera(player, true) setCameraTarget(player, player) end end function on_quit() local x,y,z = getElementPosition(source) updateValue(source, "lastposition", {x,y,z}) end addEventHandler('onPlayerQuit', root, on_quit) local function initScript() resetMapInfo() end addEventHandler("onResourceStart",resourceRoot,initScript) function informPlayerOnModelChange(oldModel, newModel) if ( getElementType(source) == "player" ) then -- Make sure the element is a player updateValue(source, "skin", newModel) end end addEventHandler("onElementModelChange", root, informPlayerOnModelChange) function onLogin(username,password,checkboxState, plr) if not (username == "") then if not (password == "") then local account = getAccount ( username, password ) if ( account ~= false ) then logIn(source, account, password) triggerClientEvent (source,"hideLoginPanel",getRootElement()) triggerClientEvent (source,"saveXML",getRootElement(),username,password,tostring(checkboxState)) spawnPlayer(plr) else triggerClientEvent(source,"changeMessage",getRootElement(),"1","Добро пожаловать, пожалуйста войдите.", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"1","Пожалуйста, введите Ваш пароль.", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"1","Пожалуйста, введите Ваш логин.", "red") end end addEvent("onLogin",true) addEventHandler("onLogin",getRootElement(),onLogin) function onRegister(username,password) if not (username == "") then if not (password == "") then local account = getAccount (username) if (account == false) then addAccount(tostring(username),tostring(password)) triggerClientEvent(source,"changeMessage",getRootElement(),"2","Вы успешно зарегистрировались.", "green") triggerClientEvent(source,"changeMessage",getRootElement(),"1","Вы успешно зарегистрировались, войдите.", "green") triggerClientEvent(source,"pressBack", getRootElement()) else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Этот логин не доступен.", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Пожалуйста, введите пароль..", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Пожалуйста, введите логин..", "red") end end addEvent("onRegister",true) addEventHandler("onRegister",getRootElement(),onRegister) error: "[22:15:04] ERROR: [gameplay]/lunarp/basic/server.lua:81: stack overflow" *code*
×
×
  • Create New...