SA-MP Forums Archive
Help - 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: Help (/showthread.php?tid=515131)



Help - JakeHunter1 - 24.05.2014

How to make if an animations is alredy on it can't do other anim ... (Speaking for the server Not a command anim.)


Re: Help - JakeHunter1 - 24.05.2014

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
You can use GetPlayerAnimationIndex(playerid)

OR (which i recommend)

Setting a variable when a player is doing an anim, then check it before doing another one.
how can i set varible (i'm a begginer )


Re: Help - Adityz - 25.05.2014

Quote:
Originally Posted by JakeHunter1
Посмотреть сообщение
how can i set varible (i'm a begginer )
Here's an example -

pawn Код:
new isplayerusinganim[MAX_PLAYERS]; // place it on the top of your script

public OnPlayerConnect(playerid)
{
    isplayerusinganim[playerid] = 0; // it means that  the player isn't using any animation
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    isplayerusinganim[playerid] = 0;
    return 1;
}
   

CMD:dance(playerid,params[]) // just an example
{
   if(isplayerusinganim[playerid] == 0)
   {
           ApplyAnimation(playerid,"DANCING","dance_loop",4.1,1,1,1,1,1,1);
           isplayerusinganim[playerid] = 1;
   }
   else if(isplayerusinganim[playerid] == 1)
   {
        SendClientMessage(playerid, 0xFFFFFFc8, "{FF0000}Error: {FFFFFF}An Animation is already in progress, use /stopanim to stop the current anim.);
   }
   return 1;
}

CMD:stopanim(playerid,params[])
{
    ClearAnimations(playerid);
    isplayerusinganim[playerid] = 0;
    return 1;
}



Re: Help - JakeHunter1 - 25.05.2014

Quote:
Originally Posted by Adityz
Посмотреть сообщение
Here's an example -

pawn Код:
new isplayerusinganim[MAX_PLAYERS]; // place it on the top of your script

public OnPlayerConnect(playerid)
{
    isplayerusinganim[playerid] = 0; // it means that  the player isn't using any animation
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    isplayerusinganim[playerid] = 0;
    return 1;
}
   

CMD:dance(playerid,params[]) // just an example
{
   if(isplayerusinganim[playerid] == 0)
   {
           ApplyAnimation(playerid,"DANCING","dance_loop",4.1,1,1,1,1,1,1);
           isplayerusinganim[playerid] = 1;
   }
   else if(isplayerusinganim[playerid] == 1)
   {
        SendClientMessage(playerid, 0xFFFFFFc8, "{FF0000}Error: {FFFFFF}An Animation is already in progress, use /stopanim to stop the current anim.);
   }
   return 1;
}

CMD:stopanim(playerid,params[])
{
    ClearAnimations(playerid);
    isplayerusinganim[playerid] = 0;
    return 1;
}
Thanks it works .. +REP