Random Animation and SA:MP crashes
#1

So, i want to make player perform random animation...
PHP код:
new RandomMove[][] =
{
    {
"Library""Anim Name"},
    {
"Library""Anim Name"},
    {
"Library""Anim Name"},
    {
"Library""Anim Name"},
    {
"Library""Anim Name"}
}; 
And now
PHP код:
Bla Bla Bla
ApplyAnimation
(playeridRandomMove[Random][0], RandomMove[Random][1], 4.101111); 
What's wrong? Maybe it won't work this way?
Reply
#2

pawn Код:
new RandomMove[5][1] =
{
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"}
};

pawn Код:
new rAnim = random( sizeof ( RandomMoves ) );
ApplyAnimation(playerid, RandomMove[rAnim][0], RandomMove[rAnim][1], 4.1, 0, 1, 1, 1, 1);
Here.

I think this might work.
Reply
#3

I did like you said but instead of RandomMove[5][1] i did RandomMove[5][2] 'cause yours gave me error about array or somethin Now i get this error
PHP код:
(10) : error 018initialization data exceeds declared size
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

Reply
#4

Quote:
Originally Posted by sekol
Посмотреть сообщение
I did like you said but instead of RandomMove[5][1] i did RandomMove[5][2] 'cause yours gave me error about array or somethin Now i get this error
PHP код:
(10) : error 018initialization data exceeds declared size
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

Ah damn, i made a mistake. It's 4 not 5, because 0 is counted too.
so
0,1,2,3,4 = 5 numbers.
Reply
#5

5 is correct, it is just the size when you create an array, and so starts with 1

Strings are arrays themself, so you need a 3d array:

pawn Код:
new RandomMove[5][2][24] =
{
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"}
};
Edit: You can use the same ApplyAnimation code you used before.
Reply
#6

Ehh, unfortunatelly it still crashes There's no hope for me
Reply
#7

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
5 is correct, it is just the size when you create an array, and so starts with 1

Strings are arrays themself, so you need a 3d array:

pawn Код:
new RandomMove[5][2][24] =
{
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"},
    {"Library", "Anim Name"}
};
Edit: You can use the same ApplyAnimation code you used before.
There is always something new you learn every day!

By the way, Seko, you might wanna try and study this function.

https://sampwiki.blast.hk/wiki/ApplyAnimation
Reply
#8

Ugh, people using PHP tags pisses me off. :/
Reply
#9

pawn Код:
Sorry -.-
PHP код:
Offtop? :
Anyway i think there's nothing wrong with my ApplyAnimation... I'll think about it tommorow...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)