SA-MP Forums Archive
Apply Animation, Not working? - 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: Apply Animation, Not working? (/showthread.php?tid=284953)



Apply Animation, Not working? - Dokins - 21.09.2011

pawn Код:
CMD:cuff(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    new giveplayerid, string[128];
    if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /cuff [player id or name]");
    if(Faction[playerid] != 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not a member of the police.");
    if(!IsPlayerNearPlayer(playerid, giveplayerid, 3.0))return SendClientMessage(playerid, COLOUR_GREY, "You must be close to the player to cuff them.");
    {
        ApplyAnimation(giveplayerid, "PED", "cower", 1, 1, 0, 0, 0, 0, 1);
        TogglePlayerControllable(giveplayerid, 0);
        format(string, sizeof(string), "Officer %s has placed handcuffs on %s", GetNameEx(playerid), GetNameEx(giveplayerid));
        ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
    }
    return 1;
}
Alright, I go in game and cuff myself, it doesnt apply the animation for some reason. I cannot understand why.

Any help would be appreciated, + rep.


Re: Apply Animation, Not working? - sleepysnowflake - 21.09.2011

Try cuffing someone else ?


Re: Apply Animation, Not working? - =WoR=G4M3Ov3r - 21.09.2011

PHP код:
CMD:cuff(playeridparams[])
{
    if(
LoggedIn[playerid] == 0) return SendClientMessage(playeridCOLOUR_GREY"You must be logged in to use this command.");
    new 
giveplayeridstring[128];
    if(
sscanf(params"u"giveplayerid)) return SendClientMessage(playeridCOLOUR_GREY"Usage: /cuff [player id or name]");
    if(
Faction[playerid] != 1) return SendClientMessage(playeridCOLOUR_GREY"You are not a member of the police.");
    if(!
IsPlayerNearPlayer(playeridgiveplayerid3.0))return SendClientMessage(playeridCOLOUR_GREY"You must be close to the player to cuff them.");
    {
        
TogglePlayerControllable(giveplayerid0);
        
ClearAnimations(giveplayerid);
        
ApplyAnimation(giveplayerid"PED""cower"1100001);
        
format(stringsizeof(string), "Officer %s has placed handcuffs on %s"GetNameEx(playerid), GetNameEx(giveplayerid));
        
ProxDetector(30.0playeridstringCOLOUR_PURPLECOLOUR_PURPLECOLOUR_PURPLECOLOUR_PURPLECOLOUR_PURPLE);
    }
    return 
1;




Re: Apply Animation, Not working? - Davz*|*Criss - 21.09.2011

Removed.


Re: Apply Animation, Not working? - Kingunit - 21.09.2011

Quote:
Originally Posted by Davz*|*Criss
Посмотреть сообщение
Under IsPlayerNearPlayer remove the brace { and at the end up of return 1; remove the brace }

Just do that four functions without declaring it in IsPlayerNearPlayer.
Probably: =WoR=G4M3Ov3r is right. Since I had the same problem while I didn't have those { and }


Re: Apply Animation, Not working? - Kush - 21.09.2011

Quote:
Originally Posted by Kingunit
Посмотреть сообщение
Probably: =WoR=G4M3Ov3r is right. Since I had the same problem while I didn't have those { and }
The braces aren't needed.


Re: Apply Animation, Not working? - sleepysnowflake - 21.09.2011

The point is that the braces SHOULD NOT be there. It's not a matter of taste and so but they should just not be there.


Re: Apply Animation, Not working? - IstuntmanI - 21.09.2011

Try like this ...

Код:
CMD:cuff(playerid, params[])
{
	if(LoggedIn[playerid] == 0) 
		return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    
	new giveplayerid, string[128];
	if(sscanf(params, "u", giveplayerid)) 
		return SendClientMessage(playerid, COLOUR_GREY, "Usage: /cuff [player id or name]");
    
	if(Faction[playerid] != 1) 
		return SendClientMessage(playerid, COLOUR_GREY, "You are not a member of the police.");
    
	if(!IsPlayerNearPlayer(playerid, giveplayerid, 3.0))
		return SendClientMessage(playerid, COLOUR_GREY, "You must be close to the player to cuff them.");

	ApplyAnimation(giveplayerid, "PED", "cower", 1, 1, 0, 0, 0, 0, 1);
	TogglePlayerControllable(giveplayerid, 0);
	format(string, sizeof(string), "Officer %s has placed handcuffs on %s", GetNameEx(playerid), GetNameEx(giveplayerid));
	ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
	return 1;
}
Код:
if(!IsPlayerNearPlayer(playerid, giveplayerid, 3.0))
checks if the player is not near the specified player, if not, will end the command, else, will continue the command.


Re: Apply Animation, Not working? - Vince - 21.09.2011

You need to preload all the animation libraries you use first.
pawn Код:
stock PreloadAnimLib(playerid, animlib[])
    ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
Then put this under OnPlayerSpawn or so:
pawn Код:
PreloadAnimLib(playerid, "PED");



Re: Apply Animation, Not working? - dreamworld - 21.09.2011

You need to play this anim,when you try this first time anim dont play and when you try second time anim play

put same anim onplayerspawn


Re: Apply Animation, Not working? - Dokins - 21.09.2011

Thanks!


Re: Apply Animation, Not working? - =WoR=Varth - 22.09.2011

All of them:
pawn Code:
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,"PED" );
Missed anything?



Re: Apply Animation, Not working? - Stigg - 22.09.2011

Quote:
Originally Posted by =WoR=Varth
View Post
All of them:
pawn Code:
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,"PED" );
Missed anything?
And of course not forgetting:

pawn Code:
PreloadAnimLib(playerid, animlib[])
{
    ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}



Re: Apply Animation, Not working? - =WoR=Varth - 22.09.2011

Quote:
Originally Posted by Stigg
View Post
And of course not forgetting:

pawn Code:
PreloadAnimLib(playerid, animlib[])
{
    ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}
Vince already mention that.


Re: Apply Animation, Not working? - Stigg - 22.09.2011

Quote:
Originally Posted by =WoR=Varth
View Post
Vince already mention that.
It was just a reminder.