Al3grab Posted April 6, 2012 Posted April 6, 2012 hi , i made something like Mega Punch cheat 'IAVENJQ' in normal mode .. so i want the ped that i hit fly away with the direction of the hit. i just made this to make him fly away .. for k=0,20 do --source : the ped , attacker : the player that attacked him x,y,z = getElementPosition(source) setElementPosition(source,x,y+0.1,z+0.1) end but he wont fly with the hit direction , i know that could be done with maths that i am not good at any help ING : [xXx]~Al3grab
X-SHADOW Posted April 6, 2012 Posted April 6, 2012 function hit (killer, killerweapon, bodypart) if (killer) and (killer ~=source) then local x,y,z = getElementPosition(source) setElementPosition(source,x,y+0.1,z+0.1) outputChatBox('You Got Hit an Moved to BlaBlaBla',source,255,255,0) end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), hit) My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Al3grab Posted April 6, 2012 Author Posted April 6, 2012 function hit (killer, killerweapon, bodypart) if (killer) and (killer ~=source) then local x,y,z = getElementPosition(source) setElementPosition(source,x,y+0.1,z+0.1) outputChatBox('You Got Hit an Moved to BlaBlaBla',source,255,255,0) end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), hit) -_-" , did you read the post ? ING : [xXx]~Al3grab
X-SHADOW Posted April 6, 2012 Posted April 6, 2012 i want the ped that i hit fly away with the direction of the hit. thats my script do ? My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Moderators IIYAMA Posted April 6, 2012 Moderators Posted April 6, 2012 "direction of the hit" You must get the attacker(not killer) position to. This is what he means!!! Sample: (this is with gun) attacker = left player = center fly direction = left > direction of the hit Al3grab is asking a big script with math stuff. I hope you understand what he means now, because I hate this kind of math. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Cassandra Posted April 6, 2012 Posted April 6, 2012 You can make use of setPedGravity when player punches then set a timer to change back the gravity to normal. Regards, Cassandra - V:MP
Al3grab Posted April 6, 2012 Author Posted April 6, 2012 "direction of the hit"You must get the attacker(not killer) position to. This is what he means!!! Sample: (this is with gun) attacker = left player = center fly direction = left > direction of the hit Al3grab is asking a big script with math stuff. I hope you understand what he means now, because I hate this kind of math. thanks for explaining that for him You can make use of setPedGravity when player punches then set a timer to change back the gravity to normal. nice idea , i tried that but it wasn't that good , so i made this .. it works but need for improving . x,y,z = getElementPosition(source) -- get the ped pos setElementPosition(source,x,y,z+4) -- fly him up power = 100 -- number of loops .. for k=0,power do x,y,z = getElementPosition(source)-- get the ped pos rot = getPedRotation(attacker)-- get the attacker rotation if rot > 45 and rot < 140 then -- Hit From Right setElementPosition(source,x-0.1,y,z) elseif rot > 200 and rot < 300 then -- Hit From Left setElementPosition(source,x+0.1,y,z) elseif rot > 90 and rot < 270 then -- Hit From Front setElementPosition(source,x,y-0.1,z) else -- Hit From Back .. betrayer setElementPosition(source,x,y+0.1,z) end end does anyone have something better ? thanks all . ING : [xXx]~Al3grab
arezu Posted April 6, 2012 Posted April 6, 2012 local power = 1 local powerUp = 0.5 addEventHandler("onClientPedDamage", getRootElement(), function(attacker) -- attacker == getLocalPlayer() because setElementVelocity is synced with server if(attacker and attacked ~= source and attacker == getLocalPlayer())then local aPosX, aPosY, aPosZ = getElementPosition(attacker) local sPosX, sPosY, sPosZ = getElementPosition(source) local angle = math.atan2(aPosX - sPosX, aPosY - sPosY) - math.rad(90) local velX, velY, velZ = getElementVelocity(source) setElementVelocity(source, velX + power*-math.cos(angle), velY + power*math.sin(angle), velZ + powerUp) end end) -- use this to test power addCommandHandler("fuu", function() local posX, posY, posZ = getElementPosition(getLocalPlayer()) local ped = createPed(16, posX, posY + 10, posZ) end)
Al3grab Posted April 6, 2012 Author Posted April 6, 2012 local power = 1 local powerUp = 0.5 addEventHandler("onClientPedDamage", getRootElement(), function(attacker) -- attacker == getLocalPlayer() because setElementVelocity is synced with server if(attacker and attacked ~= source and attacker == getLocalPlayer())then local aPosX, aPosY, aPosZ = getElementPosition(attacker) local sPosX, sPosY, sPosZ = getElementPosition(source) local angle = math.atan2(aPosX - sPosX, aPosY - sPosY) - math.rad(90) local velX, velY, velZ = getElementVelocity(source) setElementVelocity(source, velX + power*-math.cos(angle), velY + power*math.sin(angle), velZ + powerUp) end end) -- use this to test power addCommandHandler("fuu", function() local posX, posY, posZ = getElementPosition(getLocalPlayer()) local ped = createPed(16, posX, posY + 10, posZ) end) WOW ! , that works .. Thank you very much ING : [xXx]~Al3grab
arezu Posted April 6, 2012 Posted April 6, 2012 local power = 1 local powerUp = 0.5 addEventHandler("onClientPedDamage", getRootElement(), function(attacker) -- attacker == getLocalPlayer() because setElementVelocity is synced with server if(attacker and attacked ~= source and attacker == getLocalPlayer())then local aPosX, aPosY, aPosZ = getElementPosition(attacker) local sPosX, sPosY, sPosZ = getElementPosition(source) local angle = math.atan2(aPosX - sPosX, aPosY - sPosY) - math.rad(90) local velX, velY, velZ = getElementVelocity(source) setElementVelocity(source, velX + power*-math.cos(angle), velY + power*math.sin(angle), velZ + powerUp) end end) -- use this to test power addCommandHandler("fuu", function() local posX, posY, posZ = getElementPosition(getLocalPlayer()) local ped = createPed(16, posX, posY + 10, posZ) end) WOW ! , that works .. Thank you very much did it work when punching other players too (non-script created peds) ? i didn't test that.
Al3grab Posted April 6, 2012 Author Posted April 6, 2012 local power = 1 local powerUp = 0.5 addEventHandler("onClientPedDamage", getRootElement(), function(attacker) -- attacker == getLocalPlayer() because setElementVelocity is synced with server if(attacker and attacked ~= source and attacker == getLocalPlayer())then local aPosX, aPosY, aPosZ = getElementPosition(attacker) local sPosX, sPosY, sPosZ = getElementPosition(source) local angle = math.atan2(aPosX - sPosX, aPosY - sPosY) - math.rad(90) local velX, velY, velZ = getElementVelocity(source) setElementVelocity(source, velX + power*-math.cos(angle), velY + power*math.sin(angle), velZ + powerUp) end end) -- use this to test power addCommandHandler("fuu", function() local posX, posY, posZ = getElementPosition(getLocalPlayer()) local ped = createPed(16, posX, posY + 10, posZ) end) WOW ! , that works .. Thank you very much did it work when punching other players too (non-script created peds) ? i didn't test that. i didn't test that , i will test it later .. and if it didn't work i can solve it , thanks again ING : [xXx]~Al3grab
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now