Jump to content

Ryuto

Members
  • Posts

    114
  • Joined

  • Last visited

Everything posted by Ryuto

  1. Olá, estou tentando criar um script onde você possa perseguir um jogador com uma determinada animação. Há um tempo consegui recriar o sistema mas tive dois problemas... A primeira é que adiciono uma animação ao código do script, mas quando o link é reproduzido, o personagem aparece completamente estático, sem qualquer animação. E a segunda é que quando utilizo o bind em altura, o personagem vai para a posição do oponente mas enquanto está em altura e não para a posição no chão. Deixo aqui um vídeo dos erros mencionados para que seja mais fácil entendê-los. Aqui deixo um vídeo do meu problema. e este é o código do meu script local playerSelectedTarget local alpha = 255 local isChasing = false local chaseDuration = 10000 addEventHandler("onClientKey", root, function(key, state) if state and key == "1" and isElement(playerSelectedTarget) then startChasingPlayer() end end ) function startChasingPlayer() if not isChasing then isChasing = true setElementData(localPlayer, "Select", false) setPedAnimation(localPlayer, "ped", "run_player", -1, true, false, false) -- Change "run_player" to the animation name you want !!!!! setTimer(stopChasingPlayer, chaseDuration, 1) end end function stopChasingPlayer() isChasing = false setPedAnimation(localPlayer) end addEventHandler("onClientRender", root, function() if (getKeyState("mouse2") == true) then local x, y, z = getElementPosition(localPlayer) for k, target in ipairs(getElementsByType("player", root, true)) do if not (target == localPlayer) then local px, py, pz = getElementPosition(target) local distance = getDistanceBetweenPoints3D(px, py, pz, x, y, z) if playerSelectedTarget ~= localPlayer and (distance < 30) then playerSelectedTarget = target alpha = 255 setElementData(localPlayer, "Select", true) end end end if isElement(playerSelectedTarget) then local Px, Py, Pz = getCameraMatrix() local zhx, zhy, zhz = getPedBonePosition(playerSelectedTarget, 3) local dist = getDistanceBetweenPoints3D(Px, Py, Pz, zhx, zhy, zhz) if playerSelectedTarget ~= localPlayer and (dist < 30) then if (isLineOfSightClear(Px, Py, Pz, zhx, zhy, zhz, true, true, false, false, true, false, false, playerSelectedTarget)) then local sxx, syy = getScreenFromWorldPosition(zhx, zhy, zhz + 0.3) if sxx and syy then local size = 1300 / dist dxDrawImage(sxx - (size / 2), syy - (size / 4.5), size, size, "Effect/Select.webp", 0, 0, 0, tocolor(255, 255, 255, alpha), false) end end end end else if isElement(playerSelectedTarget) then alpha = 0 setElementData(localPlayer, "Select", false) end end if isChasing and isElement(playerSelectedTarget) then local px, py, pz = getElementPosition(localPlayer) local targetX, targetY, targetZ = getElementPosition(playerSelectedTarget) local angle = math.atan2(targetY - py, targetX - px) local speed = 0.1 local newX = px + math.cos(angle) * speed local newY = py + math.sin(angle) * speed setElementPosition(localPlayer, newX, newY, pz) end end )
  2. Hello, thanks for entering my publication. I'll give you some context, I'm creating an inventory system for weapons, then you have the option to drop the weapon you have and another player can pick it up. Now the problem I have is that when two players decide to throw a weapon, then you go and try to grab the other player's weapon, the weapon that I threw on the ground is eliminated but not the one that the second player threw. here I leave my code... local colShapes = {} function DropWeapon() local , , r = getElementRotation(source) local x,y,z = getElementPosition(source) setPedAnimation(source, "BOMBER", "BOM_plant_loop",-1,true,false,false,false) setTimer(setPedAnimation, 1500, 1, source, false) takeWeapon(source, 2) obj = createObject(333, x+math.sin(math.rad(-r)) * 1,y+math.cos(math.rad(-r)) * 1, z-1, 90) col = createColSphere(x+math.sin(math.rad(-r)) * 1,y+math.cos(math.rad(-r)) * 1,z, 0.5) colShapes[col] = obj addEventHandler("onColShapeHit", col, function(hitter) if getElementType(hitter) == "player" then if colShapes[source] then outputChatBox("ENTER",hitter,255,255,0,true) bindKey(hitter,"F","down",TakeWeapon) --destroyElement(colShapes[source]) --destroyElement(source) end end end) addEventHandler("onColShapeLeave", col, function(hitter) if getElementType(hitter) == "player" then if colShapes[source] then outputChatBox("EXIT",hitter,255,255,0,true) unbindKey(hitter,"F","down",TakeWeapon) -- colShapes[source] = nil end end end) end addEvent ("dropKatana", true) addEventHandler ("dropKatana", root, DropWeapon) function TakeWeapon(source) if isElement(colShapes[col]) then colShapes[col] = obj colShapes[source] = nil giveWeapon(source, 2, 1, true) setPedAnimation(source, "BOMBER", "BOM_plant_loop",-1,true,false,false,false) setTimer(setPedAnimation, 1500, 1, source, false) unbindKey(source,"F","down",TakeWeapon) destroyElement(colShapes[col]) destroyElement(source) end end thank you!!
  3. Thank you very much, I am getting closer to what I am looking for. but I have two problems... The first is that I add an animation to the script code, but when the link is played, the character appears completely static without any animation. And the second is that when I use the bind while at height, the character goes to the opponent's position but while at height and not to the position on the ground. Here I leave a video of the aforementioned errors so that it is easier to understand them.
  4. Hello how are you? I want to ask if it is possible to use an animation that chases a nearby player that is being targeted. I give an example: Pressing the "1" key while selecting a nearby player activates Woozie's running animation and then begins chasing the player for a certain amount of time. I give an example of what I'm looking for... and this is the code to target a player. local playerSelectedTarget local alpha = 255 addEventHandler("onClientRender", root, function() if ( getKeyState("mouse2") == true ) then local x,y,z = getElementPosition(localPlayer) for k,target in ipairs(getElementsByType("player",root,true)) do if not ( target == localPlayer ) then local px,py,pz = getElementPosition(target) local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z ) if playerSelectedTarget ~= localPlayer and ( distance < 30 ) then --target distanc playerSelectedTarget = target local alpha = 255 setElementData(localPlayer, "Select", true) end end end if isElement(playerSelectedTarget) then local Px,Py,Pz = getCameraMatrix( ) local zhx,zhy,zhz = getPedBonePosition(playerSelectedTarget,3) local dist = getDistanceBetweenPoints3D ( Px, Py, Pz, zhx,zhy,zhz ) if playerSelectedTarget ~= localPlayer and ( dist < 30 ) then --target distanc if ( isLineOfSightClear ( Px, Py, Pz, zhx,zhy,zhz, true, true, false, false, true, false, false, playerSelectedTarget ) ) then local sxx,syy = getScreenFromWorldPosition(zhx,zhy,zhz+0.3) if sxx and syy then local size = 1300 / dist dxDrawImage( sxx - ( size / 2 ), syy - ( size / 4.5 ), size, size, "Effect/Select.webp", 0, 0, 0, tocolor ( 255, 255, 255, alpha ),false) end end end end else if isElement(playerSelectedTarget) then local alpha = 0 setElementData(localPlayer, "Select", false) end end end ) thanks for reading this post.
  5. Thank you very much, it has worked very well for me. I want to ask how I can run the animations server-side so everyone can see them.
  6. Hello, thanks for entering my post. I have a question... Is it possible to create a bind system that when pressing, for example, the "X" key repeatedly, different animations are played? I give an example: I press the "X" key for the first time, doing so plays a dance animation. Then I press the "X" again for the second time and doing so plays the vomiting animation. And so on.
  7. Hello, thanks for entering my post. Is it possible to create an "Aura" effect in MTA? This is pretty much what I'm trying to achieve. I also wanted to ask if it is possible to change the default fire color, without affecting the original fire.
  8. I'm sorry to reopen this post again but I have a question. Is there a way to detect if the player is being selected from another external script so I can execute a function?
  9. Is there a way to recreate this wall walking system at MTA? I know there is a script called "Gravity Wheels" created by user @Ren_712 but it only works on vehicles, I was wondering if there is a way to adapt that system on players? What functions could I use?
  10. Thank you very much, I'm going to try it on my local server. Is there a way for it to work with walls or other objects?
  11. Hello, thanks for entering my post. Is it possible to add a function to an MTA object when interacting with a player? I want to make an object (in this case a ball) explode when it touches a player. I also wanted to ask if it is possible for it to explode upon contact with a wall or any other object on the map. I leave a video showing my problem and what I want to achieve.... What functions could I use to achieve something similar?
  12. Hello!! I was able to create a player selection system but I have a small error. This system only selects a specific player and there is no way to select other nearby players. Is there another way to select other players? For example, by pressing a button or pressing the mouse wheel you can select another nearby player. This is my script code. local playerSelectedTarget local alpha = 255 addEventHandler("onClientRender", root, function() if ( getKeyState("mouse2") == true ) then local x,y,z = getElementPosition(localPlayer) for k,target in ipairs(getElementsByType("player",root,true)) do if not ( target == localPlayer ) then local px,py,pz = getElementPosition(target) local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z ) if playerSelectedTarget ~= localPlayer and ( distance < 30 ) then --target distanc playerSelectedTarget = target local alpha = 255 setElementData(localPlayer, "Select", true) end end end if isElement(playerSelectedTarget) then local Px,Py,Pz = getCameraMatrix( ) local zhx,zhy,zhz = getPedBonePosition(playerSelectedTarget,3) local dist = getDistanceBetweenPoints3D ( Px, Py, Pz, zhx,zhy,zhz ) if playerSelectedTarget ~= localPlayer and ( dist < 30 ) then --target distanc if ( isLineOfSightClear ( Px, Py, Pz, zhx,zhy,zhz, true, true, false, false, true, false, false, playerSelectedTarget ) ) then local sxx,syy = getScreenFromWorldPosition(zhx,zhy,zhz+0.3) if sxx and syy then local size = 1300 / dist dxDrawImage( sxx - ( size / 2 ), syy - ( size / 4.5 ), size, size, "Effect/Select.webp", 0, 0, 0, tocolor ( 255, 255, 255, alpha ),false) end end end end else if isElement(playerSelectedTarget) then local alpha = 0 setElementData(localPlayer, "Select", false) end end end ) I leave a video of my problem so you can see the error. thanks for reading me!!
  13. Is there a function to change this kind of sounds? in this case I want to change the sound of CJ's footsteps. it's possible?
  14. When you get close to a skin or a ped, the ped's voice appears and sounds bad on some skins. How can I remove them so that nothing is heard?
  15. I really appreciate your help, little by little I'm seeing results. I have a small problem, if I hold mouse2 down, the trigger repeats many times. Isn't there another way to detect if the player is being selected without using the trigger? something like an "if" condition to detect if the player is being selected from the serverside. I have another question, is it possible to use a bind when selecting the player so that he performs an animation? for example I select it with mouse2 and if I press the number one button the selected player does an animation. something like this: Local HitPlayer = getPedTarget(thePlayer) if not HitPlayer then return end if HitPlayer and (getElementType(HitPlayer) = "ped" ) then setPedAnimation
  16. I am looking for a system to walk on walls similar to this video. I know there is a script called "Gravity Wheels" created by user @Ren_712 but it only works on vehicles, I would love it to be adapted for normal players. https://community.multitheftauto.com/index.php?p=resources&s=details&id=12899 I can easily afford this system for my server, I just need someone who can recreate it. thanks for entering!!
  17. How can I add something on the server side that will detect when a player is being targeted and when the targeting is detected run something like an animation. I'm looking for something similar to the getPedTarget function but with this selection system. I hope I explained myself well
  18. It worked perfect for me, thank you. I have another question, how can I use that code to detect if the player is being selected? And if so, what method can I use to make the selected player do an animation?
  19. Hello, I am trying to change my position with that of another player with a bind when selecting it. I am looking for something similar to this it happens in the second 00:22 of the video What functions could I use to recreate it?
  20. I have another problem, the default animation has a forward movement when it is on the ground (it is a forward jump) but when it is in the air the animation is played statically without the forward movement. How can I give it that movement while in the air? I hope I explained myself well
  21. Is there any method to protect lua files? Is there a function for the .lua to work only on a server with a certain ip? does "cache=false" protect lua client side well? Thank you!!!
  22. I want to create a system of jumping in the air, but I noticed that when I run an animation in the air or on a fall it doesn't play the animation, it only does it when it hits the ground. How can I run normal animations in the air? What functions can I use?
  23. I would like to know if there is any way to be able to aim or select a player regardless of whether they are far away with the mouse2 or the right button, without the need for a weapon. What functions could I use? This is what I want to try to achieve:
  24. Hello, I am creating an accessory system for my server and my question is how to change the dimensions of a 3d object, there is already a similar system in samp servers and here I leave an example of what I am looking for. https://www.youtube.com/watch?v=hWN5NYcR-qQ&list=LL&index=1&t=494s (See minute 07:47 and also minute 08:04 of the video) Is it possible to do this? What functions could you use to change the width or height dimensions?
  25. Hi, I have an error with the setCameraMatrix function. If I am in the Groove Street position and try to change the camera to focus on the closest beach, when I go back to the normal player camera, it changes position and CJ is seen falling below the ground. Is there a solution for this problem?
×
×
  • Create New...