Random Animation OnPlayerRequestClass -
borg747 - 01.08.2012
By looking at a thread, I managed to create a code, consisting of an array, that stores the animation data, ex: "DANCING" and "dnce_M_b".
Then I added a random function that picks a random position of the array.
Finally I added this code under OnPlayerRequestClass and everything compiled properly.
The problem is that when I get to the skin selection screen, no animations will play and I can't quite figure out why.
Can you advise me on what I should do?
Код:
new RandomAnims[][] =
{
{"DANCING", "dnce_M_b"}, // RandomAnime
{"PAULNMAC", "wank_in"}, // RandomAnime
{"KISSING", "Grlfrd_Kiss_01"}, // RandomAnime
{"FIGHT_E", "FightKick"}, // RandomAnime
{"FIGHT_B", "FightB_1"} // RandomAnime
};
public OnPlayerRequestClass(playerid, classid)
{
new Random = random(sizeof(RandomAnims));
ApplyAnimation(playerid, RandomAnims[Random][0], RandomAnims[Random][1], 4.0, 1, 1, 1, 0, -1);
Re: Random Animation OnPlayerRequestClass -
iggy1 - 01.08.2012
If you look at the filterscript
gl_actions there is a function called
PreLoadAnimLib i beleive this is what you need to use. If you do not pre-load the anim libs, a lot of anims will need to be applied twice.
EDIT: gl_actions.pwn comes with the server package in the filterscript folder.
Re: Random Animation OnPlayerRequestClass -
borg747 - 01.08.2012
I have added the following code from gl_actions, it compiled properly, but still doesn't work:
Код:
new gPlayerAnimLibsPreloaded[MAX_PLAYERS];
PreloadAnimLib(playerid, animlib[])
{
ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}
public OnPlayerRequestClass(playerid, classid)
{
if(!gPlayerAnimLibsPreloaded[playerid]) {
PreloadAnimLib(playerid,"BOMBER");
PreloadAnimLib(playerid,"RAPPING");
PreloadAnimLib(playerid,"SHOP");
PreloadAnimLib(playerid,"BEACH");
PreloadAnimLib(playerid,"SMOKING");
PreloadAnimLib(playerid,"FOOD");
PreloadAnimLib(playerid,"ON_LOOKERS");
PreloadAnimLib(playerid,"DEALER");
PreloadAnimLib(playerid,"CRACK");
PreloadAnimLib(playerid,"CARRY");
PreloadAnimLib(playerid,"COP_AMBIENT");
PreloadAnimLib(playerid,"PARK");
PreloadAnimLib(playerid,"INT_HOUSE");
PreloadAnimLib(playerid,"FOOD");
PreloadAnimLib(playerid,"PAULNMAC");
PreloadAnimLib(playerid,"KISSING");
PreloadAnimLib(playerid,"FIGHT_E");
PreloadAnimLib(playerid,"FIGHT_B");
PreloadAnimLib(playerid,"DANCING");
gPlayerAnimLibsPreloaded[playerid] = 1;
}
Am I supposed to add :
Код:
PreloadAnimLib(playerid, "PED");
Because it would not really make sense putting this after the player has picked his skin/class.
Re: Random Animation OnPlayerRequestClass -
iggy1 - 01.08.2012
You only need to preload the anim libraries you are using.
pawn Код:
PreloadAnimLib(playerid,"DANCING");
PreloadAnimLib(playerid,"PAULNMAC");
PreloadAnimLib(playerid,"KISSING");
PreloadAnimLib(playerid,"FIGHT_E");
PreloadAnimLib(playerid,"FIGHT_B");
If it still does not work try putting it under
OnPlayerConnect
Re: Random Animation OnPlayerRequestClass -
borg747 - 01.08.2012
I did as you said but it still did not work.
Could it be that there is something wrong with my array?
Also, you said something about adding the animation twice, can you explain?
Re: Random Animation OnPlayerRequestClass -
Roko_foko - 01.08.2012
Your code:
pawn Код:
new RandomAnims[][] =
{
{"DANCING", "dnce_M_b"}, // RandomAnime
{"PAULNMAC", "wank_in"}, // RandomAnime
{"KISSING", "Grlfrd_Kiss_01"}, // RandomAnime
{"FIGHT_E", "FightKick"}, // RandomAnime
{"FIGHT_B", "FightB_1"} // RandomAnime
};
I think this should be three dimension array, no?
^ one dimenison
pawn Код:
TwoStrings[][]={"DANCING", "dnce_M_b"};
^two dimensions
pawn Код:
ALotOfStrings[][][]={
{"DANCING", "dnce_M_b"}, // RandomAnime
{"PAULNMAC", "wank_in"}, // RandomAnime
{"KISSING", "Grlfrd_Kiss_01"}, // RandomAnime
{"FIGHT_E", "FightKick"}, // RandomAnime
{"FIGHT_B", "FightB_1"}
}
^three dimensions
But, actually, I am not sure.
Re: Random Animation OnPlayerRequestClass -
borg747 - 01.08.2012
I changed the code to the following:
Код:
new RandomAnims[][][] =
{
{"DANCING", "dnce_M_b"}, // RandomAnime
{"PAULNMAC", "wank_in"}, // RandomAnime
{"KISSING", "Grlfrd_Kiss_01"}, // RandomAnime
{"FIGHT_E", "FightKick"}, // RandomAnime
{"FIGHT_B", "FightB_1"} // RandomAnime
};
Which gave me: error 048: array dimensions do not match
I also tried the two dimensional array
Код:
TwoStrings[][]={"DANCING", "dnce_M_b"};
but it also did not work...I even tried removing the random and simply reading from the array position, ie: 0, 1 but that also did not fix the problem.
Re: Random Animation OnPlayerRequestClass -
Roko_foko - 01.08.2012
pawn Код:
new RandomAnims[][][] =
{
{{"DANCING"}, {"dnce_M_b"}}, // RandomAnime
{{"PAULNMAC"}, {"wank_in"}}, // RandomAnime
{{"KISSING"}, {"Grlfrd_Kiss_01"}}, // RandomAnime
{{"FIGHT_E"}, {"FightKick"}}, // RandomAnime
{{"FIGHT_B"}, {"FightB_1"}} // RandomAnime
};
This will be good I think.
Re: Random Animation OnPlayerRequestClass -
borg747 - 01.08.2012
I got an error. Perhaps there's an extra bracket?
error 048: array dimensions do not match
Re: Random Animation OnPlayerRequestClass -
Roko_foko - 01.08.2012
That works fine for me.
Код:
This forum requires that you wait 120 seconds between posts. Please try again in 67 seconds.
-.-