attemptIt Posted November 14, 2010 Share Posted November 14, 2010 Yeah, yes I did try. And yes I'm new at scripting so please help me. This is what I got up to and currently it doesn't work. function joinHandler ( ) local x = 0.0 local y = 0.0 local z = 10.0 spawnPlayer ( source, x, y, z ) fadeCamera ( source, true ) setCameraTarget ( source, source ) outputChatBox ( "Welcome to survivalServer RC:1.00", source ) bindKey ( source, "delete", "both", attackHandler ( tPlayer ) ) end addEventHandler ( "onPlayerJoin", getRootElement ( ), joinHandler ) function loadThings ( ) setGlitchEnabled ( "quickreload", true ) setGlitchEnabled ( "fastmove", true ) setGlitchEnabled ( "fastfire", true ) end addEventHandler ( "onResourceStart", getResourceRootElement ( ), loadThings ) function createVehicleForPlayer ( tPlayer, command, vehicleModel ) local x, y, z = getElementPosition ( tPlayer ) x = x + 1 local cvID = CreateVehicle ( tonumber ( vehicleModel ), x, y, z ) if ( cvID == false ) then outputchatBox ( "Failed to create vehicle. ", tPlayer ) end end addCommandHandler ( "createmevehicle", createVehicleForPlayer ) function attackHandler ( tPlayer ) local players = getElementsByType ( "player" ) local distance = -1 local x, y, z = -1 local ang for theKey, thePlayer in ipairs ( players ) do distance = getDistanceBetweenPoints3D ( getElementPosition ( thePlayer ), getElementPosition ( tPlayer ) ) if ( distance < 1.0 ) then setElementHealth ( thePlayer, getElementHealth ( thePlayer ) - 10 ) x, y, z = getElementPosition ( thePlayer ) setElementVelocity ( thePlayer, x, y, z + 5.0 ) end end end At the setting velocity part I was trying to make the player fly back. So its something like that. Player facing <-- Set Velocity >--- Make them fly back. Please help me. Link to comment
Wojak Posted November 14, 2010 Share Posted November 14, 2010 what is this? x, y, z = getElementPosition ( thePlayer) setElementVelocity ( thePlayer, x, y, z + 5.0 ) Velocity is a vector and you used coordinates as argument... you should make the attackHandler function clientside (players are always synced, so don't worry) and use the getElementMatrix (https://wiki.multitheftauto.com/wiki/GetElementMatrix) function to calculate the vector x, y, z = getElementPosition ( thePlayer) local matrix = getElementMatrix ( theplayer ) local offX = 0 * matrix[1][1] - 2 * matrix[2][1] + 2 * matrix[3][1] + matrix[4][1] local offY = 0 * matrix[1][2] - 2 * matrix[2][2] + 2 * matrix[3][2] + matrix[4][2] local offZ = 0 * matrix[1][3] - 2 * matrix[2][3] + 2 * matrix[3][3] + matrix[4][3] setElementVelocity ( thePlayer, offX - x, offY -y ,offZ -z) my code may not be correct, but experiment with it Link to comment
attemptIt Posted November 14, 2010 Author Share Posted November 14, 2010 Okay, thank you. 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