SA-MP Forums Archive
Random Animation - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random Animation (/showthread.php?tid=630775)



Random Animation - GoldenLion - 18.03.2017

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?


Re: Random Animation - Logic_ - 18.03.2017

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


Re: Random Animation - GoldenLion - 18.03.2017

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


Re: Random Animation - TitanEVG - 18.03.2017

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"}
};



Re: Random Animation - GoldenLion - 18.03.2017

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?


Re: Random Animation - SyS - 18.03.2017

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


Re: Random Animation - Toroi - 18.03.2017

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



Re: Random Animation - GoldenLion - 18.03.2017

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.