Al3grab Posted April 6, 2012 Share 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 Link to comment
X-SHADOW Posted April 6, 2012 Share 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) Link to comment
Al3grab Posted April 6, 2012 Author Share 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 ? Link to comment
X-SHADOW Posted April 6, 2012 Share Posted April 6, 2012 i want the ped that i hit fly away with the direction of the hit. thats my script do ? Link to comment
Moderators IIYAMA Posted April 6, 2012 Moderators Share 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. Link to comment
Cassandra Posted April 6, 2012 Share Posted April 6, 2012 You can make use of setPedGravity when player punches then set a timer to change back the gravity to normal. Link to comment
Al3grab Posted April 6, 2012 Author Share 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 . Link to comment
arezu Posted April 6, 2012 Share 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) Link to comment
Al3grab Posted April 6, 2012 Author Share 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 Link to comment
arezu Posted April 6, 2012 Share 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. Link to comment
Al3grab Posted April 6, 2012 Author Share 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 Link to comment
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