Jump to content

_Ace

Members
  • Posts

    67
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by _Ace

  1. o codigo ta testado, é só para exemplo e: table.insert takes an optional index parameter to insert into the middle of an array
  2. se ja nao tiver criado uma tabela no seu codigo, crie uma, dai nela armazene os objetos logo depois da linha 8 ali, use table.insert(nomedatabela,objetocriado) depois pra deletar vc pode criar um comando ou adaptar no seu codigo como gui etc, fiz 2 comandos pra demonstrar, tem outros jeitos de fazer, esse é só um exemplo em clientside: objs={}--tabela onde armazena objetos function cobj() local x,y,z=getElementPosition(localPlayer) local o=createObject(1238,x+math.random(10),y+math.random(10),z) table.insert(objs,o)--insere objetos end addCommandHandler("crob",cobj)--comando pra criar objetos perto do jogador function dobj() destroyElement(objs[#objs])--apaga ultimo item baseado no tanto de item na tabela table.remove(objs,#objs)--remove ultimo item pra nao ficar em branco end addCommandHandler("delobj",dobj)--comando pra deletar os objetos do ultimo até o primeiro
  3. from the 256+ indexes returned the first ones are bass, not sure what you are trying to do with the bass data, but if it is some visual effect you can check if those indexes met some value, something like if index[1]>0.3 then bass met = apply effect
  4. I think the problem maybe the scroll identified by the event is firing without the calculations, anyway let me know when you solve the problem
  5. so everything works but wheen resizing the bug appears? I see you alternated between the normal attachelements and the one with calculations with same results, this shouldn't happen maybe its the wheel size different then mine, try this line inside the onclientprerender function: attachElements(wheel1, vehicle, px1, py1, pz1+getElementDistanceFromCentreOfMassToBaseOfModel(wheel1)*getObjectScale(wheel1)-getElementDistanceFromCentreOfMassToBaseOfModel(wheel1)*0.70, wrx1, wry1, wrz1) this 0.70 is a offset increment to adjust the wheel Z, you change this value a bit more or less to check if it helps, the thing is using this line, the center of the whell should go up or down depending on the scroll and not stay in the same height, if its not happening check db3 if something is returning null btw, if you need I can send my full code to check if something helps, you can still do yours for the features you are adding like the wheel thickness etc
  6. yes thats correct, the onclientprerender will only do the positioning and rotation, and the onClientGUIScrollon function will only do the resizing, I dont get why you are getting those bugs since my function appears to be the same as yours, also I tested with 4 wheels no problem, just add the 4 objects and each one has its positions and attachelements, my function looks like this: command function = [create gui and hide normal car wheels; done once=(create 4 wheels objects and scale then to 0.7 just to first visual effect; start the onclienprerender function) ] onclientguiscroll function = [scale each wheel using the scroll position / 100] onclientprerender function = [ getVehicleComponentRotation for each wheel; getVehicleComponentPosition for each wheel; attachelements for each wheel ] maybe your onclientprerender function is auto incrementing some global variable, pls send your onclientprerender function
  7. you need to set 2 lines handling the attachments of wheels (attachelements) and they should be the same (the params), or this wheel jumping effect will happen, because the onclientprerender is fighting with the scrollbar event, so you can try setting the wheel size in a separate function from the onclientprerender, also check if your gui function is not recreating the wheel or reseting some variables, the way i did: the function that opens the gui create the wheel and attach to the car using offsets by getelementcomponentposition, and start the function with the onclientprerender, this is done once if I open the gui again, I have a if with return to prevent double execution, its looking like this: edit: I will try setting the 4 wheels to check if any bugs with the scrollbar
  8. https://wiki.multitheftauto.com/wiki/IsPedAiming https://wiki.multitheftauto.com/wiki/SetPlayerHudComponentVisible https://wiki.multitheftauto.com/wiki/DxDrawCircle https://wiki.multitheftauto.com/wiki/DxDrawLine https://wiki.multitheftauto.com/wiki/OnClientPreRender
  9. send your code, maybe the glitch is related to the scrollbar, I did some testing and the suspension effect is posible with setting a variable (z of https://wiki.multitheftauto.com/wiki/GetVehicleComponentPosition) to the attachelements Z offset instead of fixed number, for now it is required to adjust Z+- if trying with other car, but testing with one car the object wheel looks like a real one managed from gta, no bugs resizing or while driving
  10. I didnt see the angle problem before, I tested here and got the same wheel angle problem in the image you sent, the fix is simple: instead of using setelementrotation in the onclientprerender, use the last tree arguments in attachelements (the angle ones): attachElements(roda,getPedOccupiedVehicle(localPlayer),rodax,roday,rodaz+getElementDistanceFromCentreOfMassToBaseOfModel(roda)*getObjectScale(roda)-getElementDistanceFromCentreOfMassToBaseOfModel(roda),rodarx,rodary,rodarz) so I removed the setelementrotation and set the attachelements above to handle rotations, works nice at any angle plus seems to remove the wobbling, about the suspension I will do some more testing, and to remove the db3 warning you can set a command with a global flag to check if the code should proceed or halt, use if to check if the flag is true or false, if false use return, something like: if not wheelmanipulation then return end
  11. I made a video to show how its working, Im not sure if is the same effect you trying to do the part the changes the position while resizing is something like: addEventHandler("onClientGUIScroll", root, function(element) setObjectScale(roda,guiScrollBarGetScrollPosition(element)/10) attachElements(roda,getPedOccupiedVehicle(localPlayer),rodax,roday,rodaz+getElementDistanceFromCentreOfMassToBaseOfModel(roda)*getObjectScale(roda)-getElementDistanceFromCentreOfMassToBaseOfModel(roda)) end) with roda being the wheel object and rodax,roday,rodaz the attachelements offsets, to make the wheel object rotate with the real wheel I made a onclienprerender event getting the car z rotation and the wheel rotations: function rodarot() local vrotx,vroty,vrotz=getElementRotation(getPedOccupiedVehicle(localPlayer)) local rodarx,rodary,rodarz=getVehicleComponentRotation(getPedOccupiedVehicle(localPlayer),"wheel_rf_dummy") setElementRotation(roda,rodarx,rodary,rodarz+vrotz) end this code is not optimized nor checking for warnings/errors, just an example for use in a proper code
  12. I tested with: attachElements(wheel,getPedOccupiedVehicle(localPlayer),wheelx,wheely,whellz+getElementDistanceFromCentreOfMassToBaseOfModel(whell)*getObjectScale(whell)-getElementDistanceFromCentreOfMassToBaseOfModel(whell)) which means: position z of attached wheel + half the radius of the wheel multiplied by wheel scale + half the radius of the wheel the object wheel stayed in ground while resizing with the scrollbar, I will do some more testing regarding the rotations and soon I send you the example code
  13. I made a example, go to coords 0,0,0 and test the command: server: createPickup(0,0,10, 3, 1247) createPickup(0,5,20, 3, 1254) createPickup(10,0,10, 3, 1248) client: function pks() for i,p in ipairs(getElementsByType("pickup")) do local x,y,z=getElementPosition(localPlayer) local xb,yb,zb=getElementPosition(p) local sx,sy=getScreenFromWorldPosition(x,y,z+0.7) local sxb,syb=getScreenFromWorldPosition(xb,yb,zb) if isElement(p) and isElementOnScreen(p) and isLineOfSightClear(x,y,z+0.7,xb,yb,zb) and getDistanceBetweenPoints3D(x,y,z,xb,yb,zb)<400 then dxDrawLine(sx,sy,sxb,syb,tocolor(255, 255, 255)) dxDrawText("pickup id: "..getElementModel(p),sxb,syb,_,_,tocolor(255, 255, 0)) end end end function pksr() addEventHandler("onClientRender", root, pks) end addCommandHandler("pkps",pksr) I will list pickup ids within 400m, in camera angle and not blocked by objects (from skin position) I tested and its working but its just a test code, not checked for warnings or exception handling
  14. you need the wheels at ground level while moving the scrollbar? you can change the attachelements z offset, then you will need to calc the distance from the center off the wheel (the attached one) using https://wiki.multitheftauto.com/wiki/GetGroundPosition and https://wiki.multitheftauto.com/wiki/GetElementDistanceFromCentreOfMassToBaseOfModel Im not sure if this will work with resized object, but if not, you can https://wiki.multitheftauto.com/wiki/GetObjectScale to do the math, about the wheel rotations you can use: https://wiki.multitheftauto.com/wiki/GetVehicleComponentRotation and setElementRotation
  15. replace the second tank model to the swat tank or firetruck, (you need a vehicle with a turret) then attach the second tank to a rhino, make the rhino invisible using setElementAlpha, put a timer serverside, to get the rhino turret position and set it to the attached second tank (getVehicleTurretPosition and getVehicleTurretPosition) and you are done, the turret movement will not be super smooth even using 30ms timer, if you want smooth turret movement use onClientPreRender, but this will require more code to sync to the clients, I tested the server solution and it works fine, 2 tanks with functional cannons
  16. use https://wiki.multitheftauto.com/wiki/SetCameraShakeLevel ou https://community.multitheftauto.com/index.php?p=resources&s=details&id=11174 seguindo as instruções da descrição
  17. https://wiki.multitheftauto.com/wiki/FindRotation get player position and ped position, set their x and y in the findRotation params, then set the npc rotation with the returned value from findRotation, use setPedRotation to do so
  18. se eu entendi direito vc precisa as coordenadas do mapa f11 atraves de click ou algo assim? tem essa funcao getPlayerMapBoundingBox que talvez ajude, peguei esse exemplo da wiki, local screenSize = Vector2(guiGetScreenSize()) local function handleMapTargetBlip() if not isPlayerMapVisible() then showCursor(false, false) wasLeftMouseButtonPressed, wasRightMouseButtonPressed = false, false return end if not isCursorShowing() then showCursor(true, false) end local isLeftMouseButtonPressed = getKeyState("mouse1") if isLeftMouseButtonPressed and isLeftMouseButtonPressed ~= wasLeftMouseButtonPressed then local cursorPos, mapMin, mapMax = Vector2(getCursorPosition()) cursorPos.x, cursorPos.y = cursorPos.x * screenSize.x, cursorPos.y * screenSize.y do local mx, my, Mx, My = getPlayerMapBoundingBox() mapMin = Vector2(mx, my) mapMax = Vector2(Mx, My) end if cursorPos.x >= mapMin.x and cursorPos.y >= mapMin.y and cursorPos.x <= mapMax.x and cursorPos.y <= mapMax.y then local relPos = Vector2((cursorPos.x - mapMin.x) / (mapMax.x - mapMin.x), (cursorPos.y - mapMin.y) / (mapMax.y - mapMin.y)) local worldPlanePos = Vector2(6000 * (relPos.x - 0.5), 3000 - (relPos.y * 6000)) local worldPos = Vector3(worldPlanePos.x, worldPlanePos.y, getGroundPosition(worldPlanePos.x, worldPlanePos.y, 3000)) outputChatBox("x: "..worldPlanePos.x.." y: "..worldPlanePos.y.." z: "..getGroundPosition(worldPlanePos.x, worldPlanePos.y, 3000)) end end end addEventHandler("onClientRender", root, handleMapTargetBlip) e editei uma linha pra que saia as coords no chat quando clica no mapa do f11, mesmo que seu mapa seja diferente do padrao do mta vc pode aproveitar o algoritmo, as coords Z precisa estar perto do player pro getgroundposition funcionar, ou precisa teleportar antes o player pra perto pra carregar os dados de coll e ai sim achar a position Z do chao
  19. _Ace

    Ayuda con una GM

    el error "mysql module missing" te falta el modulo mysql https://wiki.multitheftauto.com/wiki/Modules/MTA-MySQL en el link estan las instrucciones para instalar
  20. variable p and acc are undefined or out of scope, because of the timer creating a function inside the function, remove the local to see if it works
  21. ta saindo o som para todos pq o evento ta especificado pra disparar em todos os clients (players), se for pra quem usou o som, e mais quem estiver por perto, deixe o evento como ta mas use o playSound3d https://wiki.multitheftauto.com/wiki/PlaySound3d especificando as coordenadas do player (que ta emitindo o som), dai ajusta a distancia que pode ser ouvido com setSoundMaxDistance
  22. yes using shaders to the smoke texture
  23. I need to see your code to answer properly, but to trigger js function from mta you need to use: executeBrowserJavascript(yourbrowser, "yourjavascriptfuncion()")
  24. try this: function dxDrawImageOnElement(TheElement,Image,distance,height,width,R,G,B,alpha) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local width = width or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance*width)-1+width, x, y, z+height, Image, width-(distanceBetweenPoints/distance*width), tocolor(R or 255, G or 255, B or 255, alpha or 255)) end end end end I edited the line: dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance*width)-1+width, x, y, z+height, Image, width-(distanceBetweenPoints/distance*width), tocolor(R or 255, G or 255, B or 255, alpha or 255)) to make the width parameter to work as scale/resize, use dxDrawImageOnElement with 4 in parameter width for example, will make the image 4x larger
  25. you can create the colshape in the serverside and trigger the event using onColShapeHit, or you can add the colshapes clientside right after you create the items serverside (if those itens are objetcs) you can get server objects information in clientside using getElementsByType("object") example: function tobj() for i,o in ipairs(getElementsByType("object")) do local x,y,z=getElementPosition(o) outputChatBox("model: "..getElementModel(o).." position: "..x.." "..y.." "..z) end end addCommandHandler("testeobj", tobj) this will get the model and position of all objetcs (if there are any), if your itens are not objects then you can still create the colshapes serverside or clientside using the coords in your item table, use triggerClientEvent to send the coords if you want to create the colshape in the client, btw you can still use the area near system without the colsphapes, just a matter of optimizing like majqq said
×
×
  • Create New...