Random Animation
#1

Hi, I'm making a death system right now and I stumbled across a problem where it doesn't get the whole animation name from an array.
This is the code:
Код:
static const DeathAnimations[][] =
{
	{"ped", "KO_skid_front"},
	{"ped", "KO_shot_stom"},
	{"ped", "KO_skid_front"},
	{"ped", "KO_skid_back"},
	{"KNIFE", "KILL_Knife_Ped_Die"}
};
new index = random(sizeof(DeathAnimations));
ApplyAnimation(playerid, DeathAnimations[index][0], DeathAnimations[index][1], 4.1, 0, 1, 1, 1, 0, 1);
I printed the library and animation's name out and it said
Код:
ped
ed
The library was correct but the name was just two letters. What's the problem here?
Reply
#2

try printing the animation name as well, if the same happens, use an enum.
Reply
#3

That's what I did. "ed" is the animation's name.
Reply
#4

you forgot an array size

Код HTML:
static const DeathAnimations[][][] =
{
	{"ped", "KO_skid_front"},
	{"ped", "KO_shot_stom"},
	{"ped", "KO_skid_front"},
	{"ped", "KO_skid_back"},
	{"KNIFE", "KILL_Knife_Ped_Die"}
};
Reply
#5

Quote:
Originally Posted by TitanEVG
Посмотреть сообщение
you forgot an array size

Код HTML:
static const DeathAnimations[][][] =
{
	{"ped", "KO_skid_front"},
	{"ped", "KO_shot_stom"},
	{"ped", "KO_skid_front"},
	{"ped", "KO_skid_back"},
	{"KNIFE", "KILL_Knife_Ped_Die"}
};
I'm pretty sure third dimension is not needed here, is it?
Reply
#6

thats 2d array you need more cells dimensions to hold string characters
Reply
#7

why dont you make this under your function instead of an array?

Код:
switch(random(4))
{
case 0: ApplyAnimation(playerid, ped, KO_skid_front, 4.1, 0, 1, 1, 1, 0, 1);
//and so on
Reply
#8

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
thats 2d array you need more cells dimensions to hold string characters
Thanks. I'll use an enumerator instead. I forgot about them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)