_Zume

zAnimsFix SA:MP INC

Mar 20th, 2015
1,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.32 KB | None | 0 0
  1. /* zAnimsFix & _Zume    */
  2.  
  3. #if !defined _samp_included
  4.   #error "Foul include a_samp, if not the include zAnimsFix not work!"
  5. #endif
  6.  
  7. #if !defined _zAnimsFix_include
  8.   #define _zAnimsFix_include
  9. #else
  10.   #endinput
  11. #endif
  12.  
  13. #define LastAnimExecuted    _getLastAnim
  14. #define LastAnimLibExecuted _getLastLib
  15. #define AnimLibExists      _animLibExist
  16.  
  17. #if !defined isnull
  18.   #define isnull(%1) \
  19.               ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  20. #endif
  21.  
  22. enum _pAnims
  23. {
  24.     bool:_pAlredyAnimsLoaded,
  25.     _pAnimExecute,
  26.     _pLastAnim[32 char],
  27.     _pLastAnimLib[32 char],
  28.  
  29. };
  30. new _eAnim[MAX_PLAYERS][_pAnims];
  31.  
  32. static const _AnimsEnum[][] =
  33. {
  34.     "AIRPORT",      "Attractors",   "BAR",          "BASEBALL",     "BD_FIRE",
  35.     "BEACH",        "benchpress",   "BF_injection", "BIKED",        "BIKEH",
  36.     "BIKELEAP",     "BIKES",        "BIKEV",        "BIKE_DBZ",     "BLOWJOBZ",
  37.     "BMX",          "BOMBER",       "BOX",          "BSKTBALL",     "BUDDY",
  38.     "BUS",          "CAMERA",       "CAR",          "CARRY",        "CAR_CHAT",
  39.     "CASINO",       "CHAINSAW",     "CHOPPA",       "CLOTHES",      "COACH",
  40.     "COLT45",       "COP_AMBIENT",  "COP_DVBYZ",    "CRACK",        "CRIB",
  41.     "DAM_JUMP",     "DANCING",      "DEALER",       "DILDO",        "DODGE",
  42.     "DOZER",        "DRIVEBYS",     "FAT",          "FIGHT_B",      "FIGHT_C",
  43.     "FIGHT_D",      "FIGHT_E",      "FINALE",       "FINALE2",      "FLAME",
  44.     "Flowers",      "FOOD",         "Freeweights",  "GANGS",        "GHANDS",
  45.     "GHETTO_DB",    "goggles",      "GRAFFITI",     "GRAVEYARD",    "GRENADE",
  46.     "GYMNASIUM",    "HAIRCUTS",     "HEIST9",       "INT_HOUSE",    "INT_OFFICE",
  47.     "INT_SHOP",     "JST_BUISNESS", "KART",         "KISSING",      "KNIFE",
  48.     "LAPDAN1",      "LAPDAN2",      "LAPDAN3",      "LOWRIDER",     "MD_CHASE",
  49.     "MD_END",       "MEDIC",        "MISC",         "MTB",          "MUSCULAR",
  50.     "NEVADA",       "ON_LOOKERS",   "OTB",          "PARACHUTE",    "PARK",
  51.     "PAULNMAC",     "ped",          "PLAYER_DVBYS", "PLAYIDLES",    "POLICE",
  52.     "POOL",         "POOR",         "PYTHON",       "QUAD",         "QUAD_DBZ",
  53.     "RAPPING",      "RIFLE",        "RIOT",         "ROB_BANK",     "ROCKET",
  54.     "RUSTLER",      "RYDER",        "SCRATCHING",   "SHAMAL",       "SHOP",
  55.     "SHOTGUN",      "SILENCED",     "SKATE",        "SMOKING",      "SNIPER",
  56.     "SPRAYCAN",     "STRIP",        "SUNBATHE",     "SWAT",         "SWEET",
  57.     "SWIM",         "SWORD",        "TANK",         "TATTOOS",      "TEC",
  58.     "TRAIN",        "TRUCK",        "UZI",          "VAN",          "VENDING",
  59.     "VORTEX",       "WAYFARER",     "WEAPONS",      "WUZI"
  60. };
  61.  
  62. stock _animLibExist(_LoadAnin[])
  63. {
  64.     if(_LoadAnin[0] == '\0')
  65.         return 0;
  66.  
  67.     for(new i = 0; i < sizeof(_AnimsEnum); i ++)
  68.     {
  69.         if(!strcmp(_LoadAnin, _AnimsEnum[i], true))
  70.         {
  71.             return 1;
  72.         }
  73.     }
  74.     return 0;
  75. }
  76.  
  77. stock _animPreload(playerid)
  78. {
  79.     if(!IsPlayerConnected(playerid))
  80.         return 0;
  81.  
  82.     if(_eAnim[playerid][_pAlredyAnimsLoaded] == true)
  83.         return 0;
  84.  
  85.     for(new i = 0; i < sizeof(_AnimsEnum); i ++)
  86.     {
  87.         ApplyAnimation(playerid, _AnimsEnum[i], "null", 4.0, 0, 0, 0, 0, 0, 1);
  88.         _eAnim[playerid][_pAlredyAnimsLoaded] = true;
  89.     }
  90.     return 1;
  91. }
  92.  
  93. stock _getLastAnim(playerid)
  94. {
  95.     new
  96.         string[33] = "None"
  97.         ;
  98.  
  99.     if(IsPlayerConnected(playerid))
  100.     {
  101.         if(!isnull(_eAnim[playerid][_pLastAnim]))
  102.         {
  103.             strunpack(string, _eAnim[playerid][_pLastAnim]);
  104.         }
  105.     }
  106.     return string;
  107. }
  108.  
  109. stock _getLastLib(playerid)
  110. {
  111.     new
  112.         string[33] = "None"
  113.         ;
  114.  
  115.     if(IsPlayerConnected(playerid))
  116.     {
  117.         if(!isnull(_eAnim[playerid][_pLastAnimLib]))
  118.         {
  119.             strunpack(string, _eAnim[playerid][_pLastAnimLib]);
  120.         }
  121.     }
  122.     return string;
  123. }
  124.  
  125. stock _resetPlayerAnims(playerid)
  126. {
  127.     if(!IsPlayerConnected(playerid))
  128.         return 0;
  129.  
  130.     _eAnim[playerid][_pAlredyAnimsLoaded] = false;
  131.     _eAnim[playerid][_pAnimExecute] = 0;
  132.     _eAnim[playerid][_pLastAnim][0] = '\0';
  133.     _eAnim[playerid][_pLastAnimLib][0] = '\0';
  134.     return 1;
  135. }
  136.  
  137. stock _AppliAnimEx(playerid, animlib[], anim[], Float:vel = 4.1, bucle = 0, lockx = 1, locky = 1, freeze = 1, time = 1, sync = 1)
  138. {
  139.     if(IsPlayerConnected(playerid))
  140.     {
  141.         if(!strcmp(_getLastAnim(playerid), anim, true))
  142.         {
  143.             if(_eAnim[playerid][_pAnimExecute] > gettime())
  144.             {
  145.                 return 0;
  146.             }
  147.         }
  148.         new
  149.             bool:_animLibExists = false;
  150.  
  151.         if(!strcmp(_getLastLib(playerid), animlib, true))
  152.         {
  153.             _animLibExists = true;
  154.         }
  155.         else
  156.         {
  157.             if(_animLibExists != true)
  158.             {
  159.                 _animLibExists = ((_animLibExist(animlib)) ? (true) : (false));
  160.             }
  161.         }
  162.         if(_animLibExists != false)
  163.         {
  164.             ApplyAnimation(playerid, animlib, anim, vel, bucle, lockx, locky, freeze, time, sync);
  165.             _eAnim[playerid][_pAnimExecute] = gettime()+1;
  166.             strunpack(_eAnim[playerid][_pLastAnimLib], animlib);
  167.             strunpack(_eAnim[playerid][_pLastAnim], anim);
  168.             return 1;
  169.         }
  170.     }
  171.     return 0;
  172. }
  173.  
  174. public OnPlayerSpawn(playerid)
  175. {
  176.     _animPreload(playerid);
  177.  
  178.     #if defined zHook_OnPlayerSpawn
  179.       return zHook_OnPlayerSpawn(playerid);
  180.     #else
  181.       return 1;
  182.     #endif
  183. }
  184.  
  185. public OnPlayerConnect(playerid)
  186. {
  187.     _resetPlayerAnims(playerid);
  188.  
  189.     #if defined zHook_OnPlayerConnect
  190.       return zHook_OnPlayerConnect(playerid);
  191.     #else
  192.       return 1;
  193.     #endif
  194. }
  195.  
  196. #if defined _ALS_OnPlayerConnect
  197.   #undef OnPlayerConnect
  198. #else
  199.   #define _ALS_OnPlayerConnect
  200. #endif
  201.  
  202. #if defined _ALS_OnPlayerSpawn
  203.   #undef OnPlayerSpawn
  204. #else
  205.   #define _ALS_OnPlayerSpawn
  206. #endif
  207.  
  208. #if defined _ALS_ApplyAnimation
  209.   #undef ApplyAnimation
  210. #else
  211.   #define _ALS_ApplyAnimation
  212. #endif
  213.  
  214. #define ApplyAnimation          _AppliAnimEx
  215. #define OnPlayerSpawn           zHook_OnPlayerSpawn
  216. #define OnPlayerConnect         zHook_OnPlayerConnect
  217.  
  218. #if defined zHook_OnPlayerSpawn
  219.   forward zHook_OnPlayerSpawn(playerid);
  220. #endif
  221.  
  222. #if defined zHook_OnPlayerConnect
  223.   forward zHook_OnPlayerConnect(playerid);
  224. #endif
Advertisement
Add Comment
Please, Sign In to add comment