local goals ={}local ball ={}
addCommandHandler("fut",function( player )if(getElementData (player,"InGame"))thenreturn
outputChatBox("#FF0000[FUTEBOL] #FFFFFFVocê já esta em campo ! (Digite /sairfut)", player,255,255,255,true)endlocal posX, posY, posZ = getElementPosition( player );
goals ={createObject (16281, posX, posY+25, posZ+1,0,0,180),--Gol 1
createObject (16281, posX, posY-25, posZ+1,0,0,-180)--Gol 2};--16052 \ 16281
ball = createObject (2114, posX, posY, posZ+2,0,0,180);--Bola
moveObject ( ball,1000, posX, posY-0.5, posZ-0.8)local ballX, ballY, ballZ = getElementPosition( ball );local dist = getDistanceBetweenPoints3D ( posX, posY, posZ, ballX, ballY, ballZ)
outputChatBox("#FF0000[FUTEBOL] #FFFFFFVocê começou a jogar futebol !", player,255,255,255,true);
setElementData(player,"InGame",true)
bindKey ( player,"lshift","down", funcInput )
setTimer(function()if(dist >2.1)thenreturnendif(ball ~=nil)then
attachElements ( ball, player,0,0.7,0-0.8)endend,2500,0)end)function funcInput ( player, key, keyState )local state ="let go of"if( keyState =="down")then
state ="pressed"
detachElements ( ball, player )local xb,yb,zb = getElementPosition(player)local rxb,ryb,rzb = getElementRotation(player)local matrixs =(Matrix.create(xb,yb,zb, rxb,ryb,rzb))local forward =(Matrix.getForward(matrixs)*2)local positions =(Matrix.getPosition(matrixs)+ forward)
moveObject ( ball,1000, positions.x, positions.y+25, positions.z-0.8)endendfunction destroyObjects ()for i, v in ipairs(goals)do
destroyElement(goals[i]);endif ball and isElement (ball)then
destroyElement (ball)
ball =nilendend
addCommandHandler("sairfut",function( player )if(getElementData (player,"InGame"))then
destroyObjects ();
outputChatBox("#FF0000[FUTEBOL] #FFFFFFVocê parou de jogar futebol !", player,255,255,255,true);
setElementData(player,"InGame",false)endend)
Guys, this is my soccer system. I have a problem, I'm trying to make when the player presses lshift he kicks the ball and the ball goes ahead of him, I tried a matrix code that I found here in the forum(line 39 at 43), but I could not make it work as I wanted it to work be! can you help me? if I was not clear sorry! and any English error forgive me I'm Brazilian.
Question
Junim
Guys, this is my soccer system. I have a problem, I'm trying to make when the player presses lshift he kicks the ball and the ball goes ahead of him, I tried a matrix code that I found here in the forum(line 39 at 43), but I could not make it work as I wanted it to work be! can you help me? if I was not clear sorry! and any English error forgive me I'm Brazilian.
Edited by Junim0 answers to this question
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