AmandaT666 Posted February 8, 2020 Posted February 8, 2020 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?
Jonas^ Posted February 8, 2020 Posted February 8, 2020 Se procurasse um pouquinho mais veria que tem 2 exemplos de como fazer isso. SetPedAnimation AddCommandHandler 1
AmandaT666 Posted February 8, 2020 Author Posted February 8, 2020 1 hour ago, Jonas^ said: Se procurasse um pouquinho mais veria que tem 2 exemplos de como fazer isso. SetPedAnimation AddCommandHandler Valeu, mas eu tenho que fazer isso no modo Client ou Server?
AmandaT666 Posted February 8, 2020 Author Posted February 8, 2020 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?
Tommy. Posted February 9, 2020 Posted February 9, 2020 7 hours ago, AmandaT666 said: Ele está certo? Não.
beast99 Posted February 9, 2020 Posted February 9, 2020 (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 February 9, 2020 by MesaDowN 1
AmandaT666 Posted February 9, 2020 Author Posted February 9, 2020 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
Jonas^ Posted February 9, 2020 Posted February 9, 2020 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 1
AmandaT666 Posted February 10, 2020 Author Posted February 10, 2020 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?
eicheolli Posted February 10, 2020 Posted February 10, 2020 Crie uma pasta dentro de resources. Dentro dessa pasta, crie o meta.xml e o(s) arquivo(s) necessário(s). 1
AmandaT666 Posted February 10, 2020 Author Posted February 10, 2020 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?
Angelo Pereira Posted February 10, 2020 Posted February 10, 2020 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. 1
Other Languages Moderators Lord Henry Posted February 11, 2020 Other Languages Moderators Posted February 11, 2020 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".
Gab MTA Posted August 2, 2021 Posted August 2, 2021 (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 August 2, 2021 by Gab MTA
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