Gothic Online Forums
onAnimation - Printable Version

+- Gothic Online Forums (https://archive.gothic-online.com)
+-- Forum: Scripting (English) (https://archive.gothic-online.com/forum-11.html)
+--- Forum: Scripting Help (https://archive.gothic-online.com/forum-12.html)
+--- Thread: onAnimation (/thread-1839.html)



onAnimation - imperior5 - 07.10.2016

How can I actually trigger something by using an animation, for example "S_1HATTACK" to print whenever it is used?


RE: onAnimation - Bimbol - 07.10.2016

onAnimation + getAnimationName()


RE: onAnimation - imperior5 - 07.10.2016

function onAnimation()
{

local anim = getAnimationName();
if (anim == S_1HATTACK)
{
print("HIT");
}

}

doesnt seem to work


RE: onAnimation - HammelGammel - 07.10.2016

Why doesn't it work? Do you get an error-message? In any case: It should be "S_1HATTACK". You're probably missing the quotationmarks.


RE: onAnimation - Bimbol - 07.10.2016

Of course he missing "" and onAnimation body has argument aniId.


RE: onAnimation - imperior5 - 07.10.2016

Well yes I was missing it but I tried with quotations mark before, ok so I need animation ID. To get it I should use getAnimationID yup?
so, for instance

function onCommand(cmd, params)
{
if(cmd == "use")
{
local anim = getAnimationID("T_LEGSHAKE");
print(anim);
}
}

why this command shows me, depending on what I do, different values?


...........................................................EDIT ALERT


I dont know if this function works correctly so I made timer

setTimer(function()
{
local aniID = getAnimationID();
print(aniID);

}, 200, true);

and it shows me that the ID is 68
however

function onAnimation()
{
local aniID = getAnimationID();
if (aniID == 68)
{
print("HIT");
}
}
is not working


RE: onAnimation - Bimbol - 07.10.2016

Squirrel Script
  1. function onAnimation(aniId)
  2. {
  3. local ani = getAnimationName();
  4. if (ani == "SOME_ANI")
  5. {
  6. print("HIT");
  7. }
  8. }


or better
Squirrel Script
  1. function onAnimation(aniId)
  2. {
  3. if (aniId == 68)
  4. {
  5. print("HIT");
  6. }
  7. }



Please use [code].


RE: onAnimation - imperior5 - 07.10.2016

solved, thank you.


RE: onAnimation - Son Goku - 07.10.2016

Bimbol. you are sure that the animation work? I tried to show getPlayerAni (pid) or getPlayerAni (heroId) and it does not work playAni (string) also I have the latest version of the client and the server .... translated by google Smile


ehh ok if he runs again, it means that I have something wrong