FelipeMallmann Posted July 28, 2013 Posted July 28, 2013 Eai galera, sou novo aqui, venho do sa-mp e entendo muito pouco sobre .lua.. Mas enfim, andei vendo um tutorial ai sobre Portão, só que nele o portao abria quando o player ia num circulo e fechava quando o player saia. Queria saber se tem como fazer esse mesmo sistema só que com comando e restrito para apenas 1 determinado nick. Aqui tenho exemplo de um codigo, porem pelo o que tem ai creio que o comando de abrir/fechar funcionaria de qualquer lugar e com qualquer player. Queria restringir um comando somente numa area perto do portao e somente para um nick. function createTheGate () portao1 = createObject ( ID, x, y, z, 0, 0, 0) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) function openMyGate ( ) moveObject ( portao1, tempo, x, y, z) end addCommandHandler("abrir",openMyGate) function movingMyGateBack () moveObject ( portao1, tempo, x, y, z) end addCommandHandler("fechar",movingMyGateBack) Outra duvida que tenho é se isso ficaria no client.lua ou em alguma coisa separada. Vlw galera, obrigado a todos
DNL291 Posted July 29, 2013 Posted July 29, 2013 Use getPlayerName em uma condição e verifique se é o nick determinado. Se você quiser obter a distância entre o jogador e o colshape, use getElementPosition + getDistanceBetweenPoints2D Esse código é server-side por causa do evento onResourceStart. Please do not PM me with scripting related question nor support, use the forums instead.
manawydan Posted July 30, 2013 Posted July 30, 2013 tente isso não testado local portao1 = createObject ( ID, x, y, z, 0, 0, 0) function openMyGate (thePlayer) local Nome = getPlayerName(thePlayer) if (Nome == "NickAqui") then local px,py,pz = getElementPosition(thePlayer) local x,y,z = getElementPosition(portao1) local Distancia = getDistanceBetweenPoints2D(px,py,x,y) if (Distancia <=5) then moveObject ( portao1, tempo, x, y, z) end end end addCommandHandler("abrir",openMyGate) function movingMyGateBack (thePlayer) local Nome = getPlayerName(thePlayer) if (Nome == "NickAqui") then local px,py,pz = getElementPosition(thePlayer) local x,y,z = getElementPosition(portao1) local Distancia = getDistanceBetweenPoints2D(px,py,x,y) if (Distancia <=5) then moveObject ( portao1, tempo, x, y, z) end end end addCommandHandler("fechar",movingMyGateBack) troque o 5 para a distancia maxima que vc quer que o jogador possa mover o portao e o "NickAqui" para o nick do cara Ex: "manawydan". "Querer não é poder, mas tentar é avançar"!
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