Anim problem
#1

Ok, I am trying to create a filterscript for my server, so I can keep track of what anims we have.
Problem is, with certain anims, the player dosen't stop looping them.
I used mostly code from actions and vactions.
Heres the FS:
pawn Code:
#pragma tabsize 0
#include <a_samp>
#include <core>
#include <float>

//-------------------------------------------------
new gIsDancing[MAX_PLAYERS];
new gCurrentDanceMove[MAX_PLAYERS];
new gPlayerUsingLoopingAnim[MAX_PLAYERS];
new gPlayerAnimLibsPreloaded[MAX_PLAYERS];

forward ApplyDanceMove(playerid, dancemove);
forward ChangeToNextDanceMove(playerid);
forward ChangeToPreviousDanceMove(playerid);

OnePlayAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
{
    ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
}

//-------------------------------------------------

LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
{
  gPlayerUsingLoopingAnim[playerid] = 1;
  ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
}

//-------------------------------------------------

StopLoopingAnim(playerid)
{
    gPlayerUsingLoopingAnim[playerid] = 0;
  ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
  TogglePlayerControllable(playerid,true);
}
PreloadAnimLib(playerid, animlib[])
{
    ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}



public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[256];
    new idx;
    new dancestyle;
    cmd = strtok(cmdtext, idx);
    ///////////////////////////
    if(strcmp(cmd, "/animlist", true) == 0) {
        SendClientMessage(playerid,0xAFAFAFAA,"Available Animations:");
      SendClientMessage(playerid,0xAFAFAFAA,"/dance /olddance /bomb /getarrested /laugh /lookout /robman");
    SendClientMessage(playerid,0xAFAFAFAA,"/crossarms /lay /eat /slapass /chairsit");
    SendClientMessage(playerid,0xAFAFAFAA,"/deal /crack /groundsit /chat /taichi");
    SendClientMessage(playerid,0xAFAFAFAA,"Type /actions for a list of other type of animations");
    return 1;
    }
   
   
   
    if(strcmp(cmd, "/dance", true) == 0) {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
          new tmp[256];

          // Get the dance style param
        tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) {
                SendClientMessage(playerid,0xFF0000FF,"Usage: /dance [style 1-3]");
                return 1;
            }

            dancestyle = strval(tmp);
            if(dancestyle < 1 || dancestyle > 3) {
              SendClientMessage(playerid,0xFF0000FF,"Usage: /dance [style 1-3]");
              return 1;
            }

            if(dancestyle == 1) {
              SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE1);
            } else if(dancestyle == 2) {
              SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE2);
            } else if(dancestyle == 3) {
              SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE3);
            }
            return 1;
        }
    }
    if(strcmp(cmd, "/olddance", true) == 0) {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
        gCurrentDanceMove[playerid] = 0;
        gIsDancing[playerid] = 1;
        ChangeToNextDanceMove(playerid);
            return 1;
        }
    }
   

    if (strcmp("/bomb", cmdtext, true) == 0) {
        ClearAnimations(playerid);
        OnePlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0); // Place Bomb
        return 1;
    }
    // Police Arrest
  if (strcmp("/getarrested", cmdtext, true, 7) == 0) {
       LoopingAnim(playerid,"ped", "ARRESTgun", 4.0, 0, 1, 1, 1, -1); // Gun Arrest
         return 1;
  }
    // Laugh
  if (strcmp("/laugh", cmdtext, true) == 0) {
     OnePlayAnim(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0); // Laugh
         return 1;
    }
    // Rob Lookout
  if (strcmp("/lookout", cmdtext, true) == 0) {
     OnePlayAnim(playerid, "SHOP", "ROB_Shifty", 4.0, 0, 0, 0, 0, 0); // Rob Lookout
         return 1;
    }
    // Rob Threat
  if (strcmp("/robman", cmdtext, true) == 0) {
     LoopingAnim(playerid, "SHOP", "ROB_Loop_Threat", 4.0, 1, 0, 0, 0, 0); // Rob
         return 1;
    }
    // Arms crossed
  if (strcmp("/crossarms", cmdtext, true) == 0) {
     LoopingAnim(playerid, "COP_AMBIENT", "Coplook_loop", 4.0, 0, 1, 1, 1, -1); // Arms crossed
         return 1;
    }
    // Lay Down
  if (strcmp("/lay", cmdtext, true, 6) == 0) {
     LoopingAnim(playerid,"BEACH", "bather", 4.0, 1, 0, 0, 0, 0); // Lay down
         return 1;
  }
  if (strcmp("/eat", cmdtext, true) == 0) {
       OnePlayAnim(playerid, "FOOD", "EAT_Burger", 3.0, 0, 0, 0, 0, 0); // Eat Burger
         return 1;
    }
  if (strcmp("/slapass", cmdtext, true) == 0) {
     OnePlayAnim(playerid, "SWEET", "sweet_ass_slap", 4.0, 0, 0, 0, 0, 0); // Ass Slapping
         return 1;
    }
    // Dealer
  if (strcmp("/deal", cmdtext, true) == 0) {
     OnePlayAnim(playerid, "DEALER", "DEALER_DEAL", 4.0, 0, 0, 0, 0, 0); // Deal Drugs
         return 1;
    }
    if (strcmp("/groundsit", cmdtext, true, 4) == 0) {
     LoopingAnim(playerid,"BEACH", "ParkSit_M_loop", 4.0, 1, 0, 0, 0, 0); // Sit
         return 1;
  }
  // Idle Chat
  if(strcmp(cmd, "/chat", true) == 0) {
         OnePlayAnim(playerid,"PED","IDLE_CHAT",4.0,0,0,0,0,0);
    return 1;
  }
  // Fucku
  if(strcmp(cmd, "/fucku", true) == 0) {
         OnePlayAnim(playerid,"PED","fucku",4.0,0,0,0,0,0);
    return 1;
  }
  if(strcmp(cmd, "/taichi", true) == 0) {
         LoopingAnim(playerid,"PARK","Tai_Chi_Loop",4.0,1,0,0,0,0);
    return 1;
  }

  // ChairSit
  if(strcmp(cmd, "/chairsit", true) == 0) {
         LoopingAnim(playerid,"BAR","dnk_stndF_loop",4.0,1,0,0,0,0);
    return 1;
  }
   
   
   
   
   
   

    return 0;
}
public OnPlayerSpawn(playerid)
{
    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");
        gPlayerAnimLibsPreloaded[playerid] = 1;
    }
    return 1;
}
public OnPlayerConnect(playerid)
{
  gPlayerUsingLoopingAnim[playerid] = 0;
    gPlayerAnimLibsPreloaded[playerid] = 0;

    return 1;
}

//-------------------------------------------------

dance_strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

//------------------------------------------------

IsKeyJustDown(key, newkeys, oldkeys)
{
    if((newkeys & key) && !(oldkeys & key)) return 1;
    return 0;
}

//------------------------------------------------

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(!gIsDancing[playerid]) return;
   
    if(!gPlayerUsingLoopingAnim[playerid]) return;

    if(IsKeyJustDown(KEY_FIRE,newkeys,oldkeys)) {
    ChangeToNextDanceMove(playerid);
        return;
    }
    if(IsKeyJustDown(KEY_JUMP,newkeys,oldkeys)) {
     ChangeToPreviousDanceMove(playerid);
    }

    if(IsKeyJustDown(KEY_SPRINT,newkeys,oldkeys)) {
        gCurrentDanceMove[playerid] = 0;
    gIsDancing[playerid] = 0;
    ClearAnimations(playerid);
    StopLoopingAnim(playerid);
  }

    if(IsKeyJustDown(KEY_SPRINT,newkeys,oldkeys)) {
      StopLoopingAnim(playerid);
  }
}
ApplyDanceMove(playerid, dancemove)
{
    switch(dancemove) {
        case 0:
            ApplyAnimation(playerid,"DANCING","DAN_LOOP_A",4.0,1,0,0,0,-1);
        case 1:
            ApplyAnimation(playerid,"DANCING","DNCE_M_A",4.0,1,0,0,0,-1);
        case 2:
            ApplyAnimation(playerid,"DANCING","DNCE_M_B",4.0,1,0,0,0,-1);
        case 3:
            ApplyAnimation(playerid,"DANCING","DNCE_M_C",4.0,1,0,0,0,-1);
        case 4:
            ApplyAnimation(playerid,"DANCING","DNCE_M_D",4.0,1,0,0,0,-1);
        case 5:
            ApplyAnimation(playerid,"DANCING","DNCE_M_E",4.0,1,0,0,0,-1);
    }
}
ChangeToNextDanceMove(playerid)
{
  gCurrentDanceMove[playerid]++;
  if(gCurrentDanceMove[playerid]==6) gCurrentDanceMove[playerid]=0;
    ApplyDanceMove(playerid,gCurrentDanceMove[playerid]);
}

//-------------------------------------------------

ChangeToPreviousDanceMove(playerid)
{
  gCurrentDanceMove[playerid]--;
  if(gCurrentDanceMove[playerid]<0) gCurrentDanceMove[playerid]=5;
    ApplyDanceMove(playerid,gCurrentDanceMove[playerid]);
}
Reply
#2

What's the problem?
Reply
#3

Quote:
Originally Posted by Byrner
Problem is, with certain anims, the player dosen't stop looping them.
LMAO
Reply
#4

pm me if you no where i can get pedwalk anim?



pls i need it

Reply
#5

Can ANYBODY help with this, ANY idea.
Reply
#6

Quote:
Originally Posted by Byrner
Can ANYBODY help with this, ANY idea.
What's the problem?
Reply
#7

if its what i think it is, im having the samr problem..

You do an anim and you cant get out of it by pressing space or by pressing punch or fire, you have to do /kill or do another anim like /kiss /piss or /wank to stop the first anim looping.

Im having that problem, not sure how to fix it.
Reply
#8

Quote:
Originally Posted by Serbish
Quote:
Originally Posted by Byrner
Can ANYBODY help with this, ANY idea.
What's the problem?
Anims wont stop
Reply
#9

Quote:
Originally Posted by Dujma
Quote:
Originally Posted by Serbish
Quote:
Originally Posted by Byrner
Can ANYBODY help with this, ANY idea.
What's the problem?
Anims wont stop
He must press the fire button, that means left mouse or SHIFT.
Reply
#10

Quote:
Originally Posted by Serbish
Quote:
Originally Posted by Dujma
Quote:
Originally Posted by Serbish
Quote:
Originally Posted by Byrner
Can ANYBODY help with this, ANY idea.
What's the problem?
Anims wont stop
He must press the fire button, that means left mouse or SHIFT.
Not all of the anims stop in that way
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)