Jump to content

Ajuda para criar script de executar animações


Recommended Posts

Posted

Sou nova na parte de programação em geral, e gostaria de solicitar ajuda em como criar um script simples, que teria o objetivo de fazer o jogador executar uma certa animação do jogo quando digitasse um comando no chat (/dança 1, /chorar, etc...). No caso, para a criação de tal script, como eu faria para iniciar a animação no jogador e como eu iria criar uma função para a mesma ser parada?

Posted
22 minutes ago, Jonas^ said:

O exemplo da wiki é server.

Fiz o script da seguinte forma:

 

<meta>
     <info author="Amanda" type="animation" name="choro" description="Script de chorar" />
     <script src="script.Lua" />
</meta>

bool addCommandHandler ( string chorar, function function toggleSit(thePlayer)
    if not getElementData(thePlayer, "sitting") then
        setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, false)
        setElementData(thePlayer, "sitting", true)
    else
        -- If you use again this command then your character stand up
        setPedAnimation(thePlayer)
        removeElementData(thePlayer, "sitting")
    end
end
addCommandHandler("sit", toggleSit) [, bool caseSensitive = true ] )

 

 

Ele está certo?

Posted (edited)
<meta>
     <info author="Amanda" type="animation" name="choro" description="Script de chorar" />
     <script src="script.Lua"  type="server"/>
</meta>

function toggleSit(thePlayer)
    if not getElementData(thePlayer, "sitting") then
        setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, false)
        setElementData(thePlayer, "sitting", true)
    else
        -- If you use again this command then your character stand up
        setPedAnimation(thePlayer)
        removeElementData(thePlayer, "sitting")
    end
end
addCommandHandler("sit", toggleSit)

Tenta ai agora...

Edited by MesaDowN
  • Thanks 1
Posted
3 hours ago, MesaDowN said:

<meta>
     <info author="Amanda" type="animation" name="choro" description="Script de chorar" />
     <script src="script.Lua"  type="server"/>
</meta>

function toggleSit(thePlayer)
    if not getElementData(thePlayer, "sitting") then
        setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, false)
        setElementData(thePlayer, "sitting", true)
    else
        -- If you use again this command then your character stand up
        setPedAnimation(thePlayer)
        removeElementData(thePlayer, "sitting")
    end
end
addCommandHandler("sit", toggleSit)

Tenta ai agora...

Muito obrigado, agora foi S2

Posted
addCommandHandler ("sit", function (thePlayer, cmd)
	if getElementData (thePlayer, "sitting") then -- Se a data já existir, então:
		setPedAnimation (thePlayer) -- Faz com que o jogador pare s animação.
		removeElementData (thePlayer, "sitting") -- Remove a data do jogador.
	else -- Se ele não possuir a data, então:
		setPedAnimation (thePlayer, "ped", "seat_down", -1, false, false, false, false) -- Seta a animação no jogador.
		setElementData (thePlayer, "sitting", true) -- Seta a data no jogador indicando que ele esta com a animação ativa.
	end
end)

Código um pouco melhorado.

@AmandaT666

  • Thanks 1
Posted
21 hours ago, Jonas^ said:

addCommandHandler ("sit", function (thePlayer, cmd)
	if getElementData (thePlayer, "sitting") then -- Se a data já existir, então:
		setPedAnimation (thePlayer) -- Faz com que o jogador pare s animação.
		removeElementData (thePlayer, "sitting") -- Remove a data do jogador.
	else -- Se ele não possuir a data, então:
		setPedAnimation (thePlayer, "ped", "seat_down", -1, false, false, false, false) -- Seta a animação no jogador.
		setElementData (thePlayer, "sitting", true) -- Seta a data no jogador indicando que ele esta com a animação ativa.
	end
end)

Código um pouco melhorado.

@AmandaT666

No caso, eu jogo o arquivo .Lua na pasta de resource direto ou tem que fazer mais algo para o script rodar? 

Posted
1 hour ago, eicheolli said:

Crie uma pasta dentro de resources. Dentro dessa pasta, crie o meta.xml e o(s) arquivo(s) necessário(s).

No caso, quais são os arquivos necessários?

Posted
4 minutes ago, AmandaT666 said:

No caso, quais são os arquivos necessários?

Crie uma pasta chamada "animacao_chorar", então faça dentro desta pasta

Crie um meta.xml e adicione dentro :

<meta>
     <info author="Amanda" type="animation" name="choro" description="Script de chorar" />
     <script src="script.Lua"  type="server"/>
</meta>

Então dentro da pasta "animacao_chorar" crie outro chamado "script.Lua" (Sem Aspas) e adicione dentro :

addCommandHandler ("sit", function (thePlayer, cmd)
	if getElementData (thePlayer, "sitting") then -- Se a data já existir, então:
		setPedAnimation (thePlayer) -- Faz com que o jogador pare s animação.
		removeElementData (thePlayer, "sitting") -- Remove a data do jogador.
	else -- Se ele não possuir a data, então:
		setPedAnimation (thePlayer, "ped", "seat_down", -1, false, false, false, false) -- Seta a animação no jogador.
		setElementData (thePlayer, "sitting", true) -- Seta a data no jogador indicando que ele esta com a animação ativa.
	end
end)

da refresh no F8 e de um start no resource animacao_chorar.

 

Lembrando, xml e Lua são extensões, ou copie de outro resource já pronto, apenas o meta e o server-side, caso não consiga.

  • Thanks 1
  • Other Languages Moderators
Posted
14 hours ago, Angelo Pereira said:Crie um meta.xml e adicione dentro :

<meta>
     <info author="Amanda" type="animation" name="choro" description="Script de chorar" />
     <script src="script.Lua"  type="server"/>
</meta>

 

O tipo de resource "animation" não existe. Usa-se o tipo "script" em vez disso.

Os tipos válidos são:

"gamemode", "script", "map", "misc".

  • 1 year later...
Posted (edited)
On 10/02/2020 at 19:48, Angelo Pereira said:

Crie uma pasta chamada "animacao_chorar", então faça dentro desta pasta

Crie um meta.xml e adicione dentro :

<meta>
     <info author="Amanda" type="animation" name="choro" description="Script de chorar" />
     <script src="script.Lua"  type="server"/>
</meta>

Então dentro da pasta "animacao_chorar" crie outro chamado "script.Lua" (Sem Aspas) e adicione dentro :

addCommandHandler ("sit", function (thePlayer, cmd)
	if getElementData (thePlayer, "sitting") then -- Se a data já existir, então:
		setPedAnimation (thePlayer) -- Faz com que o jogador pare s animação.
		removeElementData (thePlayer, "sitting") -- Remove a data do jogador.
	else -- Se ele não possuir a data, então:
		setPedAnimation (thePlayer, "ped", "seat_down", -1, false, false, false, false) -- Seta a animação no jogador.
		setElementData (thePlayer, "sitting", true) -- Seta a data no jogador indicando que ele esta com a animação ativa.
	end
end)

da refresh no F8 e de um start no resource animacao_chorar.

 

Lembrando, xml e Lua são extensões, ou copie de outro resource já pronto, apenas o meta e o server-side, caso não consiga.

opa mano usei teu script e deu certo, mas vc sabe como faz pra tipo, quando o player tiver com 20% ou menos de vida executar a animação

Edited by Gab MTA

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...